Collision + game crashing problem??

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
Eamonn
Party member
Posts: 550
Joined: Sat May 04, 2013 1:29 pm
Location: Ireland

Collision + game crashing problem??

Post by Eamonn »

I am working on a game called 'Mr. BallGuy', but I am having a lot of problems with it! There is a crash in it and for some reason the collision isn't working sometimes. Sometimes it's fine, and others the collision is way off. This is different from the collision problem I was having a few days ago. Then there is the crashing. I have absolutely no idea what is causing that. Now, the version that is linked here is an unreleased and semi-unfinished version of it. There are a few glitches that I'm working to iron out and some new features that are not in the forum thread one. Please please PLEASE don't re-share this or share it with anyone else. So anyway, if you know how to fix the crash in particular that would be greatly appreciated! The game is still far from done and the crash can be semi hard to reproduce, but if the music cuts out and the game is unresponsive that is the cause. I think it's because of a memory leak somewhere, but I could be wrong.

To re-create the crash, really all you have to do is play the game and sometimes you'll get a random crash. A lot of people have reported it and it is bugging me because I cannot seem to figure out what's causing it :(

And a small note: If you fix at least ONE of the glitches, you'll get your name in the credits, but it'll only be the first person :P

Any way, here is the download link: https://www.dropbox.com/s/fvdigctjhfsuk ... HOT-3.love

Thanks! Any help is appreciated!
Last edited by Eamonn on Tue May 28, 2013 9:34 pm, edited 1 time in total.
"In those quiet moments, you come into my mind" - Liam Reilly
User avatar
veethree
Inner party member
Posts: 877
Joined: Sat Dec 10, 2011 7:18 pm

Re: Collision + game crashing problem??

Post by veethree »

Perhaps you should mention what you do in game when the crash occurs.
User avatar
veethree
Inner party member
Posts: 877
Joined: Sat Dec 10, 2011 7:18 pm

Re: Collision + game crashing problem??

Post by veethree »

Few notes regarding the game, Perhaps they don't belong here but that's not really gonna stop me from posting them :)

1. The menu is a bit inconsistent. You can navigate with the mouse from the main menu, But in not any of the sub menus. On a related note, Some of the in game controls are a bit inconsistent as well. Such as you press tab to pause, But backspace to go back in game, I'd personally prefer to use the same key to pause and un-pause.

2. Jumping seems like a pretty useless mechanic for this game, Perhaps if you had different types of objects, and some land on the ground and you have to jump over them it'd make more sense to have that there.

3. Game play is a bit short. Perhaps make the objects increase speed a bit more gradually.

That's about it for the game aspect, Now I'll talk about the coding aspect.

1. Your collision issues are due to the random rotation. The object is drawn and rotated from the top left corner. And the collision doesn't take that into account.

2. Small thing, But the objects size is set to 50x50 in the code, While the sprite is 49x49. Tiny difference, But why not be accurate?

3. The player movement is a bit strange. The xVel value seems to never be used. In the player movement section you're updating the x position directly. But later in the code you update it according to xVel which is always 0.

I'd suggest, For the sake of consistency to change your movement code to something like this:

Code: Select all

if love.keyboard.isDown("left") or love.keyboard.isDown("a") then -- Checks if the user presses the left arrow key or a
			player.animL:update(dt) -- Updates the player's left sprite sheet
			player.xVel = -player.speed 
		elseif love.keyboard.isDown("right") or love.keyboard.isDown("d") then -- Checks if the user presses the right arrow key or d
			player.animR:update(dt) -- Updates the player's right sprite sheet
			player.xVel = player.speed 
		else
			player.xVel = 0
		end
This works exactly the same in game, But the code is more consistent.
User avatar
Eamonn
Party member
Posts: 550
Joined: Sat May 04, 2013 1:29 pm
Location: Ireland

Re: Collision + game crashing problem??

Post by Eamonn »

veethree wrote:Few notes regarding the game, Perhaps they don't belong here but that's not really gonna stop me from posting them :)

1. The menu is a bit inconsistent. You can navigate with the mouse from the main menu, But in not any of the sub menus. On a related note, Some of the in game controls are a bit inconsistent as well. Such as you press tab to pause, But backspace to go back in game, I'd personally prefer to use the same key to pause and un-pause.

