--[[DiabloTerrorGF]]
--System.usbDiskModeActivate()
--load graphics
yourShipImage = Image.load("yourShip.png")
enemyShipImage = Image.load("enemy1.png")
yourBulletImage = Image.load("bullet.png")
enemyBulletImage = Image.load("enemyBullet.png")
--explosionImage1 = Image.load("explosion1.png")
--explosionImage2 = Image.load("explosion2.png")
--explosionImage3 = Image.load("explosion3.png")
background = Image.load("background.png")
--gameOver = Image.load("gameOver.png")
--load sounds
bulletFire = Sound.load("PHOTON.wav")
--set bounds
YSBoundX = 0
YSBoundY = 0
YSBoundMX = 18
YSBoundMY = 11
YSBoundCMX = 0
YSBoundCMY = 0
ES1BoundX = 0
ES1BoundY = 0
ES1BoundCMX = 0
ES1BoundCMY = 0
ESBoundMX = 17
ESBoundMY = 21
--set globals
score = 0
GameRun = 0
loopNum = 0
bulletNotFired = true
function testFireSound()
if GameRun==1 then
if Controls.read():cross() then
if bulletNotFired==true then
bulletFire:play()
bulletNotFired=false
end
end
end
end
function moveMyShip()
if GameRun==1 then
if Controls.read():right() then
YSBoundX = YSBoundX+10
end
if Controls.read():left() then
YSBoundX = YSBoundX-10
end
if Controls.read():up() then
YSBoundY = YSBoundY-10
end
if Controls.read():down() then
YSBoundY = YSBoundY+10
end
end
end
GameRun = 1
if GameRun==1 then
while not Controls.read():start() do
screen:blit(0, 0, background, 0, 0, background:width(), background:height(), false)
screen:blit(YSBoundX, YSBoundY, yourShipImage)
testFireSound()
moveMyShip()
screen.flip()
screen.waitVblankStart()
bulletNotFire=true
end
end
--System.usbDiskModeDeactivate()
Moving seems laggy and slow on the psp, any ideas?
Last edited by DiabloTerrorGF on Tue Aug 23, 2005 1:16 pm, edited 1 time in total.
Controls.read() needs some time. Save the value returned from this function and call the test functions on the return value (e.g. pad=Controls.read(); if pad:right() ... if pad:top() ...)
Just a general advice, one that Shine also recommends often: If you have weird problems with your code, look through it the way it would be interpreted, follow the thread of execution. In the above example, one would see that the if statement checks for a certain boolean. Following the thread of execution through the main loop, one would see that that boolean is never reset to true, because of a spelling mistake. (doing a search through the document for the offending variable would work too. This is a good idea in Lua, as it's not an error to set a previously undeclared variable (that is, a misspelled one) to a value.)