Author Topic: tanks and AI  (Read 5715 times)

0 Members and 1 Guest are viewing this topic.

Offline stevon8ter

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 663
  • Rating: +10/-0
    • View Profile
Re: Re: tanks and AI
« Reply #15 on: July 26, 2012, 08:32:19 pm »
DOUBLE EDIT: what should i do for collision detection? is there a better method than progressional pixel testing?
I use a hackish radial-distance method for collisions in Embers - I pretend every enemy and item exists within a diamond given by distance=distancex+distancey, which is basically a optimal corruption of pythagorean distance=root(dx^2+dy^2). It's not as graphically perfect as using pixel masks but it sure is a hell of a lot faster.

Ok, in basic if i want to do that, i just do:

:root(abs(A-X)^2 + abs(B-Y)^2 -> C
:if C=1 or C=root(2
:then
:commands
:end

Where A and B are the coordinates of the (point or object) thats it collided with
And X and Y are the 'players' coordinates
Checking for root(2 is for diagonal collision and checkig the 1 is for checking for horizontal or vertical collision

This methode is just for 1 pixel colliding with 1 pixel, so much more checks would be nescessary for larger objects, i know this is an axe-topic but maybe you now have a simple idea of pythagoras?

Edit: this was meant for shmibs, not for squidget, the quote was just to tell that squidget is right about this being a good way

Edit2: ps: correct me if i'm wrong ;)
None of my posts are meant offending... I you feel hurt by one of my posts, tell me ... So i can appoligise me and/or explain why i posted it


Hi there, I'm the allmighty (read as: stupid, weak...) STEVON8TER

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: tanks and AI
« Reply #16 on: July 26, 2012, 09:00:08 pm »
Wow seems pretty fun. You should at least add dying and make it some sort of survival game. :D

Offline Hayleia

  • Programming Absol
  • Coder Of Tomorrow
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3367
  • Rating: +393/-7
    • View Profile
Re: tanks and AI
« Reply #17 on: July 27, 2012, 01:33:27 am »
Ok, in basic if i want to do that, i just do:

:root(abs(A-X)^2 + abs(B-Y)^2 -> C
:if C=1 or C=root(2
:then
:commands
:end
I don't get the utility of the "abs()" right before the "^2" ;)
Also, we are here talking about Axe, not basic. So root(2) is equal to 1, which means that the second line has something redundant and that all your method loses precision. Instead of working with the distance, what you can do is working with the square of the distance, that you compare to 1 and to 2
I own: 83+ ; 84+SE ; 76.fr ; CX CAS ; Prizm ; 84+CSE
Sorry if I answer with something that seems unrelated, English is not my primary language and I might not have understood well. Sorry if I make English mistakes too.

click here to know where you got your last +1s

Offline stevon8ter

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 663
  • Rating: +10/-0
    • View Profile
Re: tanks and AI
« Reply #18 on: July 27, 2012, 03:32:28 am »
Ok, in basic if i want to do that, i just do:

:root(abs(A-X)^2 + abs(B-Y)^2 -> C
:if C=1 or C=root(2
:then
:commands
:end
I don't get the utility of the "abs()" right before the "^2" ;)
Also, we are here talking about Axe, not basic. So root(2) is equal to 1, which means that the second line has something redundant and that all your method loses precision. Instead of working with the distance, what you can do is working with the square of the distance, that you compare to 1 and to 2

Like i said, i don't know much about axe

And indeed, that abs( thing was stupid of me that i didn't saw that
None of my posts are meant offending... I you feel hurt by one of my posts, tell me ... So i can appoligise me and/or explain why i posted it


Hi there, I'm the allmighty (read as: stupid, weak...) STEVON8TER