Progress :eng101:
[IMG]http://dl.dropbox.com/u/7941751/notbreakout.PNG[/IMG]
Ball is bouncing from the sides and also accelerates till it reaches light speed (I should limit that).
Next up is paddle collision and sound.
Yay, from a background of zero prior experience with Lua I've managed to get most of the tasks done in about two hours. There's a ball, it bounces around the screen, and accelerates slowly; There's a paddle, it moves left and right using arrow keys; the ball bounces off the paddle (very buggy, though), and it resets back to the middle when it falls off the bottom. I'm quite pleased with my progress :smile:
Are people using the Physics module? or are they just gonna create their own mini one?
[QUOTE=Bambo.;32890100]Are people using the Physics module? or are they just gonna create their own mini one?[/QUOTE]
I tried using the physics module, I wasted about an hour trying to get that piece of crap to work. It's hell on earth, I found -- though maybe it's just my lack of experience with love and lua.
I've started to draw the sprites but I don't know how the ball bouncing logic should work :v:
There is also this - [url]http://love2d.org/wiki/HardonCollider[/url] - if you want to use something else for collision detection.
[QUOTE=Swebonny;32889747]Lua is so different from languages like Java or C++. It's confusing but yet looks so simple.[/QUOTE]
its very C like in my opinion.
Apart from the reason using the physics module for this is like solving x[sup]2[/sup] = 9 with a CAS, it would be much more beneficial for your programming experience to understand how the ball bounces around and collides with the paddle.
Using the physics module is [B]way[/B] overkill.
I'm learning actionscript at college. I think I'll give this a go, but I have never even seen lua code before, so I expect imminent failure.
[QUOTE=Overv;32890501]Apart from the reason using the physics module for this is like solving x[sup]2[/sup] = 9 with a CAS, it would be much more beneficial for your programming experience to understand how the ball bounces around and collides with the paddle.[/QUOTE]
There's nothing fun about that.
How do you make something collide within a range of like 90 pixels :v:
Well I got the ball bouncing around but I have no idea how to do collision detection
The secret with collision detection is to come at it the other way. You want to do tests that test that it isn't colliding. I have a library of simple intersections here. It's coded in C++ but the logic is still the same.
[url]http://code.google.com/p/bootil/source/browse/trunk/Bootil/Intersection/Intersections.h[/url]
If you want to detect whether 2 rects intersect..
[cpp]inline bool RectIntersectRect( const Rect& r1, const Rect& r2 )
{
if ( r1.x1 > r2.x2 ) return false;
if ( r1.x2 < r2.x1 ) return false;
if ( r1.y1 > r2.y2 ) return false;
if ( r1.y2 < r2.y1 ) return false;
return true;
}[/cpp]
Where x1 is the left, x2 is the right, y1 is the top, y2 is the bottom. You're basically saying "if there's no way it can collide then return, else keep testing"
[QUOTE=FlashStock;32891362]Well I got the ball bouncing around but I have no idea how to do collision detection[/QUOTE]
Make a rectangle that follows the ball, and one that follows the paddle. If they're about to intersect, invert the y-velocity of the ball. Easy.
That said there's probably some non-complicated library you can download for Love. I would assume :(
-snip-
[QUOTE=garry;32891416]The secret with collision detection is to come at it the other way. You want to do tests that test that it isn't colliding. I have a library of simple intersections here. It's coded in C++ but the logic is still the same.
[url]http://code.google.com/p/bootil/source/browse/trunk/Bootil/Intersection/Intersections.h[/url]
If you want to detect whether 2 rects intersect..
[cpp]inline bool RectIntersectRect( const Rect& r1, const Rect& r2 )
{
if ( r1.x1 > r2.x2 ) return false;
if ( r1.x2 < r2.x1 ) return false;
if ( r1.y1 > r2.y2 ) return false;
if ( r1.y2 < r2.y1 ) return false;
return true;
}[/cpp]
Where x1 is the left, x2 is the right, y1 is the top, y2 is the bottom. You're basically saying "if there's no way it can collide then return, else keep testing"[/QUOTE]
I got it working now, thanks! Only block destroying left now :D
I'm good
[video=youtube;ysSauFL5Zcw]http://www.youtube.com/watch?v=ysSauFL5Zcw[/video]
It's nice developing something simple in LÖVE. It's a nice contrast to the huge projects I usually get involved in.
[img]http://localhostr.com/files/DdOGghp/capture.png[/img]
Adding to what Garry said before, here are some useful snippets... [url]http://love2d.org/wiki/Category:Snippets[/url]
[url]http://love2d.org/wiki/BoundingBox.lua[/url] - Is basically what Garry was talking about ( i think )
[url]http://love2d.org/wiki/PointWithinShape[/url] - Is a small bunch of collision code snippets ( i contributed the intersect one! feel free to update it because I think its pretty un-optimized )
[editline]21st October 2011[/editline]
I just saw... i need to edit in the checkDir() function into that.
After the challenge is over, will you make a semi tutorial explaining each function and stuff? I'm giving this a try but can't seem to do it.
[QUOTE=LordCrypto;32893297]After the challenge is over, will you make a semi tutorial explaining each function and stuff? I'm giving this a try but can't seem to do it.[/QUOTE]
Check out the LOVE wiki!
I want to learn Love2d and I love brick-breaker games.
Why not give this a shot.
So let's have a look at this.
[IMG]http://dl.dropbox.com/u/7941751/icbinb1.PNG[/IMG]
AWESOME TITLE SCREEN GRAPHICS
[IMG]http://dl.dropbox.com/u/7941751/icbinb2.PNG[/IMG]
REVOLUTIONARY GAMEPLAY
[IMG]http://dl.dropbox.com/u/7941751/icbinb3.PNG[/IMG]
CRAZY STATS FOR STAT ADDICTS
Also the only thing I've ever finished :dance:
[URL="http://dl.dropbox.com/u/7941751/ICBINB.7z"]DOWNLOAD[/URL]
[QUOTE]• Some kind of paddle at the bottom -DONE
• Control the paddle with the mouse or the keyboard -DONE
• Add a `Ball` -DONE
• Ball moves of its own free will -DONE
• Ball bounces from the top, left and right walls -DONE
• Ball collides with the paddle -DONE[/QUOTE]
It also get's harder the longer you play, try to survive as long as you can.
One sentence summary: LOVE2d is fun to use.
TODO: Fix collisions and thumb pictures.
Okay, I got my paddle done, next step is the ball.
How would I prevent the pad from moving out of the box?
My pad moves more than one pixel per update, and therefore goes over the edge by some pixels :-(
I guess it's the same problem as the collision one, but this more than 1 pixel per update annoys the hell out of me.
[QUOTE=AGMadsAG;32894853]How would I prevent the pad from moving out of the box?
My pad moves more than one pixel per update, and therefore goes over the edge by some pixels :-([/QUOTE]
[code]
-- when moving left
if paddlex >= 0 then
-- move paddle left
end
-- when moving right
if (paddlex + paddle width) <= 650 thn
-- move paddle right
end
[/code]
but make sure you compensate for the width.ect when moving right ( depending on what you are using )
[QUOTE=AGMadsAG;32894853]How would I prevent the pad from moving out of the box?
My pad moves more than one pixel per update, and therefore goes over the edge by some pixels :-(
I guess it's the same problem as the collision one, but this more than 1 pixel per update annoys the hell out of me.[/QUOTE]
Check the position and if it goes above or below the screen size stop it from moving, or above.
Sorry, you need to Log In to post a reply to this thread.