help me for the shoot
You could put a complete script with a jet which draws a bullet which crosses the 2 screens because I does not understand please...
SCREEN_BOTTOM = 0
SCREEN_TOP = 1
PALETTE_JET1 = 0
PALETTE_JET2 = 1
PALETTE_LASER1 = 2
PALETTE_LASER2 = 3
PALETTE_LASER3 = 4
PALETTE_LASER4 = 5
PALETTE_LIFE = 6
PALETTE_EXPLOSION = 7
----------------------------------------------------------------------------
local m_Buttons = {
A = { Pressed = false, timer = 0 },
B = { Pressed = false, timer = 0 },
X = { Pressed = false, timer = 0 },
Y = { Pressed = false, timer = 0 },
L = { Pressed = false, timer = 0 },
R = { Pressed = false, timer = 0 },
Left = { Pressed = false, timer = 0 },
Right = { Pressed = false, timer = 0 },
Start = { Pressed = false, timer = 0 },
Select = { Pressed = false, timer = 0 },
Up = { Pressed = false, timer = 0 },
Down = { Pressed = false, timer = 0 },
}
-------------------------------------------------------------------------------
function ButtonDown( name )
if Pads[ name ]() then
if not m_Buttons[ name ].Pressed then
m_Buttons[ name ].Pressed = true
m_Buttons[ name ].timer = 0
return true
else
m_Buttons[ name ].timer = m_Buttons[ name ].timer + 1
end
else
if m_Buttons[ name ].Pressed then
m_Buttons[ name ].Pressed = false
return false
end
end
return false
end
-------------------------------------------------------------------------------
function ButtonLongPressed( name )
if m_Buttons[ name ].Pressed and m_Buttons[ name ].timer >= 6 then
return true
end
return false
end
-------------------------------------------------------------------------------
BGBotMap = Screen.LoadTileBG()
BGTopMap = Screen.LoadTileBG()
BGBotText = Screen.LoadTextBG()
BGTopText = Screen.LoadTextBG()
BGBotMap:LoadPalette( "decorbot.pal" )
BGBotMap:LoadTiles( "decorbot.raw", 256 )
BGBotMap:LoadMap( "decorbot.map", ( 256 / 8 ), ( 192 / 8 ))
Screen.Initialize ( 0, BGBotText, BGBotMap )
BGTopMap:LoadPalette( "decortop.pal" )
BGTopMap:LoadTiles( "decortop.raw", 256 )
BGTopMap:LoadMap( "decortop.map", ( 256 / 8 ), ( 192 / 8 ))
Screen.Initialize ( 1, BGTopText, BGTopMap )
BGTopText:SetColor( 5 )
BGTopText:PrintXY( 0, 0, "Jetfighter: Cid2Mizard for DSLua" )
BGTopText:SetColor( 6 )
BGTopText:PrintXY( 31, 5, "S" )
BGTopText:PrintXY( 31, 6, "C" )
BGTopText:PrintXY( 31, 7, "O" )
BGTopText:PrintXY( 31, 8, "R" )
BGTopText:PrintXY( 31, 9, "E" )
BGTopText:PrintXY( 31, 10, "-" )
BGTopText:PrintXY( 31, 11, "0" )
BGBotText:SetColor( 1 )
BGBotText:PrintXY( 10,23, "Start : Quit" )
BGBotText:SetColor( 6 )
BGBotText:PrintXY( 0, 5, "S" )
BGBotText:PrintXY( 0, 6, "C" )
BGBotText:PrintXY( 0, 7, "O" )
BGBotText:PrintXY( 0, 8, "R" )
BGBotText:PrintXY( 0, 9, "E" )
BGBotText:PrintXY( 0, 10, "-" )
BGBotText:PrintXY( 0, 11, "0" )
Sprite.LoadPalette( SCREEN_TOP, PALETTE_JET1, "jet1.pal" )
Sprite.LoadPalette( SCREEN_BOTTOM, PALETTE_JET2, "jet2.pal" )
Sprite.LoadPalette( SCREEN_TOP, PALETTE_LASER1, "laser1.pal" )
Sprite.LoadPalette( SCREEN_BOTTOM, PALETTE_LASER3, "laser1.pal" )
Sprite.LoadPalette( SCREEN_TOP, PALETTE_LASER4, "laser2.pal" )
Sprite.LoadPalette( SCREEN_BOTTOM, PALETTE_LASER2, "laser2.pal" )
Sprite.LoadPalette( SCREEN_TOP, PALETTE_LIFE, "life.pal" )
Sprite.LoadPalette( SCREEN_BOTTOM, PALETTE_LIFE, "life.pal" )
Sprite.LoadPalette( SCREEN_TOP, PALETTE_EXPLOSION, "explosion.pal" )
Sprite.LoadPalette( SCREEN_BOTTOM, PALETTE_EXPLOSION, "explosion.pal" )
Jet1Frames = FrameStrip.Create( SCREEN_TOP, 32, 32, "256" )
Jet2Frames = FrameStrip.Create( SCREEN_BOTTOM, 32, 32, "256" )
Laser1Frames = FrameStrip.Create( SCREEN_TOP, 16, 8, "256" )
Laser2Frames = FrameStrip.Create( SCREEN_BOTTOM, 16, 8, "256" )
Laser3Frames = FrameStrip.Create( SCREEN_BOTTOM, 16, 8, "256" )
Laser4Frames = FrameStrip.Create( SCREEN_TOP, 16, 8, "256" )
Life1Frames = FrameStrip.Create( SCREEN_TOP, 64, 64, "256" )
Life2Frames = FrameStrip.Create( SCREEN_BOTTOM, 64, 64, "256" )
Explosion1Frames = FrameStrip.Create( SCREEN_TOP, 32, 32, "256" )
Explosion2Frames = FrameStrip.Create( SCREEN_BOTTOM, 32, 32, "256" )
Jet1Frames:LoadBin( "jet1.raw", 1 )
Jet2Frames:LoadBin( "jet2.raw", 1 )
Laser1Frames:LoadBin( "laser1.raw", 1 )
Laser2Frames:LoadBin( "laser2.raw", 1 )
Laser3Frames:LoadBin( "laser1.raw", 1 )
Laser4Frames:LoadBin( "laser2.raw", 1 )
Life1Frames:LoadBin( "life.raw", 5 )
Life2Frames:LoadBin( "life.raw", 5 )
Explosion1Frames:LoadBin( "explosion.raw", 5 )
Explosion2Frames:LoadBin( "explosion.raw", 5 )
ModIntro = Music.LoadMod( "intro.mod" )
nX = 104
nY = 50
nA = 104
nB = 50
nvX = 0
nvY = 0
nvA = 0
nvB = 0
Jet1 = Sprite.Create( Jet1Frames, 0, PALETTE_JET1, nA, nB )
Jet2 = Sprite.Create( Jet2Frames, 0, PALETTE_JET2, nX, nY )
Life1 = Sprite.Create( Life1Frames, 4, PALETTE_LIFE, 1, 64 )
Life2 = Sprite.Create( Life2Frames, 4, PALETTE_LIFE, 247, 64 )
Laser1 = nil
Laser2 = nil
Laser3 = nil
Laser4 = nil
----------------------------------------------------------------------------------------------
function Laser1Check()
if nvB > 191 then
Laser1:Free()
Laser1 = nil
if Laser1 == nil then
nvC = nvB - 191
Laser3 = Sprite.Create( Laser3Frames, 0, PALETTE_LASER3, nvA, nvC )
end
end
end
----------------------------------------------------------------------------------------------
function Laser2Check()
if nvY < 1 then
Laser2:Free()
Laser2 = nil
if Laser2 == nil then
nvZ = nvY + 191
Laser4 = Sprite.Create( Laser4Frames, 0, PALETTE_LASER4, nvX, nvZ )
end
end
end
----------------------------------------------------------------------------------------------
function Laser3Check()
if nvC > 191 then
Laser3:Free()
Laser3 = nil
end
end
----------------------------------------------------------------------------------------------
function Laser4Check()
if nvZ < 1 then
Laser4:Free()
Laser4 = nil
end
end
----------------------------------------------------------------------------------------------
while true do
ModIntro:Play()
Jet1:MoveTo( nA, nB )
Jet2:MoveTo( nX, nY )
if Pads.Right() then
nX = nX + 3
end
if nX >= 224 then
nX = nX - 3
end
if Pads.Left() then
nX = nX - 3
end
if nX <= 0 then
nX = nX + 3
end
if Pads.Up() then
nY = nY - 3
end
if nY <= 0 then
nY = nY + 3
end
if Pads.Down() then
nY = nY + 3
end
if nY >= 160 then
nY = nY - 3
end
if Pads.A() then
nA = nA + 3
end
if nA >= 224 then
nA = nA - 3
end
if Pads.Y() then
nA = nA - 3
end
if nA <= 0 then
nA = nA + 3
end
if Pads.X() then
nB = nB - 3
end
if nB <= 0 then
nB = nB + 3
end
if Pads.B() then
nB = nB + 3
end
if nB >= 160 then
nB = nB - 3
end
if ButtonDown ( "R" ) then
nvA = nA + 8
nvB = nB
Laser1 = Sprite.Create( Laser1Frames, 0, PALETTE_LASER1, nvA, nvB )
end
if ButtonDown ( "L" ) then
nvX = nX + 8
nvY = nY
Laser2 = Sprite.Create( Laser2Frames, 0, PALETTE_LASER2, nvX, nvY )
end
if ( Laser1 ~= nil ) then
nvB = nvB + 3
Laser1:MoveTo( nvA, nvB )
Laser1Check()
end
if ( Laser2 ~= nil ) then
nvY = nvY - 3
Laser2:MoveTo( nvX, nvY )
Laser2Check()
end
if ( Laser3 ~= nil ) then
nvC = nvC + 3
Laser3:MoveTo( nvA, nvC )
Laser3Check()
end
if ( Laser4 ~= nil ) then
nvZ = nvZ - 3
Laser4:MoveTo( nvX, nvZ )
Laser4Check()
end
if Pads.Start() then
break
end
Screen.WaitForVBL()
end
Jet1Frames:FreeAll()
Jet2Frames:FreeAll()
Laser1Frames:FreeAll()
Laser2Frames:FreeAll()
Laser3Frames:FreeAll()
Laser4Frames:FreeAll()
ModIntro:Free()
Help me for the Laser correctly and initialize life and score