Lua Programming Help Thread
This is a discussion on Lua Programming Help Thread within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; if collision(something,somet hing) then if player.img == something then dosomething else dofile("br.lua") end end...
-
04-22-2007, 09:49 AM #7051QJ Gamer Gold
- Registriert seit
- Aug 2006
- Beiträge
- 1.633
- Points
- 11.629
- Level
- 70
- Downloads
- 0
- Uploads
- 0
if collision(something,somet hing) then if player.img == something then dosomething else dofile("br.lua") end end
-
04-22-2007, 10:04 AM #7052QJ Gamer Gold
- Registriert seit
- Nov 2006
- Ort
- ...
- Beiträge
- 2.080
- Points
- 11.942
- Level
- 71
- Downloads
- 0
- Uploads
- 0
that didnt work
-
04-22-2007, 10:08 AM #7053words are stones in my <3

- Registriert seit
- Jul 2005
- Ort
- Spokane
- Beiträge
- 5.008
- Points
- 35.274
- Level
- 100
- My Mood
-
- Downloads
- 1
- Uploads
- 0
What do you mean by 'the player iamge is different'? If your talking about a powerup for invincibility or shield, use a bool/flag.
Code:if collide(player,object) and shield_on == false then dofile("w/ethisscriptis.lua") end
...at what speed must I live.. to be able to see you again?...
Projects
You can support my Open World 3D RPG for PSP by voting for it here
-
04-22-2007, 10:10 AM #7054QJ Gamer Gold
- Registriert seit
- Nov 2006
- Ort
- ...
- Beiträge
- 2.080
- Points
- 11.942
- Level
- 71
- Downloads
- 0
- Uploads
- 0
can you explain what that shield_on thing is
-
04-22-2007, 01:31 PM #7055QJ Gamer Gold
- Registriert seit
- Aug 2006
- Ort
- Under Your Bed
- Beiträge
- 3.083
- Points
- 12.189
- Level
- 72
- Downloads
- 0
- Uploads
- 0
Zitat von SG57
The shield_on is suppose to be a powerup and if the player and object collide without a shield then it will do a certain file, then you can just add something like if the player and object collide then the player just bounces or whatever away
Zitat von Urameshi
-
04-22-2007, 02:03 PM #7056QJ Gamer Blue
- Registriert seit
- Apr 2007
- Ort
- Relative
- Beiträge
- 135
- Points
- 3.679
- Level
- 38
- Downloads
- 0
- Uploads
- 0
Thank you very much.
Zitat von Merick
I knew it was something stupid, I just didn't think about that since it worked with a loaded image.
-
04-23-2007, 01:26 AM #7057Banned for LIFE
- Registriert seit
- Oct 2006
- Ort
- East London, England
- Beiträge
- 2
- Points
- 18.744
- Level
- 86
- Downloads
- 0
- Uploads
- 0
please can someone give me the collison formula :Argh:
-
04-23-2007, 02:42 AM #7058
Here's the formula from the collision function I'm currently using, I got it from Yaustar's C circle collision function that he posted on Evilmana:
x1,y1 and x2,y2 are the center points of each object image in relation to the screenCode:distanceSquared = (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1) radiusSquared = (rad2 + rad1) * (rad2 + rad1) if distanceSquared < radiusSquared then return true else return false end
rad1 and rad2 are the radius to use for each object, in my version I have it setup to automatically calculate these to be half of whichever side of the object image is the shortest
-
04-23-2007, 02:53 AM #7059Banned for LIFE
- Registriert seit
- Oct 2006
- Ort
- East London, England
- Beiträge
- 2
- Points
- 18.744
- Level
- 86
- Downloads
- 0
- Uploads
- 0
you misunderstood me. I meant ...
Wait i'll quote myself from the previous posts.
Omg i still cant find the post. Anyway it was basiclally that when the player hits the ball the ball goes away at the angle the player came from and then slow down due to friction.Geändert von eldiablov (04-23-2007 um 03:05 AM Uhr)
-
04-23-2007, 03:31 AM #7060
well, you could try something like this :
xspeed = 5, (or whatever)
yspeed = 7
(current speed at which the player is moving)
after collision, you would change the ball position each cycle like this:
ballspeed = 5
ball.x = ball.x + (xspeed * ballspeed)
ball.y = ball.y + (yspeed * ballspeed)
ballspeed = ballspeed - .3 (or whatever)
if ballspeed <=0 then ball stops
-
04-23-2007, 04:29 AM #7061QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Done: http://www.gamasutra.com/features/20...lander_pfv.htm
Zitat von eldiablov
[Blog] [Portfolio]
[Homebrew Illuminati - Serious Homebrew Development Forums]
[I want to make Homebrew FAQ] [How I broke into the Games Industry]
[Programming Book List] [Programming Article List]
-
04-23-2007, 04:48 AM #7062Banned for LIFE
- Registriert seit
- Oct 2006
- Ort
- East London, England
- Beiträge
- 2
- Points
- 18.744
- Level
- 86
- Downloads
- 0
- Uploads
- 0
ok yaustar. I'l try that when i get home because that sites blocked on this computer.
-= Double Post =-
BAH now my head hurts again. These formulas aren't at all simple :Argh:Geändert von eldiablov (04-23-2007 um 08:15 AM Uhr) Grund: Automerged Doublepost
-
04-23-2007, 02:05 PM #7063
i have downloades TTlde 2.1 and wen im traying to run it i ever got this error
error: ttlde.lua:10: module 'pad.lc' not found:
no field package.preload['pad.lc']
no file './pad/lc.lua'
no file '/usr/local/share/lua/5.1/pad/lc.lua'
no file '/usr/local/share/lua/5.1/pad/lc/init.lua'
no file '/usr/local/lib/lua/5.1/pad/lc.lua'
no file '/usr/local/lib/lua/5.1/pad/lc/init.lua'
no file './pad/lc.so'
no file '/usr/local/lib/lua/5.1/pad/lc.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
no file './pad.so'
no file '/usr/local/lib/lua/5.1/pad.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
can some one tell me hor to make this works.. this hapen on lpwindows. and psp
my psp is 3.10 oe a'
-
04-23-2007, 02:41 PM #7064QJ Gamer Blue
- Registriert seit
- Jul 2006
- Beiträge
- 132
- Points
- 4.296
- Level
- 41
- Downloads
- 0
- Uploads
- 0
hi i am useing PSP Game Maker v 0.7 but i have a prob. I need to kno where to put my files, like my pic and sound filkes where do i put them? pls help =)
-
04-23-2007, 02:44 PM #7065
Just put them in the same directory as the lua script file that uses them.
-
04-23-2007, 04:41 PM #7066
Zitat von eldiablov
it might help you.
Zitat von eldiablov
in your ballupdate function use:Code:if colide(player,ball) then ball.angle = player.angle ball.speed = player.shutpawer end if
i think this culd help you.. when i do somthing whit angle i thibk is betther to calculate the next x y whit sin cos angle * speed. this is good.. now you just need to see the limist of the x and y i think you can figure out how to do that. else. fell fre to ask. im glad of helping.....by the wai i write this code here it might have some errors. but tis the logic what you need.Code:function updateball() ball.x = ball.x + math.sin(ball.angle)*ball.speed ball.y = ball.y + math.cos(ball.angle)*ball.speed if ball.speed > 0 then ball.speed = ball.speed-friction --the ball continues and lose speed. else ball.speed = 0 --the ball stops end end
-
04-23-2007, 05:45 PM #7067QJ Gamer Blue
- Registriert seit
- Jul 2006
- Beiträge
- 132
- Points
- 4.296
- Level
- 41
- Downloads
- 0
- Uploads
- 0
um can someone help me with my code
red = Color.new(255, 0, 0)
background = Image.load("images/background.jpg")
screen
rint(200, 100, "Look! I made text appear!", red)
screen.flip()
while true do
screen.waitVblankStart()
end
i cant get the image to load. Its my first time codeing so i dont kno wats wrong. Can someone pls help me.
-
04-23-2007, 06:13 PM #7068QJ Gamer Green
- Registriert seit
- Dec 2006
- Ort
- main();
- Beiträge
- 1.071
- Points
- 11.300
- Level
- 70
- Downloads
- 0
- Uploads
- 0
You never blit the image. I'm sure it loads, though.
Code:red = Color.new(255, 0, 0) background = Image.load("./images/background.jpg") while true do screen:clear(Color.new(0, 0, 0)) --may be wrong function name :| screen:blit(0, 0, background, true) screen:print(200, 100, "Look! I made text appear!", red) screen.waitVblankStart() screen.flip() endGeändert von PSPJunkie_ (04-25-2007 um 11:43 AM Uhr)
-
04-23-2007, 06:26 PM #7069QJ Gamer Gold
- Registriert seit
- Nov 2006
- Ort
- ...
- Beiträge
- 2.080
- Points
- 11.942
- Level
- 71
- Downloads
- 0
- Uploads
- 0
Zitat von cruisx
Code:red=Color.new(255,0,0) background=Image.load("./images/background.jpg") while true do screen:clear() screen:blit(0,0,background) screen:print(200, 100, "Look! I made text appear!", red) screen.waitVblankStart() screen.flip() end
-
04-23-2007, 06:29 PM #7070QJ Gamer Green
- Registriert seit
- Dec 2006
- Ort
- main();
- Beiträge
- 1.071
- Points
- 11.300
- Level
- 70
- Downloads
- 0
- Uploads
- 0
.......
Zitat von PSPJunkie_
????
Zitat von Urameshi
-
04-24-2007, 01:02 AM #7071QJ Gamer Blue
- Registriert seit
- Jun 2006
- Ort
- Tokoroa, New Zealand
- Beiträge
- 103
- Points
- 4.412
- Level
- 42
- Downloads
- 0
- Uploads
- 0
At least Urameshi's code works. You didn't even check yours lol.
-
04-24-2007, 09:31 AM #7072Banned for LIFE
- Registriert seit
- Oct 2006
- Ort
- East London, England
- Beiträge
- 2
- Points
- 18.744
- Level
- 86
- Downloads
- 0
- Uploads
- 0
Thank you soooo much
Zitat von ahrimanes

