Hard Light Productions Forums
FreeSpace Releases => Scripting Releases => Topic started by: Nuke on July 10, 2006, 06:24:08 pm
-
put this in scripting.tbl and load a mission
btw this assumes youre running in a resoltuin more than 1024 * 768, i might update it later to sopport lesser resolutions.
btw the mouse controls the paddels, an axis for each, so you might want to turn off mouse flight, that is unless you want to play pong and fight shivans at the same time :D
#Global Hooks
$GameInit:
[
--HudPong (tm)
w = gr.getScreenWidth()
h = gr.getScreenHeight()
poneh = 0
ptwoh = 0
gameh = 200
gamew = 300
gamex = w / 2
gamey = h / 2
ballx = gamex
bally = gamey
ballxvel = 1
ballyvel = 1
balla = 255
drawpongarea = function(x, y, sx, sy) --pong box here
gr.setColor(0,200,0,255) --pong green
gr.drawLine(x-sx, y+sy, x+sx, y+sy)
gr.drawLine(x-sx, y-sy, x+sx, y-sy)
end
drawpongpaddle = function(x, y)
gr.setColor(0,0,200,255)
gr.drawRectangle(x+5, y+15, x-5, y-15, true)
end
drawpongball = function(x, y, a)
gr.setColor(200,0,0,a)
gr.drawCircle(10,x,y)
end
--im nuts
]
$HUD:
[
--HudPong
drawpongarea(gamex,gamey,gamew/2,gameh/2) --draw playing area every frame
maxis1 = ((ms.getY() / 768) * (gameh * 0.8)) --paddels, what a mess, my math sucks
maxis2 = ((ms.getX() / 1024) * (gameh * 0.8))
poneh = (maxis1 + (gamey - (gameh / 2))) + ((gameh - (gameh * 0.8)) / 2)
ptwoh = (maxis2 + (gamey - (gameh / 2))) + ((gameh - (gameh * 0.8)) / 2)
drawpongpaddle(gamex + (gamew/2), poneh)
drawpongpaddle(gamex - (gamew/2), ptwoh)
ballx = ballx + ballxvel --move and draw the ball
bally = bally + ballyvel
drawpongball(ballx, bally, balla)
if bally < (gamey - (gameh / 2)) + 5 or bally > (gamey + (gameh / 2)) - 5 then
ballyvel = ballyvel * -1 --bounce off borders
end
if ballx < (gamex - (gamew / 2)) or ballx > (gamex + (gamew / 2)) then --tell the player when he gets castrated and reset the game
gr.setColor(200,200,200,255)
gr.drawString("Dont Loose Your Balls", gamex - 80, gamey)
balla = balla - 10
if balla < 1 then
ballx = gamex
bally = gamey
balla = 255
end
end
if (ballx < (gamex - (gamew / 2)) + 10 and bally > ptwoh - 15 and bally < ptwoh + 15) or (ballx > (gamex + (gamew / 2)) - 10 and bally > poneh - 15 and bally < poneh + 15) then
ballxvel = ballxvel * -1 --bounce off paddles
end
--nuts indeed
]
#End
:D
-
:lol::lol::lol:
-
i hope your not laughing at my code :D
-
LOL No, it's better than any attempt I could make ;) I think you may have just explained why your co-pilots keep trying to fly into you though, they keep getting the controls confused ;)
-
:lol: :lol: :lol:
I think this is going in DEM II. :D
-
an update
now it supports any resolution, and you can set different constants for where to draw the game and how big.
#Global Hooks
$GameInit:
[
--HudPong (tm)
w = gr.getScreenWidth()
h = gr.getScreenHeight()
poneh = 0
ptwoh = 0
gameh = 300 --you can change this to what
gamew = 600 --ever resolution you want.
gamex = w / 2 --set what coords to draw
gamey = h / 2 --the game at here (game center).
ballx = gamex
bally = gamey
ballxvel = 1 --or change theese if you
ballyvel = 1 --want a faster ball speed
balla = 255
deathmsg = "Dont Loose Your Balls!"
drawpongarea = function(x, y, sx, sy) --pong box here
gr.setColor(0,200,0,255) --pong green
gr.drawLine(x-sx, y+sy, x+sx, y+sy)
gr.drawLine(x-sx, y-sy, x+sx, y-sy)
gr.setColor(0,100,0,20)
gr.drawRectangle(x-sx, y+sy, x+sx, y-sy) --now featuring a transparent back
end
drawpongpaddle = function(x, y)
gr.setColor(0,0,200,255)
gr.drawRectangle(x+5, y+15, x-5, y-15, true)
end
drawpongball = function(x, y, a)
gr.setColor(200,0,0,a)
gr.drawCircle(10,x,y)
end
--im nuts
]
$HUD:
[
--HudPong
drawpongarea(gamex,gamey,gamew/2,gameh/2) --draw playing area every frame
if w >= 1024 then --compensate for resolution
maxis1 = ((ms.getY() / 768) * (gameh * 0.9)) --paddels, what a mess, my math sucks
maxis2 = ((ms.getX() / 1024) * (gameh * 0.9))
else
maxis1 = ((ms.getY() / 480) * (gameh * 0.9)) --paddels, what a mess, my math sucks, now in lowres!
maxis2 = ((ms.getX() / 640) * (gameh * 0.9))
end
poneh = (maxis1 + (gamey - (gameh / 2))) + ((gameh - (gameh * 0.9)) / 2)
ptwoh = (maxis2 + (gamey - (gameh / 2))) + ((gameh - (gameh * 0.9)) / 2)
drawpongpaddle(gamex + (gamew/2) - 5, poneh)
drawpongpaddle(gamex - (gamew/2) + 5, ptwoh)
ballx = ballx + ballxvel --move and draw the ball
bally = bally + ballyvel
drawpongball(ballx, bally, balla)
if bally < (gamey - (gameh / 2)) + 5 or bally > (gamey + (gameh / 2)) - 5 then
ballyvel = ballyvel * -1 --bounce off borders
end
if ballx < (gamex - (gamew / 2)) or ballx > (gamex + (gamew / 2)) then --tell the player when he gets castrated and reset the game
gr.setColor(200,200,200,255)
gr.drawString(deathmsg, gamex - (gr.getStringWidth(deathmsg) / 2) , gamey)
balla = balla - 8
if balla < 1 then
ballx = gamex
bally = gamey
balla = 255
end
end
if (ballx < (gamex - (gamew / 2)) + 15 and bally > ptwoh - 15 and bally < ptwoh + 15) or (ballx > (gamex + (gamew / 2)) - 15 and bally > poneh - 15 and bally < poneh + 15) then
ballxvel = ballxvel * -1 --bounce off paddles
end
--nuts indeed
]
#End
im gonna put it up on the wiki cause i guess it can be educational :D
-
:D :p :p ;)
-
:lol: :lol: :lol:
This is awesome!
I think this is going in DEM II. :D
:D
-
This is brilliant stuff. :D :yes:
-
Screenies for those who don't have access to FS2 just now :(
-
if you insist
(http://game-warden.com/nukemod-cos/Images/hudpong.jpg)
i wonder why lvlshots dont work anymore :D
-
Here's a fun challenge - can anyone figure out how (in theory) you could do internet multiplayer pong, by expanding on this method?
-
you would first need to share the variables of the game between client and server. there arent many of them. could pretty much all be crammed into one packet. the server would be responsible for all the colision detection, scoring, ect. the only variable the client would be allowed to modify is the paddle location (poneh or ptwoh, depending on which side the client is on). the client code would be responsible for getting the mouse coords and calculating the paddle location for that player. the client paddle location would be sent to the server so colisions could be detected the client would have the draw functions available, however the function calls would be relayed from the server to the client. the background as its static would be drawn by the client, same as their paddle, but the ball and server's paddle would be called from the server. i could probibly set it up fairly easy if i had network-global variables, and some sort of function call forwarding.
-
If you can get the variables from the script into SEXP variables and visa versa the game now handles the updating of those automatically for you.
Might not be the most efficient way of doing things though :)
-
LOL We have it! The final outcome of years of SCP research.
Network Pong!
-
Next step.............snake on colossus... :lol:
-
:lol: This would provide nice pastime in multi, after one is out of respawns.
-
LOL We have it! The final outcome of years of SCP research.
Network Pong!
:lol:
The future...is now! :D
-
LOL We have it! The final outcome of years of SCP research.
Network Pong!
I sense that I Spy's rule as the official GTVA pasttime is over. :D
-
a cookie for he who makes hud tetris :D
-
ROFL!!!!!
This is great!
Kudos to Nuke.
-
:lol: This would provide nice pastime in multi, after one is out of respawns.
:lol: Brilliant idea!
-
feel free to mod my game :D
heres some things you can improve upon
-newtonian physics :D
-textureed objects
-a scoring system
-make the game progressively harder to play (bumpers, faster ball, curved paddles, ect)
-make the game window moveable, scalable, minimizeable, ect.
-give the player lives
-4 paddle mode
-multiplayer support
-soundeffects
-replace ball with a mara class fighter :D
-
http://fs2source.warpcore.org/temp/wmc/hudpong2.zip
For newer builds, requires C01142007b
-
Finally something to do on long escort missions! :D
-
And nobody's noticed the solitaire game on the upper monitor in that cockpit...
What's next? Mara Sweeper? :wakka:
-
i figured all it needed was to ckange ms. to io.
heh finally people noticed that sepulture bomber pilots get bored and need to play silly little games to keep their sanity :D
anyway it was a little joke i guess. i was anticipating rtt to work and so didnt put much effort into the screens. if i got time tomorrow i may try to rtt this thing onto the side of an orion :D
-
necrothreadaged!...?
i think i'll make a place in the HUD juuust for this.
-
youl never get hud pong to compile! muhahahaha!
-
think not! i will improve on your work!
-
You can do scripting? Word.
-
as long as i get a way to get images into hudpong, then yes i will script.
-
rather than upgrade hudpong why dont you do hud asteroids or hud centepede:D
-
because those are way to complex for a n00b scripter. besides, why cant you make a mission in a huge asteroid field and set alpha 1's hitpoits to 0.00001?
-
a) Because the lowest you can go is 1, and even if you could get to 0.00001,
b) The blast from the asteroids would kill you.
-
then set special explosions, and then get back to the topic of hudpong(tm)
-
I seriously doubt you know how to script takashi.
-
then set special explosions,
- That would work..
and then get back to the topic of hudpong(tm)
:p ::)
-
because those are way to complex for a n00b scripter. besides, why cant you make a mission in a huge asteroid field and set alpha 1's hitpoits to 0.00001?
FRED and FS2_Open should still have 2D mission support. All you'd need to do would be to define an asteroid field that asteroids don't move or spawn on any other plane than the one the player ship is on.
-
still working on hudpong. so far:
textures
better physics
-
still working on hudpong. so far:
textures
better physics
Screenshots. :doubt:
Ha, I've always wanted to use that smilie. Now my wildest dreams are...no...longer...my dreams...?
-
taking you awhile there, takashi. hudpong took me a whole 2 hours to program and im sure one of the scp coders could make a better version, from scratch, in about 15 minutes.
-
its the image creation that takes time. seriously. im not going to settle for an 8 bit mara fighter.
-
You should be able to use the renderTechModel() function to draw fighters at whatever size you want.
I'm not sure, but I think you might also be able to render them to a texture to reduce lag. That's probably going a little beyond where you are at in scripting, though.
-
ive never been able to get rtt to work at all it seems. its probibly faster just to draw them on the hud directly, ive done it before when trying to get my 3d shield gauges to worrk.
-
what 3d shield gauges?