Thread: coding issue
View Single Post
Old 06-08-2008   #1 (permalink)
chrono trigger
GamingCrazy Rookie
 
Join Date: Dec 2006
Posts: 193
coding issue

ok so im a little confussed when i had my psp phat this code i wrote worked on lua player fine, but then i bought a psp slim and had to find a different lua player that worked for it and im now using lua player HM v1.0 but when i tried to load my code it just gave me a black screen and shut off so do you think it is a prob with my code something possibly getting changed? or do you think its a combatibility issue?
p.s. heres my code if someone would be nice enough to read through it to see if its the thing causing the problem. (and its not the prettiest written code just so you all know)
Spoiler
Code:
System.usbDiskModeActivate()
red = Color.new(0,0,255)
green = Color.new(0,255,0)
ground =  Image.createEmpty(480,5)
ground:clear(green)
oldpad = Controls.read()
currentBullet = 0
direction = "right"
floor = Image.load("background.png")
pic1 = Image.load("enemy.png")
pic2 = Image.load("pic2.png")
shell = Image.load("bullet.png")
fallen = Image.load("killed.png")
Floor = {}
Floor.x = 0
Floor.y = 0
Dead = { }
Dead[1] = { x = 286, y = 107}
Pic = { }
Pic[1] = { x = 286, y = 107}
Mine = { }
Mine[1] = { x = 275, y = 143, h = pic2:height(), w = pic2:width() }
Pic = { }
Pic[1] = { x= 286, y = 107, h = pic1:height(), w = pic1:width() }
Player = {}
Player[1] = { oldx = 50, oldy = 107 }
Player.gravity = 107
Player.y = 10 
Player.x = 20
Player.jumpspeed = 10
Player.jumpstate = "ground"
Player.weapon = "gun"
Player.img = {
["gun"] = Image.load("player_gun.png"),
["none"] = Image.load("player.png"),
["flame"] = Image.load("player_flame.png"),
["machine"] = Image.load("player_machine.png"),
["crouch"] = Image.load("player_crouch.png"),
["kneel"] = Image.load("player_crouch2.png")}
BulletInfo = {}
BulletInfo[1] = { pic = shell, firing = false, direction = "right", x = Player.x + 32,
y = Player.y + 16, h = shell:height(), w = shell:width() }
playerHeight = 90
playerWidth = 90
function movePlayer()
pad = Controls.read()
if pad:left() then 
Player.x = Player.x - 1 
end
if pad:right() then 
Player.x = Player.x + 1 
end
end
Player.x = Player[1].oldx
Player.y = Player[1].oldy
function bulletSetup()
if direction == "left" then
BulletInfo[1].x = Player.x
BulletInfo[1].y = Player.y + 16
end
if direction == "right" then
BulletInfo[1].x = Player.x + 32
BulletInfo[1].y = Player.y + 16
end
BulletInfo[1].direction = direction
BulletInfo[1].firing = true
end
function bulletFire()
if BulletInfo[1].firing == true then
if BulletInfo[1].direction == "right" then BulletInfo[1].x = BulletInfo[1].x + 10 end
if BulletInfo[1].direction == "left" then BulletInfo[1].x = BulletInfo[1].x - 10 end
screen:blit(BulletInfo[1].x,BulletInfo[1].y,BulletInfo[1].pic)
end
if BulletInfo[1].x < 0 or BulletInfo[1].x > 480 then
BulletInfo[1].firing = false
end
end
function collision(Pic,BulletInfo)
if (Pic[1].x+Pic[1].w > BulletInfo[1].x ) and (Pic[1].x < BulletInfo[1].x + BulletInfo[1].w) and (Pic[1].y + Pic[1].h > BulletInfo[1].y) and (Pic[1].y < BulletInfo[1].y + BulletInfo[1].h) then
 return true
 else
  return false
 end
end
alpha = true
while true do
pad = Controls.read()
screen:clear()
screen:blit(0,262,ground)
screen:blit(Floor.x, Floor.y,floor)
screen:blit(Pic[1].x,Pic[1].y,pic1)
screen:blit(Player.x,Player.y,Player.img[Player.weapon])
if pad:left() and Player.x > 0 then
Player.x = Player.x - 2
end
if pad:right() and Player.x < 480 then
Player.x = Player.x + 2
end
if pad:up() then
Player.weapon = "kneel"
end
if pad:down() then
Player.weapon = "crouch"
end
if pad:r() then
Player.weapon = "gun"
end
if pad:l()
 then
Player.weapon = "machine" 
end
if pad:cross() and Player.jumpstate == "ground" then Player.jumpstate = "jumping"
end 
if Player.jumpstate == "jumping" then 
Player.jumpspeed = Player.jumpspeed - 0.5
Player.gravity = Player.gravity - Player.jumpspeed 
end
if Player.gravity < 0 then 
Player.jumpstate = "falling"
end
if Player.gravity < 107 and Player.jumpstate == "falling" then 
Player.gravity = Player.gravity + (Player.jumpspeed + 3) 
end
if Player.gravity == 107 then 
Player.jumpspeed = 10
Player.jumpstate = "ground"
end
if Player.gravity > 107 then Player.gravity = 107 
end
Player.y = Player.gravity
if collision(Pic,BulletInfo) then
screen:blit(Dead[1].x, Dead[1].y, fallen)
screen.flip()
end
if Player.x == 380 then
screen:print(200,80,"you beat level 1")
screen.flip()
screen.waitVblankStart(40)
screen:clear()
end
if Player.x == 286 then
Player.x = Player[1].oldx
Player.y = Player[1].oldy and
screen:print(210,80,"you lost")
screen.flip()
screen.waitVblankStart(30)
screen:clear()
end
if pad:circle() and oldpad:circle() ~= pad:circle() then
bulletSetup()
end
bulletFire()
screen.waitVblankStart()
screen.flip()
oldpad = pad
end

Thank you to anyone that is willing to help
p.s. if this is the wrong place to post this im sorry
chrono trigger is offline   Reply With Quote
Sponsored Links