Search the Community
Showing results for tags 'collision detection'.
-
I am trying to do infinite scrolling in text mode. The idea is that screen is larger (twice) MAXWIDTH = 96 This is my DLI definition: dl_start dta DL_BLANK8 + DL_DLI dta DL_MODE_40x24T2 + DL_HSCROLL + DL_LMS, a(SCREEN_GAME) dta DL_MODE_40x24T2 + DL_HSCROLL + DL_LMS, a(SCREEN_GAME + (MAXWIDTH * 1)) dta DL_MODE_40x24T2 + DL_HSCROLL + DL_LMS, a(SCREEN_GAME + (MAXWIDTH * 2)) dta DL_MODE_40x24T2 + DL_HSCROLL + DL_LMS, a(SCREEN_GAME + (MAXWIDTH * 3)) dta DL_MODE_40x24T2 + DL_HSCROLL + DL_LMS, a(SCREEN_GAME + (MAXWIDTH * 4)) dta DL_MODE_40x24T2 + DL_HSCROLL + DL_LMS, a(SCREEN_GAME + (MAXWIDTH * 5)) dta DL_MODE_40x24T2 + DL_HSCROLL + DL_LMS, a(SCREEN_GAME + (MAXWIDTH * 6)) dta DL_MODE_40x24T2 + DL_HSCROLL + DL_LMS, a(SCREEN_GAME + (MAXWIDTH * 7)) dta DL_MODE_40x24T2 + DL_HSCROLL + DL_LMS, a(SCREEN_GAME + (MAXWIDTH * 8)) dta DL_MODE_40x24T2 + DL_HSCROLL + DL_LMS, a(SCREEN_GAME + (MAXWIDTH * 9)) dta DL_MODE_40x24T2 + DL_HSCROLL + DL_LMS, a(SCREEN_GAME + (MAXWIDTH * 10)) dta DL_MODE_40x24T2 + DL_HSCROLL + DL_LMS, a(SCREEN_GAME + (MAXWIDTH * 11)) dta DL_MODE_40x24T2 + DL_HSCROLL + DL_LMS, a(SCREEN_GAME + (MAXWIDTH * 12)) dta DL_MODE_40x24T2 + DL_HSCROLL + DL_LMS, a(SCREEN_GAME + (MAXWIDTH * 13)) dta DL_MODE_40x24T2 + DL_HSCROLL + DL_LMS, a(SCREEN_GAME + (MAXWIDTH * 14)) dta DL_MODE_40x24T2 + DL_HSCROLL + DL_LMS, a(SCREEN_GAME + (MAXWIDTH * 15)) dta DL_MODE_40x24T2 + DL_HSCROLL + DL_LMS, a(SCREEN_GAME + (MAXWIDTH * 16)) dta DL_MODE_40x24T2 + DL_HSCROLL + DL_LMS, a(SCREEN_GAME + (MAXWIDTH * 17)) dta DL_MODE_40x24T2 + DL_HSCROLL + DL_LMS, a(SCREEN_GAME + (MAXWIDTH * 18)) dta DL_MODE_40x24T2 + DL_HSCROLL + DL_LMS, a(SCREEN_GAME + (MAXWIDTH * 19)) dta DL_MODE_40x24T2 + DL_HSCROLL + DL_LMS, a(SCREEN_GAME + (MAXWIDTH * 20)) dta DL_BLANK8 dta DL_BLANK8 + DL_DLI dta DL_MODE_40x24T2 + DL_LMS, a(SCREEN_BOTTOM) dta DL_JVB, a(dl_start) If I want to put character in visible part of the screen (while I am not scrolling the screen) I am having trouble. I have determined that I can put character within X position between 4 and 43. That leads to the problem to write a procedure to calculate sprite collision. cx:=43; cy:=20; addresscalc:=SCREEN_GAME + row_max[cy] + cx; // addresscalc:=SCREEN_GAME + cy * 96 + cx; Poke(addresscalc, SWARN); SWARN is a const for character #. As you can see cx=43 draws almost to the right. There is 1 character to the right, same situation is on left when I draw at cx=4. That is problematic when I try to understand and modify playfield after sprite and playfield collision. The question is how should I organize screen and calculate position from pixels to character position in playfield? I was trying to calculate cx and cy with cx:= ((missle_x - 48) div 4); cy:= ((missle_y - 48 ) div 4);
-
Anyone here who knows if any given range of collision/interaction of sprites are assigned specifically to each frame, or whether it follows box-detection, pixel-detection…? Would changing one frame (with different looks of sprite-grfx) for another, impact collision, or would it just detect and underlying program that says this or that frame has no more, no less than this or that range of collision/intersction…?
- 24 replies
-
- sprite collision
- collision detection
-
(and 1 more)
Tagged with:
-
It would be really nice to know if the detection between sprites in games (we could also discuss interaction with backdrops), are dependent on 1) Spriteblock coming into contact with other SpriteBlock (entire square 16x16, 32x32 etc), or 2) whether it is the drawn pixels within the sprites that makes for ‘crash-detection’/interaction-detection or 3) whether it is the programming behind that matters. - - - I’m primarily concerned with 2D games, not 3D games (driving/fligth). But any input is welcome. Thanks in advance for any info, input, experience.
-
- collision detection
- sprites
-
(and 3 more)
Tagged with:
-
Ok since I've been letting yet another side project rot away for too long and I really don't know if/when I'll get back to it, here's another little demo as I fiddle with scrolling. In a nutshell the program uses plotmapfile to display full screens in 160A and the player can move about in 4 directions, going 1 full tile at a time. When you reach the edge of the screen that is connected to a different map, it will scroll that map in black and white to the new screen then flash the color back. There are only two screens in this program. The screen you start in, and the screen to the left of it. Any other screen edges you can reach are "dead" and won't trigger a change. There's a "template" tmx file included that's got the embedded tiles, etc all set up for adding new screens for playing around with. Additionally this demo includes collision detection between the player and the map tiles. Changing around the order of tiles in the tmx files would obviously mess around with the collision code so keep that in mind. Compiling instructions in a command/dos window are listed in the bank0c.bas file. As mentioned in that file feel free to use anything in the code in your own projects. And yes, I suck at drawing hero sprites. rpg7800.zip rpg.bas.a78 rpg.bas.bin rpg7800-fixed.zip
- 18 replies
-
- 10
-
- scrolling
- collision detection
-
(and 1 more)
Tagged with:
-
I got this to work, and wanted to share as I could find no information searching. RT has added a clearer example to his batari Basic site: http://www.randomterrain.com/atari-2600-memories-batari-basic-commands.html#ex_dpc_shooting_nusiz Also there is a powerful "trick" that lets you cover all (or as many) virtual sprites as you want with the same code block. First you check for missile0 Player1 collision. Skip the routine if no collision. Second, find which virtual sprite was hit, set trick value, go to find out which copy, and rearrange. For triple copy, medium, there are 7 routines. For double copy, medium, there are 2 routines. Keeping track of the remaining routines are the variables enemyP2 thru enemyP8. To explain double copy: Player2 starts out with 2 copies, enemyP2 is 2. If you hit the left one, the on-goto will take the far right branch. (the first branch if enemyP2 is 0, the 2nd branch if enemyP2 is 1, the third branch I'd enemyP2 is 2) As the left sprite was hit, change to one copy NUSIZ2=0, move the single sprite over to where the copy was, set enemyP2 to 1. When next Player2 is hit, move it off screen, set enemyP2 to 0. Triple copy has more rearranging. Shooting the left enemy of 3 copies first, change to double copies, medium, move right to where copy 2 was, set enemyP3 to 3 which will next take "which 2 on the right" has been hit. Shooting the center enemy of 3 copies, change to double copies wide. enemyP3=5, that branch being "which 2 of wide" has been hit. Shooting the right enemy of 3 copies, change to double copies, medium. enemyP3=6. "which 2 on the left" So what is left over after a hit on one of 3 copies determines which branch will be taken for the 2 remaining copies to become 1 copy. Now to explain the "trick". Why is everything in the routine enemyP2 and player2 and NUSIZ2? The value in the brackets points to them sequentially. player2[0] is player2 player2[1] is player3 player2[2] is player4 etc. It works for NUSIZ2[0] thru NUSIZ2[6] (and NUSIZ2[7] if you need to set NUSIZ9) and because I set enemyP2 through enemyP8 as variables: a, b, c, d, e, f, g it works there also. Sometimes I have seen some collisions detected, the missile resets, the explosion sound is played, but the player doesn't get removed. I think my +values are correct, but possibly they are not. Maybe every once in a while it just fails a check? dim enemyP2=a dim enemyP3=b dim enemyP4=c dim enemyP5=d dim enemyP6=e dim enemyP7=f dim enemyP8=g ; Note: Above must be sequential for "trick" dim trick=t NUSIZ2=$02: NUSIZ4=$02: NUSIZ6=$02: NUSIZ8=$02: enemyP8=2: enemyP6=2: enemyP4=2: enemyP2=2 NUSIZ3=$06: NUSIZ5=$06: NUSIZ7=$06 enemyP7=7: enemyP5=7: enemyP3=7 DF6FRACINC=255: DF4FRACINC=255: DF0FRACINC=255: DF1FRACINC=255: DF2FRACINC=255: DF3FRACINC=255 ; Backgrnd colors.; PF colors.; Column 0. ; Column 1. ; Column 2. ; Column 3. drawscreen ;******************************************************************************************************************************************** ; ; missile0 collision check. ; ;``````````````````````````````````````````````````````````````` ; Checks for missile0 collision with other 8 sprites, reflected. ; As above, outside game loop, NUSIZx x=2 thru 8 ; Sprites 2, 4, 6, 8 are double, medium. ; Sprites 3, 5, 7 are triple, medium. ; if !collision(missile0,player1) then goto __Skip_m0_Collision if (missile0y+4)>=player2y && missile0y<=(player2y+4) && missile0x >=player2x && missile0x <= (player2x+64) then trick=0: goto whichCopy2 if (missile0y+4)>=player3y && missile0y<=(player3y+4) && missile0x >=player3x && missile0x <= (player3x+72) then trick=1: goto whichCopy1 if (missile0y+4)>=player4y && missile0y<=(player4y+4) && missile0x >=player4x && missile0x <= (player4x+64) then trick=2: goto whichCopy2 if (missile0y+4)>=player5y && missile0y<=(player5y+4) && missile0x >=player5x && missile0x <= (player5x+72) then trick=3: goto whichCopy1 if (missile0y+4)>=player6y && missile0y<=(player6y+4) && missile0x >=player6x && missile0x <= (player6x+64) then trick=4: goto whichCopy2 if (missile0y+4)>=player7y && missile0y<=(player7y+4) && missile0x >=player7x && missile0x <= (player7x+72) then trick=5: goto whichCopy1 if (missile0y+4)>=player8y && missile0y<=(player8y+4) && missile0x >=player8x && missile0x <= (player8x+64) then trick=6: goto whichCopy2 goto __Skip_m0_Collision whichCopy1 temp2=enemyP2[trick] on temp2 goto __Skip_m0_Collision which7w1 which7w1 which7w2l which7w1 which7w2w which7w2l which7w3 which7w3 if missile0x <= player2x[trick]+8 then NUSIZ2[trick]=$02: player2x[trick]=player2x[trick]+32: enemyP2[trick]=3: goto resetMissile0 if missile0x >= player2x[trick]+32 && missile0x <= player2x[trick]+40 then NUSIZ2[trick]=$04: enemyP2[trick]=5: goto resetMissile0 if missile0x >= player2x[trick]+64 && missile0x <= player2x[trick]+72 then NUSIZ2[trick]=$02: enemyP2[trick]=3: goto resetMissile0 which7w1 if missile0x <= player2x[trick]+8 then player2y[trick]=200: enemyP2[trick]=0: goto resetMissile0 which7w2w if missile0x <= player2x[trick]+8 then player2x[trick]=player2x[trick]+64: goto whichCopyEnd if missile0x >= player2x[trick]+64 && missile0x <= player2x[trick]+72 then whichCopyEnd which7w2l if missile0x <= player2x[trick]+8 then player2x[trick]=player2x[trick]+32: goto whichCopyEnd if missile0x >= player2x[trick]+32 && missile0x <= player2x[trick]+40 then whichCopyEnd whichCopyEnd NUSIZ2[trick]=$00: enemyP2[trick]=1: goto resetMissile0 whichCopy2 temp1=enemyP2[trick] on temp1 goto resetMissile0 which7w1 which7w2l dim enemyP2=a dim enemyP3=b dim enemyP4=c dim enemyP5=d dim enemyP6=e dim enemyP7=f dim enemyP8=g ; Note: Above must be sequential for "trick" dim trick=t NUSIZ2=$02: NUSIZ4=$02: NUSIZ6=$02: NUSIZ8=$02: enemyP8=2: enemyP6=2: enemyP4=2: enemyP2=2 NUSIZ3=$06: NUSIZ5=$06: NUSIZ7=$06 enemyP7=7: enemyP5=7: enemyP3=7 DF6FRACINC=255: DF4FRACINC=255: DF0FRACINC=255: DF1FRACINC=255: DF2FRACINC=255: DF3FRACINC=255 ; Backgrnd colors.; PF colors.; Column 0. ; Column 1. ; Column 2. ; Column 3. drawscreen ;******************************************************************************************************************************************** ; ; missile0 collision check. ; ;``````````````````````````````````````````````````````````````` ; Checks for missile0 collision with other 8 sprites, reflected. ; As above, outside game loop, NUSIZx x=2 thru 8 ; Sprites 2, 4, 6, 8 are double, medium. ; Sprites 3, 5, 7 are triple, medium. ; if !collision(missile0,player1) then goto __Skip_m0_Collision if (missile0y+4)>=player2y && missile0y<=(player2y+4) && missile0x >=player2x && missile0x <= (player2x+64) then trick=0: goto whichCopy2 if (missile0y+4)>=player3y && missile0y<=(player3y+4) && missile0x >=player3x && missile0x <= (player3x+72) then trick=1: goto whichCopy1 if (missile0y+4)>=player4y && missile0y<=(player4y+4) && missile0x >=player4x && missile0x <= (player4x+64) then trick=2: goto whichCopy2 if (missile0y+4)>=player5y && missile0y<=(player5y+4) && missile0x >=player5x && missile0x <= (player5x+72) then trick=3: goto whichCopy1 if (missile0y+4)>=player6y && missile0y<=(player6y+4) && missile0x >=player6x && missile0x <= (player6x+64) then trick=4: goto whichCopy2 if (missile0y+4)>=player7y && missile0y<=(player7y+4) && missile0x >=player7x && missile0x <= (player7x+72) then trick=5: goto whichCopy1 if (missile0y+4)>=player8y && missile0y<=(player8y+4) && missile0x >=player8x && missile0x <= (player8x+64) then trick=6: goto whichCopy2 goto __Skip_m0_Collision whichCopy1 temp2=enemyP2[trick] on temp2 goto __Skip_m0_Collision which7w1 which7w1 which7w2r which7w1 which7w2w which7w2l which7w3 which7w3 if missile0x <= player2x[trick]+8 then NUSIZ2[trick]=$02: player2x[trick]=player2x[trick]+32: enemyP2[trick]=3 if missile0x >= player2x[trick]+32 && missile0x <= player2x[trick]+40 then NUSIZ2[trick]=$04: enemyP2[trick]=5 if missile0x >= player2x[trick]+64 && missile0x <= player2x[trick]+72 then NUSIZ2[trick]=$02: enemyP2[trick]=6 goto resetMissile0 which7w2r if missile0x <= player2x[trick]+8 then NUSIZ2[trick]=$00: player2x[trick]=player2x[trick]+32: enemyP2[trick]=1 if missile0x >= player2x[trick]+32 && missile0x <= player2x[trick]+40 then NUSIZ2[trick]=$00: enemyP2[trick]=2 goto resetMissile0 which7w1 if missile0x <= player2x[trick]+8 then player2y[trick]=200: enemyP2[trick]=0 goto resetMissile0 which7w2w if missile0x <= player2x[trick]+8 then NUSIZ2[trick]=$00: player2x[trick]=player2x[trick]+64: enemyP2[trick]=1 if missile0x >= player2x[trick]+64 && missile0x <= player2x[trick]+72 then NUSIZ2[trick]=$00: enemyP2[trick]=4 goto resetMissile0 which7w2l if missile0x <= player2x[trick]+8 then NUSIZ2[trick]=$00: player2x[trick]=player2x[trick]+32: enemyP2[trick]=2 if missile0x >= player2x[trick]+32 && missile0x <= player2x[trick]+40 then NUSIZ2[trick]=$00: enemyP2[trick]=4 goto resetMissile0 whichCopy2 temp1=enemyP2[trick] on temp1 goto resetMissile0 which2w1 which2w2 which2w2 if missile0x <= player2x[trick]+8 then player2x[trick]=player2x[trick]+32: enemyP2[trick]=1: NUSIZ2[trick]=$00: goto resetMissile0 if missile0x >= player2x[trick]+32 && missile0x <= player2x[trick]+40 then enemyP2[trick]=1: NUSIZ2[trick]=$00 goto resetMissile0 which2w1 if missile0x < player2x[trick]+8 then player2y[trick]=200: enemyP2[trick]=0 goto resetMissile0
-
Hey all. First post, first game, first question. I'd like to make a simple two-player fighting game. I have 2 player sprites controllable on screen, a background, and now I just need to define some things such as the edges of the screen where the players bump into, bumping into eachother, and add a missile-based punch function, and collision between those missiles and the two players. attached is my (likely rough) code, everything working up to the point where I need to add the things described. As far as work flow goes, I've gotten to the point where I need to figure out and add collision detection, and I haven't yet begun exploring the missile system, but help with both would be very valuable to me. So far I've seen lots of complicated examples of collision detection, where the playing field wasn't a solid block that the players appear in front of (like my game), and included X and Y axis movement. I only require X axis movement, so I only require X axis collision detection, and between a total of 4 (or 6, including the edges of the screen) objects. I feel as though I understand what needs to be coded, but I'm not sure how to do it without making things far more complicated than I perceive that they need to be. in psuedo code: if collision(player0, player1) then player0 can't move right and player1 can't move left if collision(player0, left edge of screen) then player0 can't move left if collision(player1, right edge of screen) then player1 can't move right I think I read under random terrain's tutorial stuff that only standard objects like player1, missile0, etc are valid arguments in the collision/!collision statements. how do I work around this? I'd be really stoked to find out that the required work is easy, but if it required defining several constants or dimensions and includes checks and calls in the main loop.. can someone help spell it out for me? I really appreciate any help on this one. Lincoln Fight.bas
- 14 replies
-
- atari 2600
- visual bb
-
(and 3 more)
Tagged with: