Submit Your Own Code

PSP Lua CodeBase : Beginner AI: Move In A Circle

Description:
Make an object move in a circular motion using sine and cosine.

-- EVILMANA.COM PSP LUA CODEBASE
-- www.evilmana.com/tutorials/codebase
-- Beginner AI: Move In A Circle
-- SUBMITTED BY: Charlie

green = Color.new(0, 200, 0)
blockImage = Image.createEmpty(32,32)

blockImage:clear(green)

block = { x = 10, y = 100 }

radius = 100
speed = 5

xcenter = 240

ycenter = 135

degree = 0
radian = 0

while true do
screen:clear()

degree = degree + speed
      radian = (degree/180)*math.pi
      block.x = xcenter+math.cos(radian)*radius
      block.y = ycenter-math.sin(radian)*radius

screen:blit(block.x,block.y,blockImage)

screen.waitVblankStart()
screen.flip()
end

Back to CodeBase
 

Please welcome daryy, our newest member.

Who's Online: 3 Guests, 2 Users
PL3X, daryy

Total Members: 556
Total Posts: 13060
Total Topics: 1480
Total Categories: 8
Total Boards: 35

Recent Posts:

Re: Lua 5.1.4 help. by daryy
Re: PGELua Help - need term for a special rotation fix (mathematical issue) by yaustar
Re: Lua Loader? by Buddy4point0
Re: Lua Loader? by osgeld
Re: Lua Loader? by acer5050
Re: Lua Loader? by bumuckl
Re: Lua Loader? by acer5050
Re: Lua Loader? by bumuckl


Copyright © 2006-2007 www.EvilMana.com All rights reserved.
EvilMana Logo by emcp and Charlie