DSLua Community
Welcome, Guest. Please login or register.
May 21, 2012, 09:07:04 PM
1371 Posts in 262 Topics by 33109 Members
Latest Member: Limewire Download
DSLua Community  |  General DS Programming Chats  |  Code Hashing  |  Help with moving a sprite « previous next »
Pages: [1]
Author Topic: Help with moving a sprite  (Read 1629 times)
Alexand3rS
New Moon
*
Posts: 3


« on: October 27, 2007, 03:37:43 PM »

Hi I am new to DSlua and I was wondering how to move a sprite (character picture) with the D pad around the screen...  Huh
Logged
sylus101
Waxing Crescent
**
Posts: 68



« Reply #1 on: November 25, 2007, 01:05:33 AM »

There's going to be a lot of possibilities here... but for a simple example, you could just do a check if a Pad direction is held, then move the sprite by incrementing a variable that represents it's x or y position and move the sprite to the new position.

There's some stuff on this in the tutorials for sure. Without any of the other setup of loading the sprite into memory or anything, this would move a sprite Right 1 pixel every VBlank, or 60 pixels per second. I'm sure you could figure out the other directions.

x = 50
y = 96

while 1 == 1 do

if Pads.Right() then
x = x + 1
sprite.MoveTo(x,y)
end

DSLuaWaitForVBlank()

end
« Last Edit: November 25, 2007, 01:14:29 AM by sylus101 » Logged
Pages: [1]
« previous next »
    Jump to: