-- PLAYER default player with 4-way sliding movement. -- Basic four directional movement for top-down view using SlideObject. -- Usage: Attach this behavior to individual player objects to provide a basic top down movement via sliding based on move_speed. -- -- Created by: Thor Alexander -- Created on: 11/28/2007 -- Version 1.1 -- -- Version History: -- 1.1 11/28 Initial release. (TA) -- 1.2 2/28/08 Update for self changes. (JW) --- constants --- properties Define Properties() -- Parameters move_speed = 1.0 ExposeProperty( 'move_speed', 'Movement rate in tiles/second.') SetPropRange( 'move_speed', 0, 10 ) end --- commands Define Commands() MakeInput("Press 'LEFT' to start moving left.", 'left', 'down', 'none', 'move left') MakeInput("Press 'RIGHT' to start moving left.", 'right', 'down', 'none', 'move right') MakeInput("Press 'UP' to start moving up.", 'up', 'down', 'none', 'move up') MakeInput("Press 'DOWN' to start moving up.", 'down', 'down', 'none', 'move down') MakeCommand('move', 'Move', 'dir:string') end Command move(dir) local xMove = 0 local yMove = 0 if dir == 'left' then xMove = -1 elseif dir == 'right' then xMove = 1 elseif dir == 'up' then yMove = -1 elseif dir == 'down' then yMove = 1 end SlideObject(self, xMove, yMove, 0, 1000/self.move_speed, 0) end -- triggers