But where do you define ballpower?
-
04-24-2007, 11:56 AM #7073QJ Gamer Green
- Registriert seit
- Dec 2006
- Ort
- main();
- Beiträge
- 1.071
- Points
- 11.300
- Level
- 70
- Downloads
- 0
- Uploads
- 0
And? It was the exact same thing... @[email protected]
Zitat von romulator
-
04-24-2007, 02:41 PM #7074
there is not ball power. just ball speed, that increases when the player touch it, and decreaces by friction every loop.
Zitat von eldiablov
i mybe worng calling.. ball.speed = player.shutpawer... i must bee
ball.speed = player.pushforce.. since is not theplayer shuting the ball but driving it..well any question are wellcome .
-
04-24-2007, 02:46 PM #7075
eldiablov:
when the ball collides (with another ball), make sure the angle you give it isn't just player.angle.
that will only work if the collide straight on. If you hit it at more of an angle, you will need some formula for that. If you need help with that, i could figure it out later.
-= Double Post =-
lol, i kind of want to make a pool game now.Geändert von emericaska8r (04-24-2007 um 02:48 PM Uhr) Grund: Automerged Doublepost
-
04-24-2007, 03:01 PM #7076
he is making a soccer game, i dont think he need ball colision formula :)
-
04-24-2007, 03:43 PM #7077
lol my bad, i thought he was making a pool game, sorry. :o
-
04-24-2007, 03:51 PM #7078
if you still want to do the pool game i have a ball collide script i made in blitzmax. it will be easy to port to lua. if you wanna try ...tell.....
Zitat von emericaska8r
-
04-24-2007, 05:47 PM #7079QJ Gamer Blue
- Registriert seit
- Jul 2006
- Beiträge
- 132
- Points
- 4.296
- Level
- 41
- Downloads
- 0
- Uploads
- 0
You know how you can move back and forth through pics in the psp XMB by pressing R and L. Well is their any way to do this in lua? like by pressing R u go to the next pick and pressing L u go back to the previous pic?
-
04-24-2007, 06:05 PM #7080
sure ahrimanes, thanks.


LinkBack URL
About LinkBacks
Mit Zitat antworten

Hello everyone I am new here and I am glad to be part of this amazing community and I think there...
New to forum