Is there a gravity code for lua example:
a ball that goes up at 10 velocity and starts to slow down ,when it reaches zero it starts to go down and speeds up.
Printable View
Is there a gravity code for lua example:
a ball that goes up at 10 velocity and starts to slow down ,when it reaches zero it starts to go down and speeds up.
Zitat:
Zitat von shadow-evillink
you should just develop a code yourself so you can customize it the way you want...
http://www.google.com/search?hl=en&l...th%27s+gravity
http://www.evilmana.com/tutorials/lu...et_jumping.php
but that should get you started! ;D
Gah, I still need help making objects fall down the screen :dry:
Download the attached file!Zitat:
Zitat von MaSt3r_ShAk3
I used a 10x10 image which will fall from a random x location from the top of the screen to the bottom. Press X to pause the spike MID-AIR ;P
HTH
can someone give me an example animation? How do i make it so when you press X, it starts, looping forever, and when you press X it stops. Then when you press X again it starts again and so on.
THANK YOU! *bows*Zitat:
Zitat von califrag
Humm, how can i make an scrolling screen? (like when you go forward it scrolls with you and if theres objects like then they move/appear too :P)
(making smw game :P )
And also, how can i create a menu with mouse arrow replaced with an hand icon thingy, and also, if i click x while the arrow/hand is over the button, it does some function and menu dissapears(and goes to game of course :P )?
click "search this thread"Zitat:
Zitat von Greenskull
How would I have a function loop forever?
Okay this is pissing me off... I test the script in luaplayerwindows and nothing happens. It starts but its just a black screen...
Pllease post you code :D
Its good I messed around and fixed it but I get the [colo=Black]****ING LOOP IN GETTABLE NOW[/black] on the lines with "--Loop In gettable" next to emAnd the stick.x stuff has to be like that otherwise the player wont moveCode:black = Color.new(0,0,0)
red = Color.new(255,0,0)
stick = {}
stick.x = 240
stick.y = 200
life = 1
coll = 0
y = 0
speed = 3
spike = Image.load("spike.png")
bg = Image.load("background.png")
death = Image.load("death.png")
stick = Image.load("stick.png")
math.randomseed(os.time())
x = math.random(480 - spike:height())
while true do
screen:clear()
screen:blit(0, 0, bg, false)
screen:blit(stick.x, stick.y, stick) --Loop in gettable
pad = Controls.read()
screen:print(0, 240, "Speed: " .. speed, black)
screen:blit(x, y, spike)
if not paused then
screen:print(0, 250, "UNPAUSED", black)
y = y + speed
if y + spike:height() >= 272 then
screen:print(x, y - 10, "OUCH!", red)
y = 0
x = math.random(480 - spike:height())
screen.flip()
System.sleep(2000)
end
else
screen:print(0, 250, "PAUSED", red)
end
if pad:cross() and pad ~= oldpad then if paused then paused = false else
paused = true end end
if pad:up() and pad ~= oldpad then speed = speed + 1 end
if pad:down() and pad ~= oldpad then speed = speed - 1 end
if pad:left() and pad ~= oldpad then --Loop In gettable
stick.x = stick.x - 2
end
if pad:right() and pad ~= oldpad then -- Loop in gettable
stick.x = stick.x + 2
end
oldpad = pad
screen.flip()
screen.waitVblankStart()
end
LUA PLAYER BUG?
If you do like this:
It obviously plays the bgsound.Code:if BGSoundTimer >= 1 then
BGSound:play()
BGSoundTimer = 0
end
But if you have any other sound that starts exactly when "BGSound" stops, then BGSound just stop looping, just stops.
It drives me nuts, because i really want to finnish my game!
Why don't you useZitat:
Zitat von MaSt3r_ShAk3
That might fix the problem.Code:if pad:right() and
oldpad:right() ~= pad:right() then
stick.x = stick.x + 2
end
i still get the error for theCode:screen:blit(stick.x, stick.y, stick) --Loop in gettable
i'm getting loop for gettable with...
Code:monster = Sound.load("sounds/monsterkill.wav",false)
voice = monster
monster:stop() -- this gives loop gettable thing
luaplayer dosnt understand what monster means because monster is not a command.Zitat:
Zitat von Rixorster
He assigned monster to the sound he loaded
ok, this is getting annoying. i keep trying to make start resart the game im working on, nad every time i get
no loop to break near end
and my code is this
if pad:start() then
break
end
ive tried it withall versions .10 and up, and ive tried it with all buttons. plz help
ps. does ne one know where to get lua player 0.09?
That's because there is no loop to break.Zitat:
Zitat von qwerty
i rather would use:
To refresh the program, while creationg something in lua.Code:if pad:start() then
dofile "index.lua"
end
Theres just something i need to clarify.
If i do a dofile, does my application retain all the variables, arrays etc from the other file?
Yes it does.Zitat:
Zitat von Gutya
Thanks mate.
P.S. Haha, just noticed the sig. :D
thanks, I see what I can do.Zitat:
Zitat von califrag
I did. Nobobdy gave any examples lkike that.Zitat:
Zitat von califrag
Nobody has been able to help me.....I am dissapointed in this thread....
Hey, can someone help me with a couple of things?
If someone were to make a game in lua, ex. a fighting game , how would one go on about it. I've read the tutorials provided by whitehawk, they've helped alot but im looking for something a bit more complicated. How would you make it so that when your press a button, such as X, an animation plays?
something like this?
if pad:cross then
screen:blit(30, 120, punchR)
screen.flip()
end
except the character is actually executing the animation so that the location is not needed but it is where the character is, how would I do that, make it so that the character image changes to the animation, at his position? Then back?
Also How would you make your character move at a constant rate when you hold down a button and stop when you release? Would you have a command that if the button is pressed the character moves X amount of pixels right or left ect, depending on the button and then it stops when the button is released? If so, what is the command?
Finally how would you make it so that when an animation is played, if the opposing character is in range (right next to you) that the animation changes from just playing the animation but to another one where the opposing character is hit and his life goes down, an if command? If character is in range, play animation punchedR new line health - 20?
Thanks for your help
Andrey
Edit: One last thing, how would you make that if you have an image (background) and your moving in it, when you reach the end of the screen it keeps moving. Like a long image horizantle that you keep moving through then at the end when you touch a certain object it takes you to the next image, (background/level).
how would you do a sidescrolling screen? such as when your sprite reaches the end of the screen (or the middle) it scrolls with him
I would also like to know EVERYTHING you just said.Zitat:
Zitat von Andrey
I found this in teh internet :PZitat:
Zitat von mannymix03
Code:--load the images
layer = {
buffer = Image.createEmpty(480, 272)
}
slicesize=500
slices = {
Image.load("slice1.png"), --500x272px
Image.load("slice2.png"), --500x272px
Image.load("slice3.png") --500x272px --images are at his site
}
-- 0..1500
shade = {
start=0,
ende=480
}
drawslices = 0
function limited(val)
val = math.ceil(val/501)
if val>table.getn(slices) or val==0 then
return 1
end
return val
end
-- correct this value
while not Controls.read():start() do
shade.ende = shade.ende+1
shade.start = shade.start+1
if shade.ende>=1500 then
shade.ende=0
end
if shade.start>=1500 then
shade.start=0
end
--move the background to left
layer.buffer:clear()
drawslices = slicesize-math.mod(shade.start,slic esize+1)
layer.buffer:blit(0,0,sli ces[limited(shade.start)],math.mod(shade.start,sli cesize+1),0,drawslices,27 2)
layer.buffer:blit(drawsli ces,0,slices[limited(shade.ende)],0,0,math.mod(shade.ende, slicesize+1),272)
layer.buffer:print(25, 100,shade.start ,Color.new(255,0,46))
layer.buffer:print(25, 110,shade.ende ,Color.new(255,0,46))
-- update screen
screen:blit(0,0,layer.buf fer)
screen.flip()
end
For those interested more in lua, here is a tutorial which i think covers animation. Its http://wiki.ps2dev.org/psp:lua_player:tutorial it starts out with the hello world but talks about animation and a couple of other things, hope ya find what you need.
Going to read it now
Hey people, I jsut wanted to ask if anyone knew why some music in a gmae like BME would be disorted? It honestly is totally screwed, only plays a deep sound.
how do i do to make a game compatible with the analog stick?? please help!
Look at PSPGuitar, it uses analog stick.
I learned to do analog controls from this post,,Zitat:
Zitat von madsoul
Zitat:
Zitat von monster356
1. Thats Lumo's scrolling example, so i ask you, whyd you edit out his name and comments at the very top huh?Zitat:
Zitat von Rixorster
2. That is a very good scrolling example except copying and pasting doesnt help you. You wont learn anything, nor if someone hoping to learn from your code will either, that is why its fairly important youeither make it yourself, or fully comment that scrolling example.
My opinion ^
EDIT
Oh and FLai, you just spammed again, nice work! WWAAYY off topicc, and no use, should have PMd me, not post it here to get 1 + post count... Your on a roll today!! w00t w00t, tread cautiously
SG57, i found it in psplua.com, don't blame me <.< there were no credits there o_o
Is there like a basic quit command?
Like
if bla then
quit
end
what can i use?
"break" is the basic quit command. It should break the loop and bring you back to lowser. So for example:Zitat:
Zitat von Gutya
Code:if pad:start() then
break
end
What if your not loading it in Lowser? What if its with an eboot?
And also i tried that, but it doesnt seem to work in a function.