 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
DiabloTerrorGF
Joined: 15 Jul 2005 Posts: 64
|
Posted: Sat Aug 20, 2005 1:03 pm Post subject: Now sound isn't working... |
|
|
| Code: | --[[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 |
|
| Back to top |
|
 |
Shine
Joined: 03 Dec 2004 Posts: 728 Location: Germany
|
Posted: Sat Aug 20, 2005 4:47 pm Post subject: |
|
|
| 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() ...) |
|
| Back to top |
|
 |
DiabloTerrorGF
Joined: 15 Jul 2005 Posts: 64
|
Posted: Sun Aug 21, 2005 2:02 am Post subject: |
|
|
| rawr, that helped, thanks. |
|
| Back to top |
|
 |
DiabloTerrorGF
Joined: 15 Jul 2005 Posts: 64
|
Posted: Tue Aug 23, 2005 1:12 pm Post subject: |
|
|
My sound only seems to play once now... what did I do?
| Code: | --[[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
--[[ES2BoundX = 0
ES3BoundX = 0
ES4BoundX = 0
ES5BoundX = 0
ES6BoundX = 0
ES7BoundX = 0
ES8BoundX = 0
ES9BoundX = 0
ES10BoundX = 0
ES11BoundX = 0
ES12BoundX = 0]]
ES1BoundY = 0
--[[ES2BoundY = 0
ES3BoundY = 0
ES4BoundY = 0
ES5BoundY = 0
ES6BoundY = 0
ES7BoundY = 0
ES8BoundY = 0
ES9BoundY = 0
ES10BoundY = 0
ES11BoundY = 0
ES12BoundY = 0]]
ES1BoundCMX = 0
--[[ES2BoundCMX = 0
ES3BoundCMX = 0
ES4BoundCMX = 0
ES5BoundCMX = 0
ES6BoundCMX = 0
ES7BoundCMX = 0
ES8BoundCMX = 0
ES9BoundCMX = 0
ES10BoundCMX = 0
ES11BoundCMX = 0
ES12BoundCMX = 0]]
ES1BoundCMY = 0
--[[ES2BoundCMY = 0
ES3BoundCMY = 0
ES4BoundCMY = 0
ES5BoundCMY = 0
ES6BoundCMY = 0
ES7BoundCMY = 0
ES8BoundCMY = 0
ES9BoundCMY = 0
ES10BoundCMY = 0
ES11BoundCMY = 0
ES12BoundCMY = 0]]
ESBoundMX = 17
ESBoundMY = 21
--set globals
score = 0
GameRun = 0
loopNum = 0
bulletNotFired = true
pad = 0
function moveMyShip()
if GameRun==1 then
pad=Controls.read()
if pad:right() then
YSBoundX = YSBoundX+10
end
if pad:left() then
YSBoundX = YSBoundX-10
end
if pad:up() then
YSBoundY = YSBoundY-10
end
if pad:down() then
YSBoundY = YSBoundY+10
end
if pad:cross() then
if bulletNotFired then
bulletFire:play()
bulletNotFired=false
end
end
if pad:start() then
loopNum = 0
end
end
end
GameRun = 1
loopNum = 1
if GameRun==1 then
while loopNum==1 do
screen:blit(0, 0, background, 0, 0, background:width(), background:height(), false)
screen:blit(YSBoundX, YSBoundY, yourShipImage)
bulletNotFire=true
moveMyShip()
screen.flip()
screen.waitVblankStart()
end
end
System.usbDiskModeDeactivate()
dofile("index.lua")
|
|
|
| Back to top |
|
 |
nevyn
Joined: 31 Jul 2005 Posts: 136 Location: Sweden
|
Posted: Tue Aug 23, 2005 5:58 pm Post subject: |
|
|
(solved this with gf over aim)
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.) |
|
| Back to top |
|
 |
DiabloTerrorGF
Joined: 15 Jul 2005 Posts: 64
|
Posted: Wed Aug 24, 2005 1:15 pm Post subject: |
|
|
| Yeah, thanks a lot. I'm now setting up Eclipse for my own LUA IDE that will prevent this >_< |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|