turret cod 8 directions

Talk about making games.

turret cod 8 directions

Postby jimmynewguy » Sat Nov 29, 2008 7:55 pm

Can some one give me a script to make this turret face the player? Thanks :D
Attachments
turret.PNG
turret.PNG (1.6 KiB) Viewed 687 times
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score

Re: turret cod 8 directions

Postby Killagram » Sat Nov 29, 2008 8:49 pm

Draw Actor>

Code: Select all
angle=direction(x, y, player.x, player.y);
animpos=round(angle/(360/nframes));


8 frames = 360/8 = 45 so

Code: Select all
animpos=round(angle/45);


It won't work with that image though; the order of the frames is wrong.

Animation must start with facing right (0 animpos, 0 degrees) and then rotate counterclockwise.

Here is a fixed version. Have fun!
Attachments
turretfixed.png
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it."
-Brian W. Kernighan
User avatar
Killagram
 
Posts: 31
Joined: Sun Aug 10, 2008 8:49 pm
Score: 5 Give a positive score

Re: turret cod 8 directions

Postby jimmynewguy » Sun Nov 30, 2008 1:51 am

thank you so much 8)
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score

Re: turret cod 8 directions

Postby savvy » Thu Jun 04, 2009 11:59 am

cool turrets, but add more info, on the coding!
--> For my help, i ask for a simple +1 if it helps! ^-^
--> I dont code, I type art which you dont understand.
--> I keep winning the 3D model challenge at college, teacher says: "you keep winning im not giving you prizes".
User avatar
savvy
 
Posts: 494
Joined: Wed Jun 03, 2009 11:55 am
Location: England
Score: 44 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest

cron