@frost np anytime
@game you need to set up a direction system where it well move the ball based on it's current direction just make a simple variable called direction then based on the way the ball hits adjust the direction and so on and so forth
Printable View
@frost np anytime
@game you need to set up a direction system where it well move the ball based on it's current direction just make a simple variable called direction then based on the way the ball hits adjust the direction and so on and so forth
"@game you need to set up a direction system where it well move the ball based on it's current direction just make a simple variable called direction then based on the way the ball hits adjust the direction and so on and so forth
"
Issn't that exactly what I said? Anyways, by direction system I mean this:
Add a variable called "d"or "direction" to the table for the ball. However, since the ball will be moving diagonally, you need to use two variables. For this ill use d1 and d2. The number on the endof the direction indicates how fast the ball should go when it is going that direction.
Then to make the ball move do something like:
if ball.d == u1 and ball.y > 0 then
ball.y = ball.y - 1
elseif ball.d == u2 and ball.y > 0 then
ball.y = ball.y - 2
end
And then do that for however many you want each direction. The ball will move differently depending on what and how high its two directions are. Then for changing the ball's directions, make some formulas and then do something like
if collision then ball.d1 = something ball.d2 = something end
The something in there can be determined by a ricochet formula which I'll leave youto figure out.
whats the name of the file of that script. it should be "index.lua". if thats not the problem then come back.Zitat:
Zitat von savagefreak
oh, to have luaplayer for windows display the error you have to do this:
right-click the "test" file. its a "Windows NT Command Script". (hover the mouse over the file to see it)
Edit it.
it should open and say "luaplayer index.lua"
just go down one line (hit enter) and type "pause". then save. done!
Zitat:
Zitat von -TacticalPaper-
its not called that but here is the basic formula:
when you have a rounded object, that hits against a flat surface, your incoming angle is that angle between an imaginary perpendicular (which is drawn straight up from the point of collision), and the path of the object. your path of "reflection" (im using wave terminology) is equal to the incoming angle. a picture to help:
http://img295.imageshack.us/img295/8896/untitledhz7.jpg
so basically, you will have to use trig (sin and cos) to have a perfectly simulated game. but, no one cares that much, thankfully.
i made my own simple pong game, and i just had two variables for the x and y values of the ball's slope, and another variable for the speed.
when the ball collides, just think about where it is going next, and it is easy to figure out what the new slope must be
Anyone know whats wrong with this?
Zitat:
if (housex + house:width() > packx) and (housex < packx + pack:width()) and (housey + house:height() > packy) and (housey < packy + pack:width()) then
score = score + 1
end
I don't see anything wrong, but sometimes I miss things. If I were you, I would use the evilmana tutorilas. It teaches you how to make a function, so you don't need to write dozens of if statements.Zitat:
Zitat von Yongobongo
Its probably because hes using housex when it should be house.x and house.img:width()
how would u make a racing game in lua? im confused on how.... want to make one after playing some racing games i was inspired lol. you would need like speed variable and acceleration but im not quite sure how to make it can someone give a quick example.
u mean 3d racing game like wedge racer??
Zitat:
Zitat von Yongobongo
Using width for a y axis check? Should be height.Code:housey < packy + pack:width()
For a racing game and a speed variable, something like:
Theres a basis for ya. Just dont forget to make a reverse!Code:player = { x = 0, y = 0, img = Image.load("player.png"), d = u }
speed = 0
if pad:cross() and speed > maxspeed then
speed = speed+1
elseif pad:square() and speed > 0 then
speed = speed - 3
end
if speed < 0 then speed = 0 end
if player.x > 472 - player.img:width() and player.d == r then
player.x = player.x + speed
end
if player.x > 472 - player.img:width() then player.x = 472 - player.img:width()
ok thanks its late right now but ill look into that tomorrow il... put u in the credits or something lol.
EDIT: nvm i dont feel like doing spanish 2 homework right now lol.
Ok, my game is nearly done, yay! But I want to be able to fire something more then once, like so if i fire eg. a bullet it doesnt just get rid of it and fire another on from the starting point?
Yongobongo, what are you trying to say?
How can I fire multiple bullets, basically :)
http://www.evilmana.com/tutorials/lu...et_bullets.phpZitat:
Zitat von Yongobongo
That should work. If not, I can probably help you.
Yep and if 5 isnt enough just edit it a little to have more, but keep it to as few as possible.
i need to know how to clear up RAM. my game switches between scripts alot and i just got to the point where i now need to load...alot of stuff and need more space cause i dont want for it to lag...
imageyouloadedbeforethaty ounolongerneed = nil
asnotherimageyoupreviousl yloadedthatyounolongernee d = nil
imagethatyounowneed = Image.load("image.png")
Also, make sure your code isn't wasting your PSP's cpu or anything, just go through it and check for better ways of doing things and unneccessary things.
just calling them "nil" does that?
that just sounds too easy...ok!
Yea just make sure there arent multiple vcalues usin the same image. Making the m nil just redefines them as undefined and with an image sitting undefined and unused in the ram, it gets dumped out.
is there a site that says what all teh lua error messages mean so i can understand where i made my error?
That is what the line number in the error messages are for. Most of the errors are straight forward, others will require you to mentally step though the code to find your error. I also find that with scripts in general (weakly typed and usually with no debuggers) Hungarian Notation helps a lot especially during code maintenance and expansion.Zitat:
Zitat von cheese the psp
great now i got rid of the errors and now it just freezes the psp
what can cause that to happen?
Overflowing the stack, infinite loops are the immediate two that comes to mind.
waht does <eof> mean?
End of file. Generally it means you need to go through and check that you ended all of your loops and ifthens.
I used to get that message all the time until I realized that my pc took longer than 2 seconds to transfer over the files. First you will see the memstick light blink then about 10 seconds later it will blink again, then you can disconnect it.
i cant seem to get this to workZitat:
Zitat von code
this is teh menu
You need to put all your screen:prints and screen:blits inside your main loop, since you have a screen:clear() in your main loop. If you put them before the loop, they will just get wiped away by the screen:clear().Zitat:
Zitat von cheese the psp
there...Zitat:
Zitat von code
now it just freezes with loading on the screen
Zitat:
Zitat von cheese the psp
you dont have a "while true do". try this:
Code:System.usbDiskModeActivat e()
black = Color.new(0,0,0)
green = Color.new(0,255,0)
white = Color.new(255,255,255)
screenrint(120,140,"loa ding...",white)
screen:flip()
bg = Image.load("background.pn g")
current = 1
while true do
pad = Controls.read()
screen:clear()
if current == 1 and pad:cross() then
do file("game.lua")
end
if current == 2 and pad:cross() then
dofile("help.lua")
end
if current == 3 and pad:cross() then
dofile("credits.lua")
end
screen:blit(0,0,bg)
screenrint(120,140,"pla y game",black)
screenrint(120,150,"Con trols",black)
screenrint(120,160,"Cre dits",black)
screen:flip()
if current == 1 then
screenrint(120,140,"pla y game",green)
end
if current == 2 then
screenrint(120,150,"Con trols",green)
end
if current == 3 then
screenrint(120,160,"Cre dits",green)
end
if pad:up() and oldpad:up() ~= pad:up() then
current = current - 1
end
if pad:down() and oldpad:down() ~= pad:down() then
current = current + 1
end
if current == 4 then
current = 1
end
if current == 0 then
current = 3
end
screen.waitvblankStart()
screen.flip()
oldpad = pad
end
then i get an error message saying i need an end for teh 'while'
in "while true do"
where would i put this end?
btw thanks for all your help
I believe since you have a main loop, You have to put the end to end your loop, Or else it will just keep repeating the loop, I think thats right???
the point of a loop IS to repeat. the "end" just puts limits on HOW MUCH you want to repeat every frame.Zitat:
Zitat von pspgamer81
Ah, Yea ok!:p:p:p:p
Stickied!:p
God... now i finnaly got the ball to work with collosion in my ping pong game, thanks to Guitargod..
BUT! (Damm, there's always a but) At the start of the game, the ball is just blitted, and signed as an object, but i need it to move when the game starts!
(Yeah, i know nothing... *sniff*) So what should i write before the game loop, and what do i have to write?
I think my grammer is pretty wrong in this post. Oh well.
Just setup the direction system like I showed you and make the ball start out with a direction and then move the ball based on its direction.