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

0 Members and 1 Guest are viewing this topic.

Offline animaaron

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 9
  • Rating: +0/-0
    • View Profile
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. :w00t:

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->X
40->Y

Repeat getKey(56)
For(B,0,7
For(A,0,11
{B*12+A+GBD1}->T
If T
T--
Pt-On(A*8,B*8,T*8+Pic0
End
End
End
Pt-On(X,Y,[7E81FFA57E5A7E42])
DispGraph
ClrDraw

If getKey(4)
!If sub(GT,X,Y-8)=2
Y-8->Y
Pause 500
End
End

If getKey(1)
!If sub(GT,X,Y+8)=2
Y+8->Y
Pause 500
End
End

If getKey(2)
!If sub(GT,X-8,Y)=2
X-8->X
Pause 500
End
End

If getKey(3)
!If sub(GT,X+8,Y)=2
X+8->X
Pause 500
End
End

End
Return

Lbl 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 »

Offline ben_g

  • Hey cool I can set a custom title now :)
  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +125/-4
  • Asm noob
    • View Profile
    • Our programmer's team: GameCommandoSquad
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

Offline pimathbrainiac

  • Occasionally I make projects
  • Members
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1731
  • Rating: +136/-23
  • dagaem
    • View Profile
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.

Offline animaaron

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 9
  • Rating: +0/-0
    • View Profile
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..

Offline animaaron

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 9
  • Rating: +0/-0
    • View Profile
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?

Offline ben_g

  • Hey cool I can set a custom title now :)
  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +125/-4
  • Asm noob
    • View Profile
    • Our programmer's team: GameCommandoSquad
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

Offline animaaron

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 9
  • Rating: +0/-0
    • View Profile
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 sprites
prgmGDB        //loads my GDBs (rn theres only 2)

GDB1->G

48->X
40->Y
32->S             //S and T are the variables that mark where you
32->T             //need to go for the next GDB

Repeat getKey(56)
...                   //Stuff to load the GDB
If getKey(4) and (sub(GT,X,Y-8)=0 or (sub(GT,X,Y-8)=7))
Y-8->Y
Pause 500
sub(LOC)
End

...                    //The rest of the keys

End
Return
prgmSUB          //Has all my routines
That'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}
Return

Lbl LOC
If X=S and Y=T
If G=GBD1
GBD2->G
80->S                  //These are just temporary numbers. I might change them later. I don't really
48->T                  //think it matters though
Pause 2000
End
Return
End

That's it... tell me what you find out

Offline ben_g

  • Hey cool I can set a custom title now :)
  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +125/-4
  • Asm noob
    • View Profile
    • Our programmer's team: GameCommandoSquad
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

Offline TheMachine02

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 452
  • Rating: +105/-0
  • me = EF99+F41A
    • View Profile
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