2. Jumping seems like a pretty useless mechanic for this game, Perhaps if you had different types of objects, and some land on the ground and you have to jump over them it'd make more sense to have that there.

3. Game play is a bit short. Perhaps make the objects increase speed a bit more gradually.

That's about it for the game aspect, Now I'll talk about the coding aspect.

1. Your collision issues are due to the random rotation. The object is drawn and rotated from the top left corner. And the collision doesn't take that into account.

2. Small thing, But the objects size is set to 50x50 in the code, While the sprite is 49x49. Tiny difference, But why not be accurate?

3. The player movement is a bit strange. The xVel value seems to never be used. In the player movement section you're updating the x position directly. But later in the code you update it according to xVel which is always 0.

I'd suggest, For the sake of consistency to change your movement code to something like this:

Code: Select all

if love.keyboard.isDown("left") or love.keyboard.isDown("a") then -- Checks if the user presses the left arrow key or a
			player.animL:update(dt) -- Updates the player's left sprite sheet
			player.xVel = -player.speed 
		elseif love.keyboard.isDown("right") or love.keyboard.isDown("d") then -- Checks if the user presses the right arrow key or d
			player.animR:update(dt) -- Updates the player's right sprite sheet
			player.xVel = player.speed 
		else
			player.xVel = 0
		end
This works exactly the same in game, But the code is more consistent.
I did say in the thread the game is very early in development, but thanks for the tips. Also, is there an xVel? I didn't know :P I want to add a toggle button, and most of the buttons are temporary. A lot of the stuff will be changed. V2.0.0 is nowhere near done!! Thank's for the tips!

Also, the ball was 50X50, but I was fiddling with it earlier today and must have messed it up. So the only thing causing the problem was the rotation? Thank's for all your help VeeThree!
"In those quiet moments, you come into my mind" - Liam Reilly
User avatar
veethree
Inner party member
Posts: 877
Joined: Sat Dec 10, 2011 7:18 pm

Re: Collision + game crashing problem??

Post by veethree »

Eamonn wrote:
veethree wrote:Few notes regarding the game, Perhaps they don't belong here but that's not really gonna stop me from posting them :)

1. The menu is a bit inconsistent. You can navigate with the mouse from the main menu, But in not any of the sub menus. On a related note, Some of the in game controls are a bit inconsistent as well. Such as you press tab to pause, But backspace to go back in game, I'd personally prefer to use the same key to pause and un-pause.

2. Jumping seems like a pretty useless mechanic for this game, Perhaps if you had different types of objects, and some land on the ground and you have to jump over them it'd make more sense to have that there.

3. Game play is a bit short. Perhaps make the objects increase speed a bit more gradually.

That's about it for the game aspect, Now I'll talk about the coding aspect.

1. Your collision issues are due to the random rotation. The object is drawn and rotated from the top left corner. And the collision doesn't take that into account.

2. Small thing, But the objects size is set to 50x50 in the code, While the sprite is 49x49. Tiny difference, But why not be accurate?

3. The player movement is a bit strange. The xVel value seems to never be used. In the player movement section you're updating the x position directly. But later in the code you update it according to xVel which is always 0.

I'd suggest, For the sake of consistency to change your movement code to something like this:

Code: Select all

if love.keyboard.isDown("left") or love.keyboard.isDown("a") then -- Checks if the user presses the left arrow key or a
			player.animL:update(dt) -- Updates the player's left sprite sheet
			player.xVel = -player.speed 
		elseif love.keyboard.isDown("right") or love.keyboard.isDown("d") then -- Checks if the user presses the right arrow key or d
			player.animR:update(dt) -- Updates the player's right sprite sheet
			player.xVel = player.speed 
		else
			player.xVel = 0
		end
This works exactly the same in game, But the code is more consistent.
I did say in the thread the game is very early in development, but thanks for the tips. Also, is there an xVel? I didn't know :P I want to add a toggle button, and most of the buttons are temporary. A lot of the stuff will be changed. V2.0.0 is nowhere near done!! Thank's for the tips!

