? Glitchy Collision Detection. HELP!!! (Page 1) ● SmileBASIC Source Forums

Sign In

Register
*Usernames are case-sensitive
Forgot my password

Glitchy Collision Detection. HELP!!!

  • #1 ✎ 219 the_squat1115 Minecraft Is Awesome! I love Minecraft! Express Yourself Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Video Games I like to play video games! Hobbies Well, I'm working on a new platformer game called Kuni's Adventure, but... I had finally made a sample of collision detection, and... Yep, it's very, very glitchy. Some screenshots... SCREENSHOTS: (And I use the 3DS browser sometimes...) NOTE: I have solved this on my own. But if you want to help, go to here. Posted Edited by the_squat1115
  • #2 ✎ 72 GamerCymreig Beginner Programmer I'm just starting out! I'm still trying to grasp the basics. Programming Strength Video Games I like to play video games! Hobbies Pokemon Is Awesome! I love Pokemon! Express Yourself Okay, let's start with this: SPOFS X,y X=NUMBER Y=NUMBER This is probably what needs to be done first, it'll make things easier, each level can have a different location by just inserting what X & Y equals. As for collision, don't use: IF Y>145 THEN Y=145 Use the SPHITSP command for the tiles and your player sprite. IF SPHITSP PLAYER,BLOCK THEN... Posted
  • #3 ✎ 219 the_squat1115 Minecraft Is Awesome! I love Minecraft! Express Yourself Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Video Games I like to play video games! Hobbies
    Okay, let's start with this: SPOFS X,y X=NUMBER Y=NUMBER This is probably what needs to be done first, it'll make things easier, each level can have a different location by just inserting what X & Y equals. As for collision, don't use: IF Y>145 THEN Y=145 Use the SPHITSP command for the tiles and your player sprite. IF SPHITSP PLAYER,BLOCK THEN...
    Ok, I'll try it soon. Thanks Cymreig. EDIT: And what are you trying to mean about Player, Block Then?
    Posted Edited by the_squat1115
  • #4 ✎ 72 GamerCymreig Beginner Programmer I'm just starting out! I'm still trying to grasp the basics. Programming Strength Video Games I like to play video games! Hobbies Pokemon Is Awesome! I love Pokemon! Express Yourself I don't know about jumping though, check a platformer on here. Posted
  • #5 ✎ 219 the_squat1115 Minecraft Is Awesome! I love Minecraft! Express Yourself Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Video Games I like to play video games! Hobbies
    I don't know about jumping though, check a platformer on here.
    Ok, then.
    Posted
  • #6 ✎ 184 seggiepants If you think of Super Mario Bros. on the old NES, you will notice that the world is made out of blocks on a regular grid (like graph paper). Or as they say in programmer/math circles Axis Aligned rectangles. So, instead of checking if you are past a certain y coordinate, it would be better if you could instead have a big rectangle for the floor or other obstacles and a rectangle for your hero character and check if the rectangles overlap. If they do, you have a collision and should bump the player back until they don't collide anymore. Rectangles can be said to not collide if for two rectangles A, and B, the left side of rectangle A is past the right side of rectangle B, or the bottom of Rectangle A is above the top of rectangle B, or if the top of rectangle A is below the bottom of rectangle B or if the right side of Rectangle A is before the left side of Rectangle B. If all of the not intersecting tests fail then they are colliding/intersecting. See: https://stackoverflow.com/questions/13390333/two-rectangles-intersection/44120056#44120056 You can get some help from smileBasic since background tiles and sprites are largely 16x16 pixels (there is a way to query Sprite size and location too). The background tiles are on a regular grid so you only need to check for tiles your player can actually touch say a 3x3ish grid starting at floor(player x / 16), floor(player y / 16) converting the players top left to tile coordinates and going to the tile coordinates matching their bottom right. Also only checking if a given tile is one you consider a solid block. That way you can design a level with data instead of hard coding boundaries. Hopefully that helps Posted
  • #7 ✎ 219 the_squat1115 Minecraft Is Awesome! I love Minecraft! Express Yourself Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Video Games I like to play video games! Hobbies
    If you think of Super Mario Bros. on the old NES, you will notice that the world is made out of blocks on a regular grid (like graph paper). Or as they say in programmer/math circles Axis Aligned rectangles. So, instead of checking if you are past a certain y coordinate, it would be better if you could instead have a big rectangle for the floor or other obstacles and a rectangle for your hero character and check if the rectangles overlap. If they do, you have a collision and should bump the player back until they don't collide anymore. Rectangles can be said to not collide if for two rectangles A, and B, the left side of rectangle A is past the right side of rectangle B, or the bottom of Rectangle A is above the top of rectangle B, or if the top of rectangle A is below the bottom of rectangle B or if the right side of Rectangle A is before the left side of Rectangle B. If all of the not intersecting tests fail then they are colliding/intersecting. See: https://stackoverflow.com/questions/13390333/two-rectangles-intersection/44120056#44120056 You can get some help from smileBasic since background tiles and sprites are largely 16x16 pixels (there is a way to query Sprite size and location too). The background tiles are on a regular grid so you only need to check for tiles your player can actually touch say a 3x3ish grid starting at floor(player x / 16), floor(player y / 16) converting the players top left to tile coordinates and going to the tile coordinates matching their bottom right. Also only checking if a given tile is one you consider a solid block. That way you can design a level with data instead of hard coding boundaries. Hopefully that helps
    ...Still I can't understand...
    Posted
  • #8 ✎ 72 GamerCymreig Beginner Programmer I'm just starting out! I'm still trying to grasp the basics. Programming Strength Video Games I like to play video games! Hobbies Pokemon Is Awesome! I love Pokemon! Express Yourself
    Okay, let's start with this: SPOFS X,y X=NUMBER Y=NUMBER This is probably what needs to be done first, it'll make things easier, each level can have a different location by just inserting what X & Y equals. As for collision, don't use: IF Y>145 THEN Y=145 Use the SPHITSP command for the tiles and your player sprite. IF SPHITSP PLAYER,BLOCK THEN...
    Ok, I'll try it soon. Thanks Cymreig. EDIT: And what are you trying to mean about Player, Block Then?
    If the sprites (tile and Player) collide, then make some code to keep the player on top the block.
    Posted
  • #9 ✎ 937 random_god Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength QSP Contest 1 Contest Participant I participated in the first SmileBASIC Source QSP Contest! Video Games I like to play video games! Hobbies
    If you think of Super Mario Bros. on the old NES, you will notice that the world is made out of blocks on a regular grid (like graph paper). Or as they say in programmer/math circles Axis Aligned rectangles. So, instead of checking if you are past a certain y coordinate, it would be better if you could instead have a big rectangle for the floor or other obstacles and a rectangle for your hero character and check if the rectangles overlap. If they do, you have a collision and should bump the player back until they don't collide anymore. Rectangles can be said to not collide if for two rectangles A, and B, the left side of rectangle A is past the right side of rectangle B, or the bottom of Rectangle A is above the top of rectangle B, or if the top of rectangle A is below the bottom of rectangle B or if the right side of Rectangle A is before the left side of Rectangle B. If all of the not intersecting tests fail then they are colliding/intersecting. See: https://stackoverflow.com/questions/13390333/two-rectangles-intersection/44120056#44120056 You can get some help from smileBasic since background tiles and sprites are largely 16x16 pixels (there is a way to query Sprite size and location too). The background tiles are on a regular grid so you only need to check for tiles your player can actually touch say a 3x3ish grid starting at floor(player x / 16), floor(player y / 16) converting the players top left to tile coordinates and going to the tile coordinates matching their bottom right. Also only checking if a given tile is one you consider a solid block. That way you can design a level with data instead of hard coding boundaries. Hopefully that helps
    ...Still I can't understand...
    Basically use data like map arrays and the DATA command/stored DAT files you make to make maps and collision, instead of putting in coordinates you can't go to. It's much easier and WAY less tedious. Trust me, I made the mistake of doing that and it didn't go well...
    Posted
  • #10 ✎ 184 seggiepants Maybe I need to do that platformer tutorial after all. Would it be better if I did it in SmileBasic for 3DS or Switch? Posted
  • #11 ✎ 937 random_god Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength QSP Contest 1 Contest Participant I participated in the first SmileBASIC Source QSP Contest! Video Games I like to play video games! Hobbies
    Maybe I need to do that platformer tutorial after all. Would it be better if I did it in SmileBasic for 3DS or Switch?
    I would say 3ds just because I have no Switch :( Or maybe both if you can? But idk...
    Posted
  • #12 ✎ 25 S_DE_Solutions Avatar Block I didn't change my avatar for 30 days. Website Zelda Is Awesome! I love The Legend Of Zelda! Express Yourself
    Maybe I need to do that platformer tutorial after all. Would it be better if I did it in SmileBasic for 3DS or Switch?
    I think 3DS is the better choise. (Until to the relase of the Switch-Version in other Countrys. ; Btw. the EU-3DS version was only released after 2.5 years after the japan release.)
    Posted
  • #13 ✎ 219 the_squat1115 Minecraft Is Awesome! I love Minecraft! Express Yourself Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Video Games I like to play video games! Hobbies
    Maybe I need to do that platformer tutorial after all. Would it be better if I did it in SmileBasic for 3DS or Switch?
    I think 3DS is the better choise. (Until to the relase of the Switch-Version in other Countrys. ; Btw. the EU-3DS version was only released after 2.5 years after the japan release.)
    Off topic...
    Posted
  • #14 ✎ 937 random_god Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength QSP Contest 1 Contest Participant I participated in the first SmileBASIC Source QSP Contest! Video Games I like to play video games! Hobbies
    Maybe I need to do that platformer tutorial after all. Would it be better if I did it in SmileBasic for 3DS or Switch?
    I think 3DS is the better choise. (Until to the relase of the Switch-Version in other Countrys. ; Btw. the EU-3DS version was only released after 2.5 years after the japan release.)
    Off topic...
    no not off topic. It is connected to the topic because he is talking about a platformer tutorial seggiepants might make, which you might need as a solution or just a resource in general.
    Posted
  • #15 ✎ 219 the_squat1115 Minecraft Is Awesome! I love Minecraft! Express Yourself Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Video Games I like to play video games! Hobbies
    Maybe I need to do that platformer tutorial after all. Would it be better if I did it in SmileBasic for 3DS or Switch?
    I think 3DS is the better choise. (Until to the relase of the Switch-Version in other Countrys. ; Btw. the EU-3DS version was only released after 2.5 years after the japan release.)
    Off topic...
    no not off topic. It is connected to the topic because he is talking about a platformer tutorial seggiepants might make, which you might need as a solution or just a resource in general.
    Oh, then I should try to use off topic WHEN off topic themes are incoming.
    Posted