JC Software Posted January 20, 2018 Share Posted January 20, 2018 (edited) For the new Max Maze game, I'm using Random Terrain's "ex_sprite_ball_missile_collision_prevention.bas" example to add the perfect collision. (It is a maze game after all)However there are two things I need to ask you guys...1. Could someone explain this part in detail, perhaps understanding it better can help with fixing bugs and glitches for my games using this code in the future.(The example below is from Random Terrain's example, not my game) temp5 = (player0x-10)/4 temp6 = (player0y-9)/8 if temp5 < 34 then if pfread(temp5,temp6) then goto __Skip_Joy0_Up temp4 = (player0x-17)/4 if temp4 < 34 then if pfread(temp4,temp6) then goto __Skip_Joy0_Up temp3 = temp5 - 1 if temp3 < 34 then if pfread(temp3,temp6) then goto __Skip_Joy0_Up 2. As I've said my newest game is using the above code for collision, however unlike Random Terrain's 8x8 sprite in the example, this sprite is 3x6Because of this sudden sprite size change, the game is going crazy, going left and up seems to be fine, but going right and down at the same time is awful. You can barley move around since the walls feel like they have the force pushing you away from them. Any help would be appreciated, Thanks(When playing 2018_01_19_2349, make sure to press the fire button when you see a blank red screen to start the actual game) 2018_01_19_2349.bas Edited January 20, 2018 by Lolkiu64 Quote Link to comment Share on other sites More sharing options...
+Lewis2907 Posted January 20, 2018 Share Posted January 20, 2018 This may help. It helped me some with collision. http://atariage.com/forums/topic/129542-collision-at-a-specific-point-solved-for-real-this-time/ I will take a look at your code, I'm not the best but I will give it a try this weekend, thanks. 1 Quote Link to comment Share on other sites More sharing options...
bogax Posted January 20, 2018 Share Posted January 20, 2018 this lets you step player0 around the screen while displaying player0x in the left three score digits and player0y in the right three score digits the sprite changes color when there's a collision with the playfield bear in mind that the sprites are drawn upside down so this 3x6 sprite is in the lower left corner of an 8x8 sprite definition sprite_position.bas sprite_position.bas.bin 1 Quote Link to comment Share on other sites More sharing options...
bogax Posted January 21, 2018 Share Posted January 21, 2018 here I've inserted different collision code and changed the height of player0 the code is basically similar it tests two corners of the player0 for each direction to see if there's a playfield pixel in the way so for example if you're moving right it tests the top right corner of player0 against the bottom left of the PFpixel and the bottom right of player0 against the top left of the PFpixel Max_Maze_mod_01.bas Max_Maze_mod_01.bas.bin Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted January 21, 2018 Share Posted January 21, 2018 here I've inserted different collision code and changed the height of player0 the code is basically similar it tests two corners of the player0 for each direction to see if there's a playfield pixel in the way so for example if you're moving right it tests the top right corner of player0 against the bottom left of the PFpixel and the bottom right of player0 against the top left of the PFpixel I'll be gone for a day or two (more packing and moving), but when I get back, if your code uses less space or cycles or both, I'll update the examples on the bB page. 1 Quote Link to comment Share on other sites More sharing options...
JC Software Posted January 21, 2018 Author Share Posted January 21, 2018 @Lewis2907: Thanks, even though the topic looks pretty long, I'll give it a shot.@bogax: Wow, I forgot about the sprites being drawn upside down, I guess that shows how new I am at this, but I'll soon get to your level I'm sure. I'll be sure to check out sprite_postion.bas and of course the Max's Maze Mod. Speaking of this mod, I'm planning on making a whole series of Max's Maze games, each one helps me learn something new in bB, for example the first game is collision, the second will introduce sounds, animations, and so on. Would you mind if I added your mod into the list of Max's Maze games? (Just as a mini example, and of course I'll give you credit)@Randon Terrain: I know you weren't replying to me but, good luck moving 1 Quote Link to comment Share on other sites More sharing options...
JC Software Posted January 21, 2018 Author Share Posted January 21, 2018 Just tried out bogax's example, it's awesome, Thanks for your help. 1 Quote Link to comment Share on other sites More sharing options...
+Lewis2907 Posted January 22, 2018 Share Posted January 22, 2018 (edited) Lolkiu64, Thanks to Bogax code I was able to adjust some of my stuff. I did add the feature of speed control (based upon RT's Code) if that helps. That way your sprite speed is adjustable. ;*************************************************************** ; ; Don't move right if pfpixel is in the way. ; if joy0right then _P0_L_R = _P0_L_R + .5 : then left temp3 = (player0x - 14)/4 : temp4 = (player0y - 6)/8 if pfread(temp3, temp4) then _P0_L_R = _P0_L_R - .5 : then down temp3 = (player0x - 14)/4 : temp4 = (player0y - 1)/8 if pfread(temp3, temp4) then _P0_L_R = _P0_L_R - .5 : then down (Just adjust all the .5 to what ever you need. 1.5; 1.8; .9 etc.) I did try to add another section, but got an error to detect the middle of the sprite. My thought there was if you can detect the middle of the sprite. Why not code it for the entire sprite. I know it will eat up space but then I think you have 100% collision. What I tried and it didn't compile. temp4 = (player0y - 3)/8 should detect the middle of the sprite, i think. ;*************************************************************** ; ; Don't move right if pfpixel is in the way. ; if joy0right then _P0_L_R = _P0_L_R + .5 : then left temp3 = (player0x - 14)/4 : temp4 = (player0y - 6)/8 if pfread(temp3, temp4) then _P0_L_R = _P0_L_R - .5 : then down temp3 = (player0x - 14)/4 : temp4 = (player0y - 3)/8 if pfread(temp3, temp4) then _P0_L_R = _P0_L_R - .5 : then down temp3 = (player0x - 14)/4 : temp4 = (player0y - 1)/8 if pfread(temp3, temp4) then _P0_L_R = _P0_L_R - .5 : then down I am working on the Multisprite version which is attached. Hopefully Bogax or someone can adjust the code around to work. The left and right detection works. I'm having trouble with the up and down portions. The issue I see even in the above program is that they both use only one pixel for detection which is great, but at times the sprite will cut corners and not have the 100% true detection. This is still better that the bouncy detection that I first learned how to use. Hope these help in your game development, thanks. Max_Maze_mod_02.bas.bin 20180121 - Max_Maze_mod_02.txt MultiSprite_pfread.bas.bin 20180121 -Multisprite Collision Detection.txt Edited January 22, 2018 by Lewis2907 1 Quote Link to comment Share on other sites More sharing options...
Coolcrab Posted January 22, 2018 Share Posted January 22, 2018 This seems very relevant to my problem, so please allow me to highjack the thread a little bit. I got my game to work using similar conversions but the collision only seems to registers if the player moves into the wall and not if the wall scrolls into the player. Is this a known problem? And is there any way around it? 1 Quote Link to comment Share on other sites More sharing options...
bogax Posted January 22, 2018 Share Posted January 22, 2018 (edited) Lolkiu64, Thanks to Bogax code I was able to adjust some of my stuff. I did add the feature of speed control (based upon RT's Code) if that helps. That way your sprite speed is adjustable. ;*************************************************************** ; ; Don't move right if pfpixel is in the way. ; if joy0right then _P0_L_R = _P0_L_R + .5 : then left temp3 = (player0x - 14)/4 : temp4 = (player0y - 6)/8 if pfread(temp3, temp4) then _P0_L_R = _P0_L_R - .5 : then down temp3 = (player0x - 14)/4 : temp4 = (player0y - 1)/8 if pfread(temp3, temp4) then _P0_L_R = _P0_L_R - .5 : then down (Just adjust all the .5 to what ever you need. 1.5; 1.8; .9 etc.) I did try to add another section, but got an error to detect the middle of the sprite. My thought there was if you can detect the middle of the sprite. Why not code it for the entire sprite. I know it will eat up space but then I think you have 100% collision. What I tried and it didn't compile. temp4 = (player0y - 3)/8 should detect the middle of the sprite, i think. ;*************************************************************** ; ; Don't move right if pfpixel is in the way. ; if joy0right then _P0_L_R = _P0_L_R + .5 : then left temp3 = (player0x - 14)/4 : temp4 = (player0y - 6)/8 if pfread(temp3, temp4) then _P0_L_R = _P0_L_R - .5 : then down temp3 = (player0x - 14)/4 : temp4 = (player0y - 3)/8 if pfread(temp3, temp4) then _P0_L_R = _P0_L_R - .5 : then down temp3 = (player0x - 14)/4 : temp4 = (player0y - 1)/8 if pfread(temp3, temp4) then _P0_L_R = _P0_L_R - .5 : then down I am working on the Multisprite version which is attached. Hopefully Bogax or someone can adjust the code around to work. The left and right detection works. I'm having trouble with the up and down portions. The issue I see even in the above program is that they both use only one pixel for detection which is great, but at times the sprite will cut corners and not have the 100% true detection. This is still better that the bouncy detection that I first learned how to use. Hope these help in your game development, thanks. you could have a look at this collision_prevention_13.bas collision_prevention_13.bas.bin Edited January 22, 2018 by bogax 1 Quote Link to comment Share on other sites More sharing options...
JC Software Posted January 23, 2018 Author Share Posted January 23, 2018 @Coolcrab feel free to highjack any topic I start@Bogax Thanks to you, I finished my Max's Maze Deluxe game, also I'll be sure to try out collision_prevention_13.bas(P.S. I'm giving you special credit) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.