I already answered your question before! Right under your post. :(Zitat:
Zitat von Vaza
Here is the link to the post...http://forums.qj.net/showpost.php?p=...postcount=1190
Printable View
I already answered your question before! Right under your post. :(Zitat:
Zitat von Vaza
Here is the link to the post...http://forums.qj.net/showpost.php?p=...postcount=1190
ok i need help i got my pictures to load but it keeps on flashing rapidly could someone help me thx
Math.Random keeps selecting the same
place, how could i get it so it changes everytime
you play? Its annoying because i am creating a small
game "Pairs" But they keep getting put in the same place?
Likely you need to create a seed, using the PSPs timekeeping functions. Check out this excerpt from a LUA tutorial site.
http://www.lua.org/pil/18.html
Zitat:
The math.random function generates pseudo-random numbers. We can call it in three ways. When we call it without arguments, it returns a pseudo-random real number with uniform distribution in the interval [0,1). When we call it with only one argument, an integer n, it returns an integer pseudo-random number x such that 1 <= x <= n. For instance, you can simulate the result of a die with random(6). Finally, we can call random with two integer arguments, l and u, to get a pseudo-random integer x such that l <= x <= u.
You can set a seed for the pseudo-random generator with the randomseed function; its only numeric argument is the seed. Usually, when a program starts, it initializes the generator with a fixed seed. That means that, every time you run your program, it generates the same sequence of pseudo-random numbers. For debugging, that is a nice property; but in a game, you will have the same scenario over and over. A common trick to solve this problem is to use the current time as a seed:
math.randomseed(os.time() )
Thanks! :DZitat:
Zitat von Psilocybeing
That was very eductional!
EDIT:
My program doesnt work now?
x2=math.randomseed(os.tim e())
y2=math.randomseed(os.tim e())
It says:
Calling `blit' on bad self.
Thanks PSPHax0r9 and C5cha7, both methods work great.
In between what numbers does math.randomseed(ostime()) come up with? if it is unlimited, how can you make it seed between certian numbers, and not in decimals?
Now i am completley confused.... :(Zitat:
Zitat von Vaza
I just want it to pick a certain number at random..
But all this is confusing me now :( ..
Well I think it seeds unlimited, which is what you want. When you go to pick the random number with math.random(), do math.random(6) or math.random(1,6) . In the parenthesis you can write between what numbers you want it to choose a random whole number. IF you just write one number, it defaults to choosing any number between zero and that number. Otherwise you can specify where you want it o choose in between with a comma, such as with math.random(1,6) it will choose a random whole number between one and six. Hope that helps.Zitat:
Zitat von Vaza
For some reason though, it always comes up with the number 1, i have:Zitat:
Zitat von PSPHax0r9
BGMUSIC = math.random(1, 6)
if BGMUSIC == 1 then
Music.playfile("BGMUSIC1. xm", true)
end
and it goes on for 6 different song files.
is there any way to sort it out?
errr c5cha7, post ur code, thats saying that ur blitting a nil image, so show what ur blitting with the code, ill see if i can help, its unlikely though
I doubt he wants to post his code, since he's so far with his game, but you're right about the error. You probably changed something that had something to do with an image aswell. maybe you reused those x2 and y2?
yea, i meant just post the small bit of code, but you see what i mean now
Small code snippets:
x2=math.randomseed(os.tim e())
y2=math.randomseed(os.tim e())
screen:blit(x2, y2, blueimg)
And thats about all that use's the x2 and y2?
Maybe its cause i am emulating it on the PC?
Or should it still work?
...
You do realise that the random seed isn't a random number? You get a random number using "math.random" AFTER SETTING a random seed.
Oh... Now you guys tell me that :o ..Zitat:
Zitat von TheEmulatorGuy
I Bet you all just wanted me to look more stupid :icon_razz .
But thanks!
Yer cos only 2 out of 40 000 people like u, lol. Hey, wait, that includes me! :surprisedZitat:
Zitat von c5cha7
Hopefully i will make some chao friends :icon_razz ...Zitat:
Zitat von Vaza
And i got it working!
Thanks for your help everyone!
And my two bestest buddys lol..
So thats... How many petscan u have it that game? 1 or 2? ok, 4 out of 40 000, a huge improvement :sarcasm: LOL J/K Good Luck Mate. Keep Up the good work.Zitat:
Zitat von c5cha7
Hey everyone, I have a quick question.
How does the "bool voice:playing()" work? Everytime I try to use it, I get a nice "loop in getable" error....
this is a bit confusing to explain, but i want a way,
when the timer has started, and when a button is pressed, to record the time of the timer at the time the button was pressed, in another file like this
file = io.open("test.lua","a")
file:write("\n[whatever the time is]")
file:close()
how would i do that?
How do you make an animation in lua? Can you use gifs or what?
Here read this:
http://wiki.ps2dev.org/psp:lua_player:tutorial
file = io.open("test.lua","a")Zitat:
Zitat von Sousanator
pad = Controls.read()
if pad:start() then
file:write(os.time())
end
file.close()
but would that work with a timer,
i though os.time was the clock?
Can anyone get the voice:playing() function working?
ok i think I get it but how do you make it so multiple pictures are used to create an animation?Zitat:
Zitat von Altair
Correct, use multiple png images, then use a timer to display them.Zitat:
Zitat von Greenskull
can someone give an example of how to make a 3 picture smilie animation? I want him to talk.
Well, if you want each frame of the smilie to last for 8 milliseconds, you'd do this:
[HTML]
frame_1 = Image.load("frame_1.png")
frame_2 = Image.load("frame_2.png")
frame_3 = Image.load("frame_3.png")
screen:clear()
while (true) do
--Put image to memory and flip it to screen
screen:blit(0, 0, frame_1)
screen.flip()
--Keep frame showing for 8 milliseconds
screen.WaitVblankStart(8)
--Clear screen to start over
screen:clear()
screen:blit(0, 0, frame_2)
screen.flip()
screen.WaitVblankStart(8)
screen:clear()
screen:blit(0, 0, frame_3)
screen.flip()
screen.WaitVblankStart(8)
screen:clear()
end
[/HTML]
There's probably an error in there somewhere, but that should be a fair idea of how you do it.
hey could someone help me out of this rut, i need a projectile type code so when i shoot i can move around but the bullet keeps on going straight, does anyone know what im talking about if so could u help me out thx :icon_bigg
Zitat:
Zitat von Greenskull
Zitat:
Zitat von youresam
ok i'll kill two birds with one stone!:
Add or remove images/sounds as needed! Adjust the timer:time()'s to the lengths of the wav files in milliseconds! HTH!~Code:sounds = {}
sounds[1] = Sound.load("sound1.wav")
sounds[2] = Sound.load("sound2.wav")
sounds[3] = Sound.load("sound3.wav")
smilies = {}
smilies[1] = Image.load("smilie1.png")
smilies[2] = Image.load("smilie2.png")
smilies[3] = Image.load("smilie3.png")
timer = Timer.new()
while true do
timer:start()
if timer:time() > 0 and timer:time() <= 1000 then
screen:blit(50, 50, smilies[1])
sound = sounds[1]
if not sound:playing() then voice = sound:play() end
elseif timer:time() > 1000 and timer:time() <= 2000 then
screen:blit(50, 50, smilies[2])
sound = sounds[2]
if not sound:playing() then voice = sound:play() end
elseif timer:time() > 2000 and timer:time() <= 3000 then
screen:blit(50, 50, smilies[3])
sound = sounds[3]
if not sound:playing() then voice = sound:play() end
elseif timer:time() > 3000 then
timer:stop()
timer:reset()
end
screen.flip()
screen.waitVblankStart()
end
Then ill take down the last one :P
@Mr.Game
Usae different x/y coordinates for your projectile and your playercharacter. Lets say x and y for the player and xp and yp for your projectile.
This is only for one bullet though and if you press cross again while its not yet gone then it will "jump". But this should give you an idea.Code:if pad:cross() then
xp=x
yp=y
shoot = 1
end
if shoot==1 then
xp=xp+5 -- 5 is the speed so if you want it to go faster take a bigger number
end
You should check PSPMillionair's tutorials. Theres also one about multiple projectiles.
damn, i was gonna answer that one. And it was ALMOST identicle!!
By the way you'll catch up with me post wise cos i wont be on much till 15th April!!!!!!!!
whaaaaa, racing and moving house, im 13 lol, my dad races not me!
I Seen a tutorial once and it told me something about
the oldpad function, i wanna use the function cause
everytime i press "X" at the menu it will loop very fast...
Please help lol.
ok thx Altair ;)
Ill help u out, check ur PMsZitat:
Zitat von c5cha7
Have you tried that code? I'm not asking how to USE IT, but why it gave me an error when I called it.Zitat:
Zitat von califrag
ok cool. how do you make it loop?Zitat:
Zitat von TheEmulatorGuy
eeehhm ... it is in a while loop so it loops already
make sure your wav is mono not stereo. also i think it has to be less than 44khzZitat:
Zitat von youresam