Tuesday, 02 December 2008
 
  Home arrow Forum  
Main Menu
Home
News
Forum
Documentation
Download
Links
Administrator
Login Form
Welcome, Guest. Please login or register.
December 02, 2008, 09:19:38 AM
Username: Password:
Login with username, password and session length

Forgot your password?
Help with moving a sprite
DSLua Community
Welcome, Guest. Please login or register.
December 02, 2008, 09:19:38 AM
1723 Posts in 315 Topics by 6338 Members
Latest Member: Driennaunmand
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 796 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: 74



« 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:  



    (C) 2008 DSLua

    DSLua - Best scripting language for Nintendo DS home-brew!