![]() |
| Forums | Gaming News | Videos | Downloads | Today's Posts | Mark Forums Read | Chat | FAQ | Members List | Contact |
| ||||||
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 ...
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 |
![]() ![]() chaccaron.
![]() |
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
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() Please help i really want this game to work and then i might make a series
__________________
whyHELLOder. |
|
|
|
|
|
#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
|
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
|
|
|
|
|
|
#3 |
![]() ![]() sceKernelExitGame();
|
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 this: Code:
while true do screen:blit(0,0,play) screen.flip() end pad = Controls.read() 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
__________________
|
|
|
|
|
|
#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
|
Quote:
|
|
|
|
|
|
|
#5 |
![]() ![]() sceKernelExitGame();
|
oops.... lol, haven't programmed in la for awhile
, just natural now
__________________
|
|
|
|
|
|
#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
|
Quote:
Spoiler for Code:
|
|
|
|
|
|
|
#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
|
Quote:
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
|
|
|
|
|
|
|
#10 |
![]() ![]() sceKernelExitGame();
|
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
__________________
|
|
|
|
|
|
#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
|
Quote:
Spoiler for *:
|
|
|
|
|
|
|
#13 | |
![]() ![]() chaccaron.
![]() |
Quote:
__________________
whyHELLOder. |
|
|
|
|
|
|
#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
|
Quote:
____ (0_o) -\_/- --|-- -/-\- |
|
|
|
|
|
|
#16 |
![]() ![]() sceKernelExitGame();
|
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
__________________
|
|
|
|
|
|
#18 |
![]() ![]() Developer
|
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) Code:
while true do status = 0 Code:
screen:blit(0,0,play) pad = Controls.read() 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
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
Code:
if pad:cross() and status == 2 then
dofile("hiscore.lua")
end
if pad:down() and status == 2 then
status = 0
end
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. |
|
|
|
|
|
#19 |
![]() ![]() chaccaron.
![]() |
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. |
|
|
|
|
|
#20 |
![]() ![]() Three Years Old
|
i'm touched
![]() lol, im going now, thanks for mentioning me andy. |
|
|
|
![]() |
| Tags |
| lua , menu , skateboarding |
| Thread Tools | |
|
|