[QUOTE=Paulendy;32929947]I've got the ball moving but I have no idea how I can do the collision stuff.[/QUOTE]
For basic wall collision, just make it so that when the ball's x position is lower than 0 then reverse it's direction. Do the same for both walls and then the top wall reverse the y direction. Probably not making sense sorry :v:.
[QUOTE=icemaz;32930517]For basic wall collision, just make it so that when the ball's x position is lower than 0 then reverse it's direction. Do the same for both walls and then the top wall reverse the y direction. Probably not making sense sorry :v:.[/QUOTE]
I've tried that, it just bounces around at the wall, I'm probably just doing something stupid.
I was getting similar problems, what I did was just stop changing one little bit, remove all the relevant code again and just work through it a lot more logically. Write stuff down on a bit of paper if you need to, sometimes it helps to not just dive in but to think before you do the code rather than while you're doing it. If all else fails post the code here so we can help :v:
[QUOTE=Paulendy;32930570]I've tried that, it just bounces around at the wall, I'm probably just doing something stupid.[/QUOTE]
Show the code.
[QUOTE=icemaz;32930517]For basic wall collision, just make it so that when the ball's x position is lower than 0 then reverse it's direction. Do the same for both walls and then the top wall reverse the y direction. Probably not making sense sorry :v:.[/QUOTE]
Like this?
[code]bally = bally + Ballvel
ballx = ballx + Ballvel
if bally == height then
Ballvel = -Ballvel
end
if bally == 5 then
Ballvel = -Ballvel
end
if ballx == width then
Ballvel = -Ballvel
end
if ballx == 5 then
Ballvel = -Ballvel
end
end
[/code]
It bounces between two points depending on what X / Y is, but I've got no idea on how to make it move freely.
Also there's probably some really simple way to do all that math, but I always over complicate. Also is it bad I'm using love.graphics.circle for the ball instead of an image?
Have seperate x and y velocities.
I looked at how FlashStock did it and now I realize how silly I am.
[QUOTE=Map in a box;32931423]Have seperate x and y velocities.[/QUOTE]
Holy shit you are a god among men.
Eh, I just made the ball and tried to set CollisionCallbacks (Is this what I'm supposed to use?) and when I start up the game I get this:
[QUOTE][IMG]http://i1221.photobucket.com/albums/dd461/All0utWar/GameProblem.png[/IMG][/QUOTE]
Any ideas? Here's the code:
[url]http://pastebin.com/XS5ThA8h[/url]
You really, really don't need to (and shouldn't) use love.physics for this.
Then how do I make the ball bounce freely?
[media]http://www.youtube.com/watch?v=ZRgWh6LctzM[/media] Jealous?
[editline]23rd October 2011[/editline]
[QUOTE=BlkDucky;32932616]You really, really don't need to (and shouldn't) use love.physics for this.[/QUOTE]
I actually agree, 110%. Don't use Box2D for this. :v:
[QUOTE=amcfaggot;32933081][media]http://www.youtube.com/watch?v=ZRgWh6LctzM[/media] Jealous?
[editline]23rd October 2011[/editline]
I actually agree, 110%. Don't use Box2D for this. :v:[/QUOTE]
I am, I can't even figure out how to add gravity, collisions, or the boxes at the top.
[QUOTE=garry;32888083]
• Ball moves of its own free will
[/QUOTE]
This is what I am having the most difficulty with. Does it have to experience emotion too?
Here's the latest\final edits to my cow thing.
[media]http://www.youtube.com/watch?v=T_2cj4e7Ssw[/media]
You can [url=http://dl.dropbox.com/u/6929441/gwilty01rc3.love]download it here[/url], not that you'd ever want to though. I might make a post once this assignment is over explaining how I wrote it, if anyone needs a hand getting graphics\drawing\"physics" etc working. It's not the greatest code, at all (if you download it and open it as a zipfile you can see the source), but it works enough for a joke entry.
Haha I remember my first method for hit detection in Java. I would do this assignment but I don't have the slightest clue about Love. I can't even comprehend what I did here, but it worked:
[IMG]http://i.imgur.com/I3V9g.png[/IMG]
[QUOTE=toaster468;32924461]Just saying that this only returns true or false if it is colliding at ANY point meaning, if the ball hits the side of the paddle it wont tell you if it hit the sides, top , or bottom. That said put it in your update loop.[/QUOTE]
Instead of just returning true or false, you could return a value between 1 and 4 depending on what side is hit, and 0 if it doesn't intersect. That way you could still treat it as a boolean for an if block and it'd give you the information needed.
[QUOTE=amcfaggot;32933081][media]http://www.youtube.com/watch?v=ZRgWh6LctzM[/media] Jealous?
[editline]23rd October 2011[/editline]
I actually agree, 110%. Don't use Box2D for this. :v:[/QUOTE]
Awesome music.
[QUOTE=TheDecryptor;32935679]Instead of just returning true or false, you could return a value between 1 and 4 depending on what side is hit, and 0 if it doesn't intersect. That way you could still treat it as a boolean for an if block and it'd give you the information needed.[/QUOTE]
In Lua, 0 is still considered 'true', e.g. "if 0 then foo end" will execute. You could make it return false if no collision while still returning numbers for the sides though.
I'm gonna end up turning this project into a full game if I can. Do you think I should? It'll have levels and shit. :D
This gave me an opportunity to finally make a sequel to my first Flash game.
Im gonna make... A platform runner! In Lua ofc.
Well I now have a lonely game of vertical pong, I don't think I'll be able to get blocks working though.
I hope it's okay that I'm mirroring my posts back and forth between here and WAYWO. Here's my latest progress.
[QUOTE=amcfaggot;32939676]Thank God I just keep persisting with coding until I fix stuff, because I made the stupidest mistake with collision callbacks. Let's just put it at, they work now, and I'll leave you with this:
[media]http://www.youtube.com/watch?v=Q5b88BTzIvQ[/media]
Now all that needs fixing is ball velocity adjustment (I need to find a way for it to ignore gravity the best I can get it to) and the direction it moves after impact. Right now it uses the collision normal as it's new velocity on impact, which is not correct. I should be inverting the angle along 180 degrees, to get it to properly move in a consistent, realistic direction.[/QUOTE]
[QUOTE=slime73;32939029]In Lua, 0 is still considered 'true', e.g. "if 0 then foo end" will execute. You could make it return false if no collision while still returning numbers for the sides though.[/QUOTE]
Oh yeah, I forgot this was mainly Lua (I'm doing it in .NET), that's a relatively strange quirk though.
Edit: My idea wouldn't work well though, you need to separate checking the sides and the top, otherwise only one will win (so it won't detect corners, but that could be quite rare in game play)
Well this isn't really a breakout clone, it's more like lonely vertical pong.
[url]http://dl.dropbox.com/u/5324647/Lonely%20Pong.love[/url]
Also please don't kill my dropbox. :saddowns:
-snip- Fixed
Sorry, you need to Log In to post a reply to this thread.