Also, the ball was 50X50, but I was fiddling with it earlier today and must have messed it up. So the only thing causing the problem was the rotation? Thank's for all your help VeeThree!
As far as i can tell, It was just the rotation. To solve that you can either simply disable the rotation, Or change the collision, I'd recommend Using circle collision instead of bounding box. For the player too. Wouldn't make a noticeable difference in this case. That way you can keep the random rotation, And have proper collision. There is a fantastic post on the love2d blog about circle collisions.
User avatar
the_leg
Prole
Posts: 25
Joined: Sun Sep 05, 2010 3:43 am

Re: Collision + game crashing problem??

Post by the_leg »

The crashing is related to audio and fixed in latest source code for love (issue #442). In the next release of love, you won't have this issue. I believe if you stop and start an audio source rapidly (like every dt) you'll encounter this problem more often.

I like your game.
User avatar
Eamonn
Party member
Posts: 550
Joined: Sat May 04, 2013 1:29 pm
Location: Ireland

Re: Collision + game crashing problem??

Post by Eamonn »

veethree wrote:
Eamonn wrote:
veethree wrote:Few notes regarding the game, Perhaps they don't belong here but that's not really gonna stop me from posting them :)

1. The menu is a bit inconsistent. You can navigate with the mouse from the main menu, But in not any of the sub menus. On a related note, Some of the in game controls are a bit inconsistent as well. Such as you press tab to pause, But backspace to go back in game, I'd personally prefer to use the same key to pause and un-pause.

2. Jumping seems like a pretty useless mechanic for this game, Perhaps if you had different types of objects, and some land on the ground and you have to jump over them it'd make more sense to have that there.

3. Game play is a bit short. Perhaps make the objects increase speed a bit more gradually.

That's about it for the game aspect, Now I'll talk about the coding aspect.

1. Your collision issues are due to the random rotation. The object is drawn and rotated from the top left corner. And the collision doesn't take that into account.

2. Small thing, But the objects size is set to 50x50 in the code, While the sprite is 49x49. Tiny difference, But why not be accurate?

3. The player movement is a bit strange. The xVel value seems to never be used. In the player movement section you're updating the x position directly. But later in the code you update it according to xVel which is always 0.

I'd suggest, For the sake of consistency to change your movement code to something like this:

Code: Select all

if love.keyboard.isDown("left") or love.keyboard.isDown("a") then -- Checks if the user presses the left arrow key or a
			player.animL:update(dt) -- Updates the player's left sprite sheet
			player.xVel = -player.speed 
		elseif love.keyboard.isDown("right") or love.keyboard.isDown("d") then -- Checks if the user presses the right arrow key or d
			player.animR:update(dt) -- Updates the player's right sprite sheet
			player.xVel = player.speed 
		else
			player.xVel = 0
		end
This works exactly the same in game, But the code is more consistent.
I did say in the thread the game is very early in development, but thanks for the tips. Also, is there an xVel? I didn't know :P I want to add a toggle button, and most of the buttons are temporary. A lot of the stuff will be changed. V2.0.0 is nowhere near done!! Thank's for the tips!

Also, the ball was 50X50, but I was fiddling with it earlier today and must have messed it up. So the only thing causing the problem was the rotation? Thank's for all your help VeeThree!
As far as i can tell, It was just the rotation. To solve that you can either simply disable the rotation, Or change the collision, I'd recommend Using circle collision instead of bounding box. For the player too. Wouldn't make a noticeable difference in this case. That way you can keep the random rotation, And have proper collision. There is a fantastic post on the love2d blog about circle collisions.
I feel like such an idiot now, since there were so many things I should fix :P Thanks for the circle collision! I didn't know how to do it and asked before with no real help. This is my first game, so I'd expected to have a little bit of inefficient code. Veethree, if you still read this thread I want you to know you are awesome!!!!!!!!!!!!
the_leg wrote:The crashing is related to audio and fixed in latest source code for love (issue #442). In the next release of love, you won't have this issue. I believe if you stop and start an audio source rapidly (like every dt) you'll encounter this problem more often.

I like your game.
I thought it had something to do with the audio!! The audio was kind of stuttering, so that's what I thought was causing it but I didn't think it was likely. So it's nothing to do with my game's code and just a bug on LÖVE?



Everyone that has helped me here, I thank you a thousand times over! As a first time game developer(and a 13-year-old one at that :P ), I need all the help I can get :)
"In those quiet moments, you come into my mind" - Liam Reilly
Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests