QJ.NET | Videos | Forums | iPhone | MMORPG | Nintendo DS | Wii | PlayStation 3 | PSP | Xbox 360 | PC | Downloads | Contact Us
Forums | Gaming News | Videos | Downloads | Today's Posts | Mark Forums Read | Chat | FAQ | Members List | Contact

QJ.net Game Discussion - PSP, Xbox, Wii, PS3, PSP Homebrew, and PSP Guides

Go Back   QJ.net Game Discussion - PSP, Xbox, Wii, PS3, PSP Homebrew, and PSP Guides > Developers Corner > PSP Development, Hacks, and Homebrew > PSP Development Forum
The above video goes away if you are a member and logged in, so log in now!

Lua Skateboarding - Menu Help :(

This is a discussion on Lua Skateboarding - Menu Help :( within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; Hey all, i am having some problems with my menu for my game which i will release when finished... I ...

Reply
 
LinkBack Thread Tools
Old 10-01-2006, 12:53 PM   #1

chaccaron.
 
 
Join Date: Sep 2006
Real First Name: Andrew
Location: England
Posts: 2,615
Trader Feedback: 0
Default Lua Skateboarding - Menu Help :(

Hey all, i am having some problems with my menu for my game which i will release when finished...

I have some images which will change when people press down or up on the menu,
My problem is that it loads the menu screen but when i press down or x it just stays on the same image, here is my code:
Code:
red = Color.new(255,0,0)
green = Color.new(0,255,0)
blue = Color.new(0,0,255)
yellow = Color.new(255,255,0)
purple = Color.new(255,0,255)
play = Image.load("mselectplay.png")
credits = Image.load("mselectcred.png")
score = Image.load("mselectscore.png")
function delay(seconds)
	time=seconds*60
	for i=1, time do
		screen.waitVblankStart()
	end
end
-- select
while true do
screen:blit(0,0,play)
screen.flip()
end
pad = Controls.read()
if pad:cross() then
dofile("game.lua")
end 
if pad:down() then
screen:blit(0,0,credits)
screen.flip()
end
if pad:cross() then
dofile("credits.lua")
end
if pad:down() then
screen:blit(0,0,score)
screen.flip()
end
if pad:cross() then
dofile("hiscore.lua")
end
As you can see above is where the controls are, i think the problem might be ending the ifs too soon or something like that or it might be this bit of code:
Code:
	for i=1, time do
		screen.waitVblankStart()
	end
end
-- select
while true do
screen:blit(0,0,play)
screen.flip()
end
pad = Controls.read()
Which might be ending the loop too soon therefor not reading the controls?

Please help i really want this game to work and then i might make a series
__________________
whyHELLOder.
AndyMosh is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-01-2006, 12:57 PM   #2
likes kittens....awww....
 
Join Date: Sep 2006
Real First Name: Erik
Location: Detroit
Just Played: Call of Duty:World at War
Posts: 628
Trader Feedback: 0
Default

hmm.....
try this.. instead..
Code:
red = Color.new(255,0,0)
green = Color.new(0,255,0)
blue = Color.new(0,0,255)
yellow = Color.new(255,255,0)
purple = Color.new(255,0,255)
play = Image.load("mselectplay.png")
credits = Image.load("mselectcred.png")
score = Image.load("mselectscore.png")
  function delay(seconds)
  time=seconds*60
  for i=1, time do
  screen.waitVblankStart()
  end
end
-- select
while true do
status = 0
screen:blit(0,0,play)
screen.flip()
end
pad = Controls.read()
if pad:cross() and status == 0 then
status = ingame
dofile("game.lua")
end 
if pad:down() and status == 0 then
status = 1
screen:blit(0,0,credits)
screen.flip()
end
if pad:cross()  and status == 1 then
dofile("credits.lua")
end
if pad:down() and status == 1 then
status = 2
screen:blit(0,0,score)
screen.flip()
end
if pad:cross() and status == 2 then
dofile("hiscore.lua")
end
if pad:down() and status == 2 then
status = 0
end
end
psphacker12. is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-01-2006, 01:05 PM   #3

sceKernelExitGame();
 
Bronx's Avatar
 
Join Date: Jan 2006
Location: New York
Posts: 3,125
Trader Feedback: 0
Default

Don't blit pictures right in a if statement, use a finit state... like for example:
Code:
 blit_credits = 0

if pad:cross() then
blit_credits = 1
end

if blit_credits == 1 then
screen:blit(0,0, "credits")
end
And you shouldn't have the screen.flip() after them either.

And this:
Code:
while true do
screen:blit(0,0,play)
screen.flip()
end
pad = Controls.read()
Should be:
Code:
while true do

//do all if statements in-game stuff here
pad = Controls.read()
screen:blit(0,0,play)
screen.flip()
screen.waitVblankStart()
end
Bronx is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-01-2006, 01:07 PM   #4
likes kittens....awww....
 
Join Date: Sep 2006
Real First Name: Erik
Location: Detroit
Just Played: Call of Duty:World at War
Posts: 628
Trader Feedback: 0
Default

Quote:
Originally Posted by Bronx
Don't blit pictures right in a if statement, use a finit state... like for example:
Code:
 blit_credits = 0

if pad:cross() then
blit_credits = 1
end

if blit_credits == 1 then
screen:blit(0,0, "credits")
end
And you shouldn't have the screen.flip() after them either.

And this:
Code:
while true do
screen:blit(0,0,play)
screen.flip()
end
pad = Controls.read()
Should be:
Code:
while true do

//do all if statements in-game stuff here
pad = Controls.read()
screen:blit(0,0,play)
screen.flip()
screen.waitVblankStart()
end
lol bronx in lua its not // its --
psphacker12. is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-01-2006, 01:10 PM   #5

sceKernelExitGame();
 
Bronx's Avatar
 
Join Date: Jan 2006
Location: New York
Posts: 3,125
Trader Feedback: 0
Default

oops.... lol, haven't programmed in la for awhile , just natural now
Bronx is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-01-2006, 01:11 PM   #6

chaccaron.
 
 
Join Date: Sep 2006
Real First Name: Andrew
Location: England
Posts: 2,615
Trader Feedback: 0
Default

Bronx how would i make it that when it loads mselectplay if they press down it will blit another image?
__________________
whyHELLOder.
AndyMosh is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-01-2006, 01:15 PM   #7
likes kittens....awww....
 
Join Date: Sep 2006
Real First Name: Erik
Location: Detroit
Just Played: Call of Duty:World at War
Posts: 628
Trader Feedback: 0
Default

Quote:
Originally Posted by AndyMosh
Bronx how would i make it that when it loads mselectplay if they press down it will blit another image?
Just use this and it should work..
Spoiler for Code:
Code:
red = Color.new(255,0,0)
green = Color.new(0,255,0)
blue = Color.new(0,0,255)
yellow = Color.new(255,255,0)
purple = Color.new(255,0,255)
play = Image.load("mselectplay.png")
credits = Image.load("mselectcred.png")
score = Image.load("mselectscore.png")
  function delay(seconds)
  time=seconds*60
  for i=1, time do
  screen.waitVblankStart()
  end
end
-- select
while true do
status = 0
screen:blit(0,0,play)
pad = Controls.read()
if pad:cross() and status == 0 then
status = ingame
dofile("game.lua")
end 
if pad:down() and status == 0 then
status = 1
screen:blit(0,0,credits)
screen.flip()
end
if pad:cross()  and status == 1 then
dofile("credits.lua")
end
if pad:down() and status == 1 then
status = 2
screen:blit(0,0,score)
screen.flip()
end
if pad:cross() and status == 2 then
dofile("hiscore.lua")
end
if pad:down() and status == 2 then
status = 0
end
psphacker12. is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-01-2006, 01:18 PM   #8

chaccaron.
 
 
Join Date: Sep 2006
Real First Name: Andrew
Location: England
Posts: 2,615
Trader Feedback: 0
Default

I've tried it and it says (eof) expected near 'end' you know that error?
__________________
whyHELLOder.
AndyMosh is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-01-2006, 01:20 PM   #9
likes kittens....awww....
 
Join Date: Sep 2006
Real First Name: Erik
Location: Detroit
Just Played: Call of Duty:World at War
Posts: 628
Trader Feedback: 0
Default

Quote:
Originally Posted by AndyMosh
I've tried it and it says (eof) expected near 'end' you know that error?
Try this.
Code:
red = Color.new(255,0,0)
green = Color.new(0,255,0)
blue = Color.new(0,0,255)
yellow = Color.new(255,255,0)
purple = Color.new(255,0,255)
play = Image.load("mselectplay.png")
credits = Image.load("mselectcred.png")
score = Image.load("mselectscore.png")
  function delay(seconds)
  time=seconds*60
  for i=1, time do
  screen.waitVblankStart()
  end
end
-- select
while true do
status = 0
screen:blit(0,0,play)
pad = Controls.read()
if pad:cross() and status == 0 then
status = ingame
dofile("game.lua")
end 
if pad:down() and status == 0 then
status = 1
screen:blit(0,0,credits)
screen.flip()
end
if pad:cross()  and status == 1 then
dofile("credits.lua")
end
if pad:down() and status == 1 then
status = 2
screen:blit(0,0,score)
screen.flip()
end
if pad:cross() and status == 2 then
dofile("hiscore.lua")
end
if pad:down() and status == 2 then
status = 0
end
there was an unneeded end statement near screen:blit
psphacker12. is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-01-2006, 01:21 PM   #10

sceKernelExitGame();
 
Bronx's Avatar
 
Join Date: Jan 2006
Location: New York
Posts: 3,125
Trader Feedback: 0
Default

what line? you probably forgot an 'end'

and for your other question, I don't see mselectplay in your code, but ti would be someting like this:
Code:
 if mselectplay and pad:down() then
--blit w/e
end
acourse I did say not blit in a if statement, but thats the idea, you should be able t merge it with a finite state machine
Bronx is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-01-2006, 01:25 PM   #11

chaccaron.
 
 
Join Date: Sep 2006
Real First Name: Andrew
Location: England
Posts: 2,615
Trader Feedback: 0
Default

psphacker12 after i used that it said 'end' expected near :16: (eof)
__________________
whyHELLOder.
AndyMosh is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-01-2006, 01:28 PM   #12
likes kittens....awww....
 
Join Date: Sep 2006
Real First Name: Erik
Location: Detroit
Just Played: Call of Duty:World at War
Posts: 628
Trader Feedback: 0
Default

Quote:
Originally Posted by AndyMosh
psphacker12 after i used that it said 'end' expected near :16: (eof)
then try this instead:
Spoiler for *:
Code:
red = Color.new(255,0,0)
green = Color.new(0,255,0)
blue = Color.new(0,0,255)
yellow = Color.new(255,255,0)
purple = Color.new(255,0,255)
play = Image.load("mselectplay.png")
credits = Image.load("mselectcred.png")
score = Image.load("mselectscore.png")
  function delay(seconds)
  time=seconds*60
  for i=1, time do
  screen.waitVblankStart()
  end
end
-- select
while true do
status = 0
screen:blit(0,0,play)
pad = Controls.read()
if pad:cross() and status == 0 then
status = ingame
dofile("game.lua")
end 
if pad:down() and status == 0 then
status = 1
screen:blit(0,0,credits)
screen.flip()
end
if pad:cross()  and status == 1 then
dofile("credits.lua")
end
if pad:down() and status == 1 then
status = 2
screen:blit(0,0,score)
screen.flip()
end
if pad:cross() and status == 2 then
dofile("hiscore.lua")
end
if pad:down() and status == 2 then
status = 0
end
end
psphacker12. is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-01-2006, 01:31 PM   #13

chaccaron.
 
 
Join Date: Sep 2006
Real First Name: Andrew
Location: England
Posts: 2,615
Trader Feedback: 0
Default

Quote:
Originally Posted by Bronx
Don't blit pictures right in a if statement, use a finit state... like for example:
Code:
 blit_credits = 0

if pad:cross() then
blit_credits = 1
end

if blit_credits == 1 then
screen:blit(0,0, "credits")
end
And you shouldn't have the screen.flip() after them either.

And this:
Code:
while true do
screen:blit(0,0,play)
screen.flip()
end
pad = Controls.read()
Should be:
Code:
while true do

//do all if statements in-game stuff here
pad = Controls.read()
screen:blit(0,0,play)
screen.flip()
screen.waitVblankStart()
end
I don't get the blit_credits = 0 part is there a tu on this anywhere?
__________________
whyHELLOder.
AndyMosh is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-01-2006, 01:33 PM   #14
likes kittens....awww....
 
Join Date: Sep 2006
Real First Name: Erik
Location: Detroit
Just Played: Call of Duty:World at War
Posts: 628
Trader Feedback: 0
Default

Quote:
Originally Posted by AndyMosh
I don't get the blit_credits = 0 part is there a tu on this anywhere?
It is just a simple nil variable.
____
(0_o)
-\_/-
--|--
-/-\-
psphacker12. is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-01-2006, 01:33 PM   #15

chaccaron.
 
 
Join Date: Sep 2006
Real First Name: Andrew
Location: England
Posts: 2,615
Trader Feedback: 0
Default

psphacker12 it doesn't matter i will work it out myself
__________________
whyHELLOder.
AndyMosh is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-01-2006, 01:53 PM   #16

sceKernelExitGame();
 
Bronx's Avatar
 
Join Date: Jan 2006
Location: New York
Posts: 3,125
Trader Feedback: 0
Default

If you go over to forums.evilmana.com they are mant threads similiar to this one. I'm sure you will find your answer there
Bronx is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-02-2006, 07:54 AM   #17

chaccaron.
 
 
Join Date: Sep 2006
Real First Name: Andrew
Location: England
Posts: 2,615
Trader Feedback: 0
Default

Edit: Don't want my code sharing, and i figured it out i was ending too soon
__________________
whyHELLOder.

Last edited by Blood; 10-02-2006 at 08:20 AM..
AndyMosh is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-02-2006, 11:29 AM   #18

Developer
 
Join Date: Jul 2006
Posts: 205
Trader Feedback: 0
Default

When you help somebody, please explain what is wrong and what could be done better, don't just give them code to try. For instance, you don't need that delay function. The command screen.waitVblankStart accepts input, so this is the same as yours:
Code:
screen.waitVblankStart(seconds*60)
You already know that you ended the while loop before you read the controls, so I'll just give you some general help. When you're writing code, think about exactly what the code will make the interpreter do. Take the latest code that psphacker posted (I don't know whose code is whose):

Code:
while true do
status = 0
This sets the status to zero at the beginning of each loop...are you sure you want to do that?
Code:
screen:blit(0,0,play)
pad = Controls.read()
You read the controls once each loop, which is good. That's all you should need. But...
Code:
if pad:cross() and status == 0 then
status = ingame
dofile("game.lua")
end 
if pad:down() and status == 0 then
status = 1
screen:blit(0,0,credits)
screen.flip()
end
If you were pressing down when the controls were read, this part sets the status to 1...
Code:
if pad:cross()  and status == 1 then
dofile("credits.lua")
end
if pad:down() and status == 1 then
status = 2
screen:blit(0,0,score)
screen.flip()
end
Which triggers this "if" statement, setting the status to 2...
Code:
if pad:cross() and status == 2 then
dofile("hiscore.lua")
end
if pad:down() and status == 2 then
status = 0
end
Which triggers this "if" statement, setting the status back to 0. So no matter what you do, this code makes doubly sure that you'll never get out of status == 0.

I think a common problem among new coders is that they don't realize how fast the code will run. You don't have a screen.waitVblankStart, which would limit your execution speed to at most 60 loops per second, so this code will go even faster. Stuff like this would only work if you read the controls after each change and you actually had time to react to them, which just isn't realistic.
LMelior is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-02-2006, 11:35 AM   #19

chaccaron.
 
 
Join Date: Sep 2006
Real First Name: Andrew
Location: England
Posts: 2,615
Trader Feedback: 0
Default

Hey dude, thanks i figured it out in the end, Freshmilk is helping me through lua aswell, if i need help he usually knows the answer, so i have done the loading screen menu and credits, now for the game, and i want to know what type of simple skateboarding game would you like? not too complicated though, my first game will hopeflly make a series with the ability to choose decks?
__________________
whyHELLOder.
AndyMosh is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-02-2006, 11:43 AM   #20

Three Years Old
 
Freshmilk's Avatar
 
Join Date: Dec 2005
Location: Ermmm... Pass?
Posts: 2,239
Trader Feedback: 0
Default

i'm touched

lol, im going now, thanks for mentioning me andy.
Freshmilk is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-02-2006, 11:56 AM   #21

chaccaron.
 
 
Join Date: Sep 2006
Real First Name: Andrew
Location: England
Posts: 2,615
Trader Feedback: 0
Default

No problem dude, your a real good friend when helping people
__________________
whyHELLOder.
AndyMosh is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Tags
lua , menu , skateboarding

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -8. The time now is 04:54 AM.



Use of this Web site constitutes acceptance of the TERMS & CONDITIONS and PRIVACY POLICY
Copyright © 2009, QJ.NET. All Rights Reserved.
Contact Us