DSLua Community
Welcome,
Guest
. Please
login
or
register
.
May 21, 2012, 08:40:20 PM
1371
Posts in
262
Topics by
33109
Members
Latest Member:
Limewire Download
Home
Help
Search
Login
Register
DSLua Community
|
DSLua - Best scripting language for Nintendo DS
|
Need Help?
|
Need Help with my code... :(
« previous
next »
Pages:
[
1
]
Print
Author
Topic: Need Help with my code... :( (Read 1270 times)
LeightonW87
Waxing Crescent
Posts: 17
Need Help with my code... :(
«
on:
July 10, 2007, 07:57:02 AM »
I'm currently trying to make a remake of some thing I done on the PC but I keep getting errors all the time. could someone take a look at the code for me and tell me whats wrong here.
I also have trouble reading the font it gives when there are errors. It's very difficult making it out sometimes.
Code:
SCREEN_BOTTOM = 0 -- This inits the DS's bottom screen
PAL_PLAYR = 0 -- This is going to make it easier to load the player ship palette
X = Stylus.X()
Y = Stylus.Y()
Sprite.LoadPalette( SCREEN_BOTTOM, PAL_PLAYR, "playr_1.pal" ) -- This has loaded the palette file for the player's ship
PLAYERSTATIC = FrameStrip.Create( SCREEN_BOTTOM, 32, 32, "256" )
PLAYERSTATIC:LoadBin( "playr_1.raw", 1 )
SHIP = Sprite.Create( PLAYERSTATIC, 0, playr_1.pal, 112, 150 )
while Pads.Start() == false do -- Press Start to exit script
for delay=1,500 do
SHIP.MoveTo( X, Y )
end
end
PLAYER:SetFrame( PLAYERSTATIC, 0 )
PLAYER:Free()
I've also attached the images for it.
playr_1.raw
(1 KB - downloaded 55 times.)
playr_1.pal
(0.5 KB - downloaded 58 times.)
Logged
manu62300
Waxing Crescent
Posts: 89
Re: Need Help with my code... :(
«
Reply #1 on:
July 10, 2007, 05:19:06 PM »
U have many error
Code:
SCREEN_BOTTOM = 0
PAL_PLAYR = 0
Sprite.LoadPalette( SCREEN_BOTTOM, PAL_PLAYR, "playr_1.pal" )
PLAYERFrames = FrameStrip.Create( SCREEN_BOTTOM, 32, 32, "256" )
PLAYERFrames:LoadBin( "playr_1.raw", 1 )
SHIP = Sprite.Create( PLAYERFrames, 0, PAL_PLAYR, 112, 150 )
while Pads.Start() == false do
X = Stylus.X()
Y = Stylus.Y()
if Stylus.Down() then
SHIP:MoveTo( X, Y )
for delay=1,500 do
end
end
end
PLAYER:SetFrame( PLAYERFrames, 0 )
PLAYER:Free()
«
Last Edit: July 11, 2007, 03:43:31 AM by manu62300
»
Logged
XtreamLua.com
La Référence en programmation sur PSP & DS
xtreamlua.miniville.fr
Bon dev...;
LeightonW87
Waxing Crescent
Posts: 17
Re: Need Help with my code... :(
«
Reply #2 on:
July 11, 2007, 07:58:23 AM »
Hey thanks alot, I might get working on this right now.
I'm going to try and make the ship shoot a bullet at each side of the ship. so if I look at this closely enough I may be able to.
Thanks again.
Logged
LeightonW87
Waxing Crescent
Posts: 17
Re: Need Help with my code... :(
«
Reply #3 on:
July 12, 2007, 11:30:10 AM »
Sorry about the double post but I've got myself in a spot of trouble, I'm going to attach any new files that are needed for my new code but could some one check it out again for me.
Code:
SCREEN_BOTTOM = 0
PAL_PLAYR = 0
PAL_PLAYR_SHOT = 1
Sprite.LoadPalette( SCREEN_BOTTOM, PAL_PLAYR, "playr_1.pal" )
Sprite.LoadPalette( SCREEN_BOTTOM, PAL_PLAYR_SHOT, "playr_shot.pal" )
PLAYERFrames = FrameStrip.Create( SCREEN_BOTTOM, 32, 32, "256" )
PLAYERFrames:LoadBin( "playr_1.raw", 1 )
SHOTFrames = FrameStrip.Create( SCREEN_BOTTOM, 16, 16, "256" )
SHOTFrames:LoadBin( "playr_shot.raw", 1 )
SHIP = Sprite.Create( PLAYERFrames, 0, PAL_PLAYR, 112, 150 )
while Pads.Start() == false do
X = Stylus.X()
Y = Stylus.Y()
while Pads.L() == true do
PSHOT = Sprite.Create( SHOTFrames, 0, PAL_PLAYR_SHOT, x + 16, Y + 8 )
end
if Stylus.Down() then
SHIP:MoveTo( X + 16, Y + 8 )
PSHOT:MoveTo( , + 1 )
for delay=1,500 do
end
end
end
PLAYER:SetFrame( PLAYERFrames, 0 )
PLAYER:Free()
I think it says line 24 or 25 the error is on but could someone look at it for me.
I'm just not sure how to set the objects firing position relavent to another object, which in this case is the player.
And how would I spawn objects of the same kind.
playr_shot.PAL
(0.5 KB - downloaded 60 times.)
playr_shot.raw
(0.25 KB - downloaded 52 times.)
Logged
manu62300
Waxing Crescent
Posts: 89
Re: Need Help with my code... :(
«
Reply #4 on:
July 12, 2007, 04:46:51 PM »
look this :
Code:
-- global vars
SCREEN_BOTTOM = 0
SCREEN_TOP = 1
PALETTE_SHIP = 0
PALETTE_LASER = 1
-- preparing screen
BGTopText = Screen.LoadTextBG()
Screen.Initialize( SCREEN_TOP, BGTopText )
-- text
BGTopText:PrintXY( 0, 0, "Press select to exit the game." )
BGTopText:PrintXY( 0, 1, "Created by GrimmyX." )
-- loading sprite pallette
Sprite.LoadPalette( SCREEN_BOTTOM, PALETTE_SHIP, "vaisseau.bmp.pal" )
Sprite.LoadPalette( SCREEN_BOTTOM, PALETTE_LASER, "vaisseau1.bmp.pal" )
-- frame strip to hold sprite
ShipFrames = FrameStrip.Create( SCREEN_BOTTOM, 32, 32, "256" )
LaserFrames = FrameStrip.Create( SCREEN_BOTTOM, 32, 32, "256" )
-- load binary data into frame strip object
ShipFrames:LoadBin( "vaisseau.raw", 1 )
LaserFrames:LoadBin( "vaisseau1.raw", 1 )
-- init variable to move sprite around
nX = 104
nY = 50
nvX = 0
nvY = 0
-- create a sprite using frame loaded
Ship = Sprite.Create( ShipFrames, 0, PALETTE_SHIP, nX, nY )
Laser = nil
-------------------------------------------------------------------------------
function LaserCheck()
if nvY < 1 then
Laser:Free()
Laser = nil
end
end
-------------------------------------------------------------------------------
-- updating graphics
while true do
Ship:MoveTo( nX, nY )
-- moving the actual ship with keys
if Pads.Down() then
nY = nY + 4
end
if Pads.Up() then
nY = nY - 4
end
if Pads.Left() then
nX = nX - 4
end
if Pads.Right() then
nX = nX + 4
end
-- shooting
if ( ( Laser == nil ) and ( Pads.A() ) ) then
nvX = nX
nvY = nY
Laser = Sprite.Create( LaserFrames, 0, PALETTE_LASER, nvX, nvY )
end
-- move laser
if ( Laser ~= nil ) then
nvY = nvY - 1
Laser:MoveTo( nvX, nvY )
LaserCheck()
end
-- exit when user press a key
if Pads.Select() then
break
end
-- wait for VBlank so we don't cause graphics tearing
Screen.WaitForVBL()
end
-- clean up
if ( Laser ~= nil ) then
Laser:Free()
end
Ship:Free()
ShipFrames:FreeAll()
LaserFrames:FreeAll()
and look the project Zhemesis and Jetfighter on the forum
Logged
XtreamLua.com
La Référence en programmation sur PSP & DS
xtreamlua.miniville.fr
Bon dev...;
Pages:
[
1
]
Print
« previous
next »
Jump to:
Please select a destination:
-----------------------------
DSLua - Best scripting language for Nintendo DS
-----------------------------
=> News and Announcements
=> Examples/Tutorials
=> Home-brew/Hacks/Games/Projects
=> Hardware and Equipments
=> Need Help?
=> Bugs & Suggestions
-----------------------------
General DS Programming Chats
-----------------------------
=> Code Hashing
=> Chat Room
=> Test Area
Powered by SMF 1.1 RC2
|
SMF © 2001-2005, Lewis Media