im a noob!!!!!!!!, need some advice
Moderators: Shine, Insert_witty_name
im a noob!!!!!!!!, need some advice
hi,
i've never coded in my life >_<, and i REALLY want to make a QTE replica of the game in shenmue. if you dont know it, its a simply game with button symbols flashing up on screen, and you press them before they dissapear.
i've read the tutorials i can find, but i dont understand some stuff, i would like for the player to show an image and wait 1 second, and hide the image again. if x is pressed while the image is there then a counter goes up (score), and if any other button is pressed (or no buttons) then a seperate coutner goes down (lives).
ignore me if this is too trivial for this forum.
i can get it to show the image, and make a counter go up when x is pressed, but they are unrelated (and the counter shoots up fast, obviously).
any help would be appreciated.
i've never coded in my life >_<, and i REALLY want to make a QTE replica of the game in shenmue. if you dont know it, its a simply game with button symbols flashing up on screen, and you press them before they dissapear.
i've read the tutorials i can find, but i dont understand some stuff, i would like for the player to show an image and wait 1 second, and hide the image again. if x is pressed while the image is there then a counter goes up (score), and if any other button is pressed (or no buttons) then a seperate coutner goes down (lives).
ignore me if this is too trivial for this forum.
i can get it to show the image, and make a counter go up when x is pressed, but they are unrelated (and the counter shoots up fast, obviously).
any help would be appreciated.
-
- Posts: 123
- Joined: Mon Oct 03, 2005 4:25 am
- Location: Netherlands
Code: Select all
System.sleep(miliseconds)
1 second would be:
Code: Select all
System.sleep(1000)
http://www.lua.org/manual/5.0/
but I think this isn't what you're looking for, since you want luaplayer to check if the x button is pressed while the image is displayed. You need a timer. See this page for timer functions and other luaplayer functions:
http://wiki.ps2dev.org/psp:lua_player:f ... cond_timer
after you created a new timer and started it, you should make a loop that checks the time and if it is greater than 1000, remove the image.
Code: Select all
while timer:time() < 1000 do
pad = Controls.read()
if pad:cross() then
score = score + 1
end
end
screen:clear()
Behold! The Underminer got hold of a PSP
I think you'd be better adding screen.waitVblankStart() inside the loop.
This will pause execution of the PSP until the next cycle. Without this line, you'll be throttling the CPU. Someone correct me if i'm wrong.
Lee
This will pause execution of the PSP until the next cycle. Without this line, you'll be throttling the CPU. Someone correct me if i'm wrong.
Lee
Code: Select all
while timer:time() < 1000 do
pad = Controls.read()
if pad:cross() then
score = score + 1
end
--This will sync each loop to 1/60th of a ms
screen.waitVblankStart()
end
screen:clear()
I could be way off here, but I believe that will only wait as long as it needs until the end of the next clock cycle (1/60th ms), whereas will always wait the specified amount of time (and will also only resolve to a millisecond integer).
Lee
Code: Select all
screen.waitVblankStart()
Code: Select all
System.sleep(miliseconds)
Lee
System.sleep() sleeps the entire system for x ammount of time which means no input can be processed.
So in otherwords thats a no go.
setting up a timer would be the only option you have available for timing each element to a specific event.
Another thing I would introduce is the ability time multiple elements in the script.
which would probably go something like this
More code must be added to this to make it workable but its a general idea of how to use it.
So in otherwords thats a no go.
setting up a timer would be the only option you have available for timing each element to a specific event.
Another thing I would introduce is the ability time multiple elements in the script.
which would probably go something like this
Code: Select all
local timer = Timer.new()
timer:start() // this starts the timer and also gets the seconds. (A bug possibly)
timertable = { }
function timertable_insert(endtime)
// adds a table to timertable (used for loop below)
table.insert(timertable, { timer:start(), endtime })
end
timertable_insert(10000);
while true do
// An endless loop break fixes that
// Keyboard input here.
local mytime = timer:start(); // Gets time
for k,v in timertable do
// gets all the elements of timertable
if (timer:start() > (v[1] + v[2])) then
timertable[k] = nil; // removes the variable from existance
end
end
end
-
- Posts: 123
- Joined: Mon Oct 03, 2005 4:25 am
- Location: Netherlands
Isn't timer:start() the time that the timer was started? So, if I understand correctly, it doesn't get the current time. I don't quite understand why you put that line there.romero126 wrote:Code: Select all
local mytime = timer:start(); // Gets time
By the way, romero, i've got some experience with lua coding now, and part of that is because of you. You really should get an award for all the work you do for noobs :-)
Behold! The Underminer got hold of a PSP