07 January 2023, 19:17 | #1 |
Registered User
Join Date: Feb 2021
Location: poland
Posts: 18
|
collision detection
hello, after a long and unwanted break, I returned to amos. With the help of books, I created something that works. title page, menu, level 1 art. I even transferred photos from pc to amiga . Unfortunately i have problem with 2 things:
1. i can't understand the collision system, i think something is wrong with bob and sprite numbers but i tried all ways and nothing. 2. as long as the background works fine, other objects like planes except bullets are flashing. The colours palette is the same in bobs and in background tiles. Can someone look at the code and correct it and explain to me what is wrong there. please |
08 January 2023, 00:29 | #2 |
Registered User
Join Date: Feb 2017
Location: Oslo
Posts: 90
|
Hi, I have some suspicions as to what the problems might be.
1. The Spritebob Col (and Bobsprite Col) command doesn't take Screen Offset into account, so to make it work you need to reposition the missile (to compensate the screen offset) before using Spritebob Col, and then move it back right after. (It is probably a good idea to turn off automatic sprite updates if you're doing this, using Sprite Update Off.) 2. Could it be that you're not in Double Buffer mode? |
08 January 2023, 14:19 | #3 |
Registered User
Join Date: Feb 2021
Location: poland
Posts: 18
|
I can't use double buffer because it breaks the scrolling of the screen. how to add screen offset to sprite bob col? sprite update off disables bullets.
|
08 January 2023, 14:53 | #4 |
Registered User
Join Date: Feb 2017
Location: Oslo
Posts: 90
|
Yes, with Sprite Update Off you need to use the command Sprite Update to show and move the sprites. To adjust for Screen Offset, I think you just add the screen offset coordinates, like
Code:
XOFFSET=SCRPOINTER+LICZNIK Sprite 0,X Sprite(0)+XOFFSET, Spritebob Col(0,0 To LICZBAOBCYCH-1) Sprite 0,X Sprite(0)-XOFFSET, |
12 January 2023, 19:58 | #5 |
Registered User
Join Date: Feb 2021
Location: poland
Posts: 18
|
another problem
hello, because i had a big problem with screen scrolling code replacement and with bobs (empty tiles sometimes, flashing bobs) i decided to use amos tome program and as usual almost everything works. works: scrolling, bullets, aliens, player-alien collisions, and bullet-player collisions. only bullet-alien collisions don't work. Please help as I still don't understand this system.
|
14 January 2023, 13:30 | #6 |
Registered User
Join Date: Feb 2017
Location: Oslo
Posts: 90
|
From the code it seems like you have used the same bob numbers both for bullets and enemies? I suppose what you want is to have Bob 0-1 for players, Bob 2-7 for bullets and Bob 8- for enemies.
|
16 January 2023, 11:05 | #7 |
Registered User
Join Date: Feb 2021
Location: poland
Posts: 18
|
I changed bob numbers:
1: player 4: alien 8: projectile and everything went to hell, even the shooting I don't understand it, I'm too stupid for that, I'm good at graphics but not at programming Dim EX(5),EY(5),EP(5),EH(5),ESX(5) Dim BX(5),BY(5) Global EX(),EY() Data 1,64,128,1,128 Load "ikonki.abk" Load "samoloty.abk" Reserve As Work 6,404 Bload "mapa.map",Start(6) Tile Size 32,32 Map View 0,0 To 256,288 Hide On No Icon Mask Auto View Off Screen Open 1,320,288,16,Lowres Curs Off : Flash Off : Cls 0 Wait Vbl Screen Hide 1 Screen Open 0,320,256,16,Lowres Curs Off : Flash Off : Cls 0 Get Icon Palette : Wait Vbl Double Buffer Screen To Front 0 Auto View On HYO=-1 MXY=Map Y*32 MY=MXY-256 SCR=1 X=128 : Y=128 : T=0 LIVES=3 Bob Update Off While LIVES>0 DEAD=0 X=128 : Y=128 : T=0 ENEMY=0 BL=0 While DEAD<4 HY=MY/32 Screen Copy 1,0,0,256,288 To 1,0,SCR If HYO<>HY : Gosub VERTMAP : End If Screen 0 Bob Clear Screen Copy 1,0,32,256,288 To Logic(0),0,0 HYO=HY Add MY,-SCR MY=(MY+MXY) mod MXY Bob 1,X,Y,1 NB=0 BADDIES If BL>0 Gosub BULLETS End If If NB<NBO For A=NB To NBO Bob Off A+2 Next A End If NBO=NB C=Bob Col(1,2 To NB+1) If C and DEAD=0 : DEAD=1 : Boom : End If Bob Draw Screen Swap Wait Vbl T=1-T X=Max(16,Min(240,X+(Jleft(1)-Jright(1))*8)) Y=Max(128,Min(240,Y+(Jup(1)-Jdown(1))*8)) If Fire(1) Gosub GUN End If Wend Wend End GUN: If BL<6 BX(BL)=X : BY(BL)=Y-8 Inc BL Shoot End If Return BULLETS: For A=0 To BL-1 If BX(A)>0 and BX(A)<256 and BY(A)>0 and BY(A)<256 Bob 8+NB,BX(A),BY(A),8 C=Bob Col(4+NB,3 To 8+NB) If C and ENEMY>0 For B=0 To ENEMY-1 If Col(B+2) EH(B)=1 Boom SCRE=SCRE+100 BX(A)=-1 : BY(A)=-1 : Bob Off 4+NB : B=999 End If Next B End If Inc NB BY(A)=BY(A)-16 Else BX(A)=0 End If Next A For A=BL-1 To 0 Step -1 If BX(A)=0 Swap BX(BL-1),BX(A) : Swap BY(BL-1),BY(A) Dec BL : BL=Max(0,BL) End If Next A Return Procedure BADDIES Bob 4+NB,EX(A),EY(A),4 Add EY(A),4 If EY(A)>300 EX(A)=Rnd(250)+30 EY(A)=30 End If End Proc VERTMAP: Screen 1 If HYO=-1 Map Do 0,HY Screen Copy 1,0,0,256,288 To 1,0,32-SCR Else Map Top 0,HY End If Return |
17 January 2023, 02:09 | #8 |
Registered User
Join Date: Feb 2017
Location: Oslo
Posts: 90
|
Well, I think you just need to work on your debugging skills. The most common way to figure out these things is not by thinking, most of the time you simply start a debugger from a suitable place in the code. In AMOS you can do this with the command Monitor. The debugger in AMOS works like most other debuggers: it allows you to execute one line of code at a time and look directly into the values held by your variables.
When learning how to use a new system, another thing to consider is creating smaller programs to test its features. In this case for instance, if you're uncertain about whether or not you've understood the bob system correctly, then writing a small program could help you figure that out. I'm unable to take in exactly what's going on in the code you posted, but I think the values you pass to Bob Col looks a bit odd. I challenge you to try the Monitor from the beginning of BULLETS: and see if you discover anything out of order. Last edited by adrazar; 17 January 2023 at 12:41. |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Collision detection | geldo79 | Coders. Asm / Hardware | 4 | 30 November 2020 13:17 |
Hardware collision detection | nandius_c | Coders. Asm / Hardware | 4 | 23 May 2020 05:32 |
Possible problem with Collision detection ! | amilo3438 | support.WinUAE | 5 | 11 January 2017 18:35 |
Collision Detection | sandruzzo | Coders. General | 5 | 10 June 2016 12:50 |
Collision detection: 2 doubts | nandius_c | Coders. Asm / Hardware | 6 | 30 November 2014 00:53 |
|
|