Game Programming and Development Tools

Averaging Movement – Mene-Mene

Mene-Mene

Member

Posts: 1398
From: Fort Wayne, IN, USA
Registered: 10-23-2006
I'm attempting a game inwhich I'll choose the strategy, and AI of the opponents, then they'll fight each other. I'm not sure though how to average movement.

I know that 45 means exactly half-way between right, and up so:

Ex.

facing = 45

speed = 4

If facing = 45 then

Movementspeed = speed / 2

px = px + movementspeed
py = py + movementspeed

endif

------------------
MM out-
Thought travels much faster than sound, it is better to think something twice, and say it once, than to think something once, and have to say it twice.
"Frogs and Fauns! The tournament!" - Professor Winneynoodle/HanClinto

Realm Master

Member

Posts: 1971
From: USA
Registered: 05-15-2005
Well, its been a year since i leared this but...

can't you use Cos and Sin(e)?

Its really vague in my mind but it goes something like tihs

direction = 45

speed = 4

vecx = Cos(direction) * speed

vecy = Sin(direction) * speed

px = px + vecx
py = py + vecy

althought x might need SIn and y might need Cos... i dunno, i've forgotten.

------------------
yeah, im a little crazy
Check out my crazy sig that I made:

Mene-Mene

Member

Posts: 1398
From: Fort Wayne, IN, USA
Registered: 10-23-2006
RM: Thank you, You're so great and Powerful... I didn't know that they could be used for that, I don't really have a good understanding of what they do, just that they can do what I want them to do in "" instances. I'll be able to take it from here.

------------------
MM out-
Thought travels much faster than sound, it is better to think something twice, and say it once, than to think something once, and have to say it twice.
"Frogs and Fauns! The tournament!" - Professor Winneynoodle/HanClinto

Lava
Member

Posts: 1905
From:
Registered: 01-26-2005
quote:
Originally posted by Mene-Mene:
RM: Thank you, You're so great and Powerful...


LOL!

------------------

Mene-Mene

Member

Posts: 1398
From: Fort Wayne, IN, USA
Registered: 10-23-2006
Lava: I said that because he's always rolling about how inexperienced he is, and how I've got less than he does.

------------------
MM out-
Thought travels much faster than sound, it is better to think something twice, and say it once, than to think something once, and have to say it twice.
"Frogs and Fauns! The tournament!" - Professor Winneynoodle/HanClinto

Lava
Member

Posts: 1905
From:
Registered: 01-26-2005
Haha, I know, there was nothing wrong with what you said, I just thought it was hilarious

------------------

Realm Master

Member

Posts: 1971
From: USA
Registered: 05-15-2005
*WARNING: THAT COMMENT MAY CAUSE EGO INFLATION*

lol.

------------------
yeah, im a little crazy
Check out my crazy sig that I made:

Mene-Mene

Member

Posts: 1398
From: Fort Wayne, IN, USA
Registered: 10-23-2006
RM: Yay! I think this might be how it goes.


Function Move(facing,thing,speed,direction)

If direction = 1 Then ;Left

movex = Cos(facing - 90) * speed
movey = Sin(facing - 90) * speed

ElseIf direction = 2 Then ;Up

movex = Cos(facing) * speed
movey = Sin(facing) * speed

ElseIf direction = 3 Then ;Right

movex = Cos(facing + 90) * speed
movey = Sin(facing + 90) * speed

ElseIf direction = 4 Then ;Back

movex = Cos(facing + 180) * speed
movey = Sin(facing + 180) * speed

EndIf

If thing = "Player" Then

Player\x = Player\x + movex
Player\y = Player\y + movey

ElseIf thing = "Enemy" Then

Enemy\x = Enemy\x + movex
Enemy\y = Enemy\y + movey

EndIf

End Function

------------------
MM out-
Thought travels much faster than sound, it is better to think something twice, and say it once, than to think something once, and have to say it twice.
"Frogs and Fauns! The tournament!" - Professor Winneynoodle/HanClinto

[This message has been edited by Mene-Mene (edited December 02, 2006).]

Mene-Mene

Member

Posts: 1398
From: Fort Wayne, IN, USA
Registered: 10-23-2006
Oops, just remembered Sin, and CoSine are calculated facing the east.

------------------
MM out-
Thought travels much faster than sound, it is better to think something twice, and say it once, than to think something once, and have to say it twice.
"Frogs and Fauns! The tournament!" - Professor Winneynoodle/HanClinto

Lazarus

Member

Posts: 1668
From: USA
Registered: 06-06-2006
I could recommend something for memory loss - just bought my M.D degree online.
Mene-Mene

Member

Posts: 1398
From: Fort Wayne, IN, USA
Registered: 10-23-2006
I don't get you.

------------------
MM out-
Thought travels much faster than sound, it is better to think something twice, and say it once, than to think something once, and have to say it twice.
"Frogs and Fauns! The tournament!" - Professor Winneynoodle/HanClinto

Lazarus

Member

Posts: 1668
From: USA
Registered: 06-06-2006
There's this scandal about how you can actually buy fake college degrees over the Internet - like there was a cat that had a degree in dentistry and a cow that had a degree in being a veterinarian.

Mene-Mene

Member

Posts: 1398
From: Fort Wayne, IN, USA
Registered: 10-23-2006
Oh...

------------------
MM out-
Thought travels much faster than sound, it is better to think something twice, and say it once, than to think something once, and have to say it twice.
"Frogs and Fauns! The tournament!" - Professor Winneynoodle/HanClinto