Thursday, 08 January 2009
 
  Home arrow Forum  
Main Menu
Home
News
Forum
Documentation
Download
Links
Administrator
Login Form
Welcome, Guest. Please login or register.
January 08, 2009, 02:56:22 PM
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.
January 08, 2009, 02:56:22 PM
1724 Posts in 316 Topics by 10304 Members
Latest Member: Optopsity
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 879 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) 2009 DSLua

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