### Author Topic: HELP- Problems with Collision Detection  (Read 4716 times)

0 Members and 1 Guest are viewing this topic.

#### animaaron

• LV1 Newcomer (Next: 20)
• Posts: 9
• Rating: +0/-0
##### HELP- Problems with Collision Detection
« on: April 25, 2015, 05:47:04 pm »
I'm having trouble with the collision detecting in a simple map I made using a tut I found on the forum.. I don't know whats wrong, cant find a problem anywhere.

Here's the code, if you can help me.

Code: [Select]
.TILENOSC[AA4400552200AA44]->Pic0[FFFFFFFFFFFFFFFFFF][020202020202010202020202]->GBD1[020000000000000000000002][020000000000000000000002][020000000000000000000002][020000000000000000000002][020000000000000000000002][020000000000000000000002][020202020202010202020202]48->X40->YRepeat getKey(56)For(B,0,7For(A,0,11{B*12+A+GBD1}->TIf TT--Pt-On(A*8,B*8,T*8+Pic0EndEndEndPt-On(X,Y,[7E81FFA57E5A7E42])DispGraphClrDrawIf getKey(4)!If sub(GT,X,Y-8)=2Y-8->YPause 500EndEndIf getKey(1)!If sub(GT,X,Y+8)=2Y+8->YPause 500EndEndIf getKey(2)!If sub(GT,X-8,Y)=2X-8->XPause 500EndEndIf getKey(3)!If sub(GT,X+8,Y)=2X+8->XPause 500EndEndEndReturnLbl GT{r[sub]2[/sub]/8+12+(r[sub]1[/sub]/8)+GBD1}Return
There it is. Please, if you find something wrong, tell me so I can make this work
« Last Edit: April 25, 2015, 08:49:22 pm by Runer112 »

#### ben_g

• Hey cool I can set a custom title now :)
• LV9 Veteran (Next: 1337)
• Posts: 1002
• Rating: +125/-4
• Asm noob
##### Re: HELP- Problems with Collision Detection
« Reply #1 on: April 25, 2015, 06:23:13 pm »
I think you made a mistake here:
Code: [Select]
{r2/8+12+(r1/8)+GBD1}I think that should be:
Code: [Select]
{r2/8*12+(r1/8)+GBD1}(* instead of +)

EDIT: I just noticed that you move your player 8 pixels (or 1 tile) at a time. If you plan on doing that in the final version of your game, then I'd reccomend using tile coordinates instead of pixel coordinates. Now, the X and Y are the location at which the sprite should be drawn, and you have to multiply/divide with 8 troughout your whole program, but if you set the X and Y to the tile the player is on, then you'd only have to multiply by 8 when you draw the sprite.

This could save you a few bytes and a few cycles, and it makes everything a little bit clearer, though you won't be able to place your player halfway on a tile.
« Last Edit: April 25, 2015, 06:29:55 pm by ben_g »
My projects
- The Lost Survivors (Unreal Engine) ACTIVE [GameCommandoSquad main project]
- Oxo, with single-calc multiplayer and AI (axe) RELEASED (screenshot) (topic)
- An android version of oxo (java)  ACTIVE
- A 3D collision detection library (axe) RELEASED! (topic)(screenshot)(more recent screenshot)(screenshot of it being used in a tilemapper)
Spoiler For inactive:
- A first person shooter with a polygon-based 3d engine. (z80, will probably be recoded in axe using GLib) ON HOLD (screenshot)
- A java MORPG. (pc) DEEP COMA(read more)(screenshot)
- a minecraft game in axe DEAD (source code available)
- a 3D racing game (axe) ON HOLD (outdated screenshot of asm version)

This signature was last updated on 20/04/2015 and may be outdated

#### pimathbrainiac

• Occasionally I make projects
• Members
• LV10 31337 u53r (Next: 2000)
• Posts: 1731
• Rating: +136/-23
• dagaem
##### Re: HELP- Problems with Collision Detection
« Reply #2 on: April 25, 2015, 06:33:39 pm »
Just for future reference, please use the [code] bbcode to surround code. It puts it in monospaced font and it's easier organization-wise.
I am Bach.

#### animaaron

• LV1 Newcomer (Next: 20)
• Posts: 9
• Rating: +0/-0
##### Re: HELP- Problems with Collision Detection
« Reply #3 on: April 25, 2015, 07:46:54 pm »
@ben_g THANK YOU SO MUCH!!! Ugh stupid little mistakes... its always just one little stupid mistake..

#### animaaron

• LV1 Newcomer (Next: 20)
• Posts: 9
• Rating: +0/-0
##### Re: HELP- Problems with Collision Detection
« Reply #4 on: April 26, 2015, 02:31:10 pm »
How would I make it so I can switch between GDBs when my character is at a certain spot, to enter a new area?

#### ben_g

• Hey cool I can set a custom title now :)
• LV9 Veteran (Next: 1337)
• Posts: 1002
• Rating: +125/-4
• Asm noob
##### Re: HELP- Problems with Collision Detection
« Reply #5 on: April 26, 2015, 03:23:17 pm »
Simple: instead of using GBD's, you use a normal variable, for example L. Then, at the start, you just to GBD1->L, and then when switching levels, you simply store the next gdb in the variable (for example GDB3->L)
My projects
- The Lost Survivors (Unreal Engine) ACTIVE [GameCommandoSquad main project]
- Oxo, with single-calc multiplayer and AI (axe) RELEASED (screenshot) (topic)
- An android version of oxo (java)  ACTIVE
- A 3D collision detection library (axe) RELEASED! (topic)(screenshot)(more recent screenshot)(screenshot of it being used in a tilemapper)
Spoiler For inactive:
- A first person shooter with a polygon-based 3d engine. (z80, will probably be recoded in axe using GLib) ON HOLD (screenshot)
- A java MORPG. (pc) DEEP COMA(read more)(screenshot)
- a minecraft game in axe DEAD (source code available)
- a 3D racing game (axe) ON HOLD (outdated screenshot of asm version)

This signature was last updated on 20/04/2015 and may be outdated

#### animaaron

• LV1 Newcomer (Next: 20)
• Posts: 9
• Rating: +0/-0
##### Re: HELP- Problems with Collision Detection
« Reply #6 on: April 26, 2015, 07:49:03 pm »
I'm still having problems...
Code: [Select]
prgmASSETS   //loads all my spritesprgmGDB        //loads my GDBs (rn theres only 2)GDB1->G48->X40->Y32->S             //S and T are the variables that mark where you32->T             //need to go for the next GDBRepeat getKey(56)...                   //Stuff to load the GDBIf getKey(4) and (sub(GT,X,Y-8)=0 or (sub(GT,X,Y-8)=7))Y-8->YPause 500sub(LOC)End...                    //The rest of the keysEndReturnprgmSUB          //Has all my routinesThat's my main program, and there might already be problems, idk. Here's my routine prgm

Code: [Select]
Lbl GT{r[sub]2[/sub]/8*12+(r[sub]1[/sub]/8)+G}ReturnLbl LOCIf X=S and Y=TIf G=GBD1GBD2->G80->S                  //These are just temporary numbers. I might change them later. I don't really48->T                  //think it matters thoughPause 2000EndReturnEnd
That's it... tell me what you find out

#### ben_g

• Hey cool I can set a custom title now :)
• LV9 Veteran (Next: 1337)
• Posts: 1002
• Rating: +125/-4
• Asm noob
##### Re: HELP- Problems with Collision Detection
« Reply #7 on: April 27, 2015, 01:14:48 pm »
What's the problem you're having? It's hard to look for problems when you don't know what's happening.
My projects
- The Lost Survivors (Unreal Engine) ACTIVE [GameCommandoSquad main project]
- Oxo, with single-calc multiplayer and AI (axe) RELEASED (screenshot) (topic)
- An android version of oxo (java)  ACTIVE
- A 3D collision detection library (axe) RELEASED! (topic)(screenshot)(more recent screenshot)(screenshot of it being used in a tilemapper)
Spoiler For inactive:
- A first person shooter with a polygon-based 3d engine. (z80, will probably be recoded in axe using GLib) ON HOLD (screenshot)
- A java MORPG. (pc) DEEP COMA(read more)(screenshot)
- a minecraft game in axe DEAD (source code available)
- a 3D racing game (axe) ON HOLD (outdated screenshot of asm version)

This signature was last updated on 20/04/2015 and may be outdated

#### TheMachine02

• LV6 Super Member (Next: 500)
• Posts: 452
• Rating: +105/-0
• me = EF99+F41A
##### Re: HELP- Problems with Collision Detection
« Reply #8 on: April 28, 2015, 06:32:28 am »
It does seems taht there is an error in operation orders at this line :
Code: [Select]
If X=S and Y=TAxe doesn't have opertaion orders and operate from left to right without care to 'actual' rules. I guess you want more to put this:
Code: [Select]
If X=S and (Y=T)(note parenthesis to restore correct order)
AXE/asm programmer - unleash the power of z80 //C++//C

epic 3D things http://www.ntu.edu.sg/home/ehchua/programming/opengl/CG_BasicsTheory.html