BlitzCoder Essentials
•
Home Page
•
About BlitzCoder
•
Contributors
•
Terms of Use
•
Email Us
Main Areas
•
BlitzCoder Chat
•
Discussions
•
Articles/Tutorials
•
Code Database
•
Link Database
•
Showcase Area
•
Worklogs
•
Competitions
Special Areas
•
Undocumented
Other Blitz Sites
•
Blitz Basic Home
•
Blitz Showcase
•
BlitzPlay Library
Forum Login
Username:
Password:
•
Register Now!
BlitzCoder Code Archives Page
Main Codes Page
"Simple Sin/Cos movement"
, by xiyo
This is just a simple "car-like" movement code. I have seen that it has been requested many times in the forums so..
Code
Graphics 1024, 768 SetBuffer BackBuffer() degree# = 45 speed# = 0 While Not KeyHit(1) Cls y# = y# + speed*Sin(degree) ; The Sin movement x# = x# + speed*Cos(degree) ; The Cos movement If KeyDown(200) ; Move speed = 5 Else speed = 0 EndIf If KeyDown(205) Then ; Turn left degree = degree +5 EndIf If KeyDown(203) Then ; Turn right degree = degree -5 EndIf Line x,y,x +50*Sin(degree+90),y -50*Cos(degree+90) ; Draw the line and make it face forward Flip Wend End
Copyright(c) 2000-2004, BlitzCoder. All Rights Reserved.
Code software created by Krylar's Kreations