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
New to LUA coding need help with 2 things!
Moderators: Shine, Insert_witty_name
-
- Posts: 2
- Joined: Thu Nov 01, 2007 5:17 am
Re: New to LUA coding need help with 2 things!
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: Select all
do while quitter == false
...
if pad:start() then quitter = true end
...
end
Code: Select all
quitter = false
...
do while quitter == false
...
if pad:start() then quitter = true end
...
end
Enlighten me, Reveal my fate -- Follow - Breaking Benjamin
-
- Posts: 2
- Joined: Thu Nov 01, 2007 5:17 am
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-- 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
P.S
i forgot if u have any idea on how to do AI then message me thxz
just like I said above check if you have a quit variable(which you do)
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
should solve your problem
Code: Select all
if exitgame== 1 then
break
end
Code: Select all
exitgame = 0
Enlighten me, Reveal my fate -- Follow - Breaking Benjamin