forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

New to LUA coding need help with 2 things!

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development
View previous topic :: View next topic  
Author Message
lukespalding



Joined: 01 Nov 2007
Posts: 2

PostPosted: Thu Nov 01, 2007 5:42 am    Post subject: New to LUA coding need help with 2 things! Reply with quote

Right well i have 2 problems, one is that i want to create A.I so that item will fall from top of the screena nd my player will touch them and they will dissappear and a point added to players points and the other is that when i play my agme then exit back to the lua player i cannot run the game again the memory card light flashes for about 2 sec's then it just stops flashing and the game starts then just goes of straight away and i dont know why?!
i really need some help on these two things so please give me any information about these things if you know of any.
luke spalding
Back to top
View user's profile Send private message
PiCkDaT



Joined: 04 Oct 2007
Posts: 69

PostPosted: Fri Nov 09, 2007 11:12 pm    Post subject: Re: New to LUA coding need help with 2 things! Reply with quote

lukespalding wrote:
Right well i have 2 problems, one is that i want to create A.I so that item will fall from top of the screena nd my player will touch them and they will dissappear and a point added to players points and the other is that when i play my agme then exit back to the lua player i cannot run the game again the memory card light flashes for about 2 sec's then it just stops flashing and the game starts then just goes of straight away and i dont know why?!
i really need some help on these two things so please give me any information about these things if you know of any.
luke spalding



for the A.I. you are on your own for now cause I dont have the time to write something at the moment, but as for your game.. do you have a quitter variable?

for example

Code:

do while quitter == false

...

if pad:start() then quitter = true end

...

end



if so then your problem may be that quitter still = true so at the top of your code fix it by re declairing it

Code:


quitter = false

...

do while quitter == false

...

if pad:start() then quitter = true end

...

end


_________________
Enlighten me, Reveal my fate -- Follow - Breaking Benjamin
Back to top
View user's profile Send private message AIM Address
lukespalding



Joined: 01 Nov 2007
Posts: 2

PostPosted: Sat Nov 10, 2007 12:14 am    Post subject: Reply with quote

Quote:
-- Created by Luke Spalding --
-- On the 16/10/2007 --

-- this activates the usb mode so you can edit this script easyily--
System.usbDiskModeActivate()

-- these are the colors that i can use within the game --
AliceBlue=Color.new(240,248,255)
cyan = Color.new(0, 255, 255)
green=Color.new(0,255,0)
black=Color.new(0,0,0)
white = Color.new(255,255,255)
yellow = Color.new(255, 255, 0)
-------------------------------------
background = Image.load("images/background.PNG")
player1 = Image.load("images/player1.PNG")

screenwidth = 480 - player1:width()
screenheight = 272 - player1:height()
player1x =200
player1y =204

gamestate = "paused"

screen:clear()
screen:print(80,136, "Christmas Pac Man Created By Luke Spalding", AliceBlue)
screen:flip()
screen.waitVblankStart(240)

-------------------------------------------------

-- functions --
-- this checks the controls you press ingame --
function checkcontrols()
pad = Controls.read()


if pad:right() and gamestate == "game" then
player1x = player1x +4
end


if pad:left() and gamestate == "game" then
player1x = player1x -4
end






function playGame()
screen:clear()
pad = Controls.read()

if pad:start() then
gamestate = "paused"
end
end


if pad:cross() and gamestate == "paused" then
gamestate = "game"
end

if pad:select() and gamestate == "paused" then
exitgame = 1
end
end

function drawall()
screen:clear()
screen:blit (0,0,background,false)
screen:blit(player1x,player1y,player1)
screen.waitVblankStart()
screen.flip()
end

function paused()
screen:print(160,145,"Press X To Play christmas pac man",black)
screen:print(160,155,"Press Select to Quit",black)
screen:flip()
screen.waitVblankStart()
end
-- main loop --

while true do
checkcontrols()
drawall()

if gamestate == "paused" then
paused()
end

if gamestate == "game" then
playGame()
end

if exitgame== 1 then
break
end
end



thats my whole game code so if anybody could take a look at that and help with the exiting in the lua player then please do if not dont rob the game ok thanks

P.S
i forgot if u have any idea on how to do AI then message me thxz
Back to top
View user's profile Send private message
PiCkDaT



Joined: 04 Oct 2007
Posts: 69

PostPosted: Sat Nov 10, 2007 4:31 am    Post subject: Reply with quote

just like I said above check if you have a quit variable(which you do)

Code:

if exitgame== 1 then
break
end


if you look at the top of your code you dont have anything to make it = 0 again. If you are running LOWSER it doesn't quit LUA so therefor some variable's are still loaded into the memory to fix this just add somewhere before your main loop

Code:

exitgame = 0


should solve your problem
_________________
Enlighten me, Reveal my fate -- Follow - Breaking Benjamin
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
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