360 degree character rotation + movement

Started by Iphigenia, Mon 31/08/2009 10:38:27

Previous topic - Next topic

Iphigenia

I have a vehicle-like character that I'd like to be able to rotate left and right (with A and D keys) and move forward and back in direction of facing (with W and S keys).

Despite looking in confused awe at zabnat's Taxi demo source code:
http://www.adventuregamestudio.co.uk/yabb/index.php?topic=36546.0

spending several hours trying to adapt Ryan Timothy's Road Racer rotation code:
http://www.adventuregamestudio.co.uk/yabb/index.php?topic=38401.0

and searching in vain for KhrisMUC's Dynamic Rotation Module:
http://www.adventuregamestudio.co.uk/yabb/index.php?topic=33122.0

I don't seem to be able to achieve this end. Can anyone help me out with some guidance?

Thanks.

Khris

I have reuploaded the file, the download should work now.

Iphigenia

Thanks a lot Khris.

Still slightly confused, but I think I'm making progress.

I've used:

newsprite=DynS.CreateFromExistingSprite(1)

to create a dynamic sprite from my character sprite

and

newsprite=DynS.Rotate(newsprite, 5);

to rotate that sprite when the appropriate key is pressed.

What I can't seem to work out is how to draw the rotatable sprite in the appropriate place (ie - where my character is)

Khris

Here's a line from the example script:
  ds.DrawImage(100+dyn.XC(), 100+dyn.YC(), dyn.Graphic);
You'd use that to draw DynamicSprite dyn centered at 100;100.


Cpt Ezz

just a question......can you use your module to move the car forward as well as rotating it (accerating around a corner)?

Khris

The module makes it a lot easier to display rotated versions of existing sprites. That's it, unfortunately.

Cpt Ezz

Grrrrrrr!!!!!!!!!!!!!!!!!!! that is anoying is there a way to make it do it though?

Khris

Sure, script it.
I won't include unrelated code into a sprite rotation module.

Cpt Ezz

so all i really would need to script would be

newsprite=DynS.CreateFromExistingSprite(1) \\Gets sprite
newsprite=DynS.Rotate(newsprite, 5);
newsprite.move(x+5,y+5,.......);

Is that right or em i WAY off

Khris

The first two lines are the correct way to use my modules, yes.

As for the third, a DynamicSprite isn't a visible entity by itself; to display it you can attach it to a GUI, on object, a character or RawDraw it to the background. So you either have to move the GUI, object, character or RawDraw it to another position.


SMF spam blocked by CleanTalk