Author Topic: [LuaZM] Pong++  (Read 7908 times)

0 Members and 2 Guests are viewing this topic.

Offline flyingfisch

  • I'm 1337 now!
  • Members
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1620
  • Rating: +94/-17
  • Testing, testing, 1...2...3...4...5...6...7...8..9
    • View Profile
    • Top Page Website Design
[LuaZM] Pong++
« on: September 19, 2012, 04:40:13 pm »
I have started a project I am calling pong++. It is based on pong but will have lots of different modes.

So far I have this:

Code: [Select]
print("starting...")

print("defining functions")
--function variables
local drawRectFill = zmg.drawRectFill
local fastCopy = zmg.fastCopy
local makeColor = zmg.makeColor
local drawPoint = zmg.drawPoint
local keyMenuFast = zmg.keyMenuFast
local clear = zmg.clear
local drawText = zmg.drawText
local keyDirectPoll = zmg.keyDirectPoll
local keyDirect = zmg.keyDirect
local floor = math.floor
local random = math.random

print("setting vars")
--screen vars
local LCD_SCREEN_WIDTH = 384
local LCD_SCREEN_HEIGHT = 216

--game variables
local key = {F1=79, F2=69, F3=59, F4=49, F5=39, F6=29, Alpha=77, Exit=47, Optn=68, Up=28, Down=37, Left=38, Right=27}
local color = {makeColor("limegreen"),makeColor("black")}
local ball = {x=20, y=20, width=8, height=8}
local dir = {x=1, y=1}
local speed = {x=2, y=2}
local paddle = {player=40, width=8, height=30, speed=4}
local wall = {width=8}


print("entering game loop")
----game loop----
while keyMenuFast() ~= key.Exit do
----DRAW----
--draw background
drawRectFill(0,0,LCD_SCREEN_WIDTH,LCD_SCREEN_HEIGHT,color[2])

--draw ball
drawRectFill(ball.x, ball.y, ball.width, ball.height, color[1])

--draw player paddle
drawRectFill(0, paddle.player, paddle.width, paddle.height, color[1])

--draw wall
drawRectFill(LCD_SCREEN_WIDTH-wall.width, 0, wall.width, LCD_SCREEN_HEIGHT, color[1])


----CONTROLS----
--control paddle
if keyMenuFast()==key.Up and paddle.player>0 then paddle.player = paddle.player - paddle.speed
elseif keyMenuFast()==key.Down and paddle.player<LCD_SCREEN_HEIGHT - paddle.height then paddle.player = paddle.player + paddle.speed
end


----COLLISIONS----
--check for collisions
if ball.x < 0 + paddle.width and ball.y > paddle.player and ball.y < paddle.player + paddle.height then ball.x = 0 + paddle.width dir.x=1
elseif ball.x < 0 then print("Game Over") break
end

if ball.x>LCD_SCREEN_WIDTH - ball.width - wall.width then ball.x = LCD_SCREEN_WIDTH - ball.width - wall.width dir.x=-1
end

if ball.y<0 then ball.y=0 dir.y=1
elseif ball.y>LCD_SCREEN_HEIGHT - ball.height then ball.y = LCD_SCREEN_HEIGHT - ball.height dir.y=-1
end

----ETC----
--make new vars
ball.x = ball.x + (dir.x * speed.x)
ball.y = ball.y + (dir.y * speed.y)

--refresh screen
fastCopy()

--[[--
--debug
print("ball.y:" .. ball.y)
print("ball.x:" .. ball.x)
--]]--

end
print("exiting.")

As you can see I have a basic pong game set up there. It is totally playable, just paste it into notepad or whatever, save it, and send it to your calc. If you get errors, please post them.



The main reason I am posting this is because I have not come up with many ideas for different modes. The ideas I have come up with are:

* Slug: Make the paddle move very slowly. I will probably make this something that happens in-game as a penalty or whatever, not as an actual game mode.

* Spread: have two player paddles that move away from each other symmetrically from the center.

* Obstacles: Have obstacles in the middle of the screen.

* Multiple balls: self-explanatory, I think. Have more than one ball to keep track of.

Please post your ideas!


If you can give me tips on optimization, by all means do! :)

I think that there may be a faster way of clearing the screen than drawing the background every frame, but I am too lazy right now to figure that out. :P
« Last Edit: September 19, 2012, 04:41:25 pm by flyingfisch »



Quote from: my dad
"welcome to the world of computers, where everything seems to be based on random number generators"



The Game V. 2.0

Offline blfngl

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 121
  • Rating: +3/-4
  • No worry, I'll surpass Calc84 in greatness...never
    • View Profile
Re: [LuaZM] Pong++
« Reply #1 on: September 19, 2012, 05:02:38 pm »
Is this compatible with Ti Lua, not just Lua ZM?
GAMEGAMEGAMEGAMEGAMEGAMEGAMEGAMEGAMEGAME
My blog:

TiLibs
My Projects:
Minecraft Library

Offline flyingfisch

  • I'm 1337 now!
  • Members
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1620
  • Rating: +94/-17
  • Testing, testing, 1...2...3...4...5...6...7...8..9
    • View Profile
    • Top Page Website Design
Re: [LuaZM] Pong++
« Reply #2 on: September 19, 2012, 07:35:21 pm »
I imagine it could be ported pretty easily, but as far as being able to run it without modification, no.

But... I wonder if anyone has thought of making a luazm interpretor for TI calcs?



Quote from: my dad
"welcome to the world of computers, where everything seems to be based on random number generators"



The Game V. 2.0

Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
Re: [LuaZM] Pong++
« Reply #3 on: September 19, 2012, 07:36:39 pm »
I think Jim Bauwens is working on some sort of cross compatibility.

Offline blfngl

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 121
  • Rating: +3/-4
  • No worry, I'll surpass Calc84 in greatness...never
    • View Profile
Re: [LuaZM] Pong++
« Reply #4 on: September 19, 2012, 09:13:37 pm »
That would be quite nice, is there already a forum post for it? Can't find one :P
GAMEGAMEGAMEGAMEGAMEGAMEGAMEGAMEGAMEGAME
My blog:

TiLibs
My Projects:
Minecraft Library

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55942
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: [LuaZM] Pong++
« Reply #5 on: October 01, 2012, 03:15:03 pm »
I don't have much ideas, but multiple balls definitively seems like a good idea, along with paddle size increase/decrease
Now active at https://discord.gg/cuZcfcF (CodeWalrus server)

Offline Yeong

  • Not a bridge
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3739
  • Rating: +278/-12
  • Survivor of Apocalypse
    • View Profile
Re: [LuaZM] Pong++
« Reply #6 on: October 01, 2012, 04:28:02 pm »
@ffish: How about fireball? The ball goes through blox.
Sig wipe!

Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
Re: [LuaZM] Pong++
« Reply #7 on: October 03, 2012, 04:19:20 am »
Power-up ideas:
Shrink/Expand paddle.
Gun: Lets you use the "launch ball" button to fire shots in straight line from the center of the paddle. Has about 5 shots IIRC.
Reverse:Forces your paddle to move in the opposite direction of the key pressed for a small period of time.
@blfngl:There isn't a topic for it, but he did mention it in an Nspire Lua thread somewhere.
*Edit* Perhaps it was in the LuaZM topic now that I think about it...
*Edit2*Yep, mentioned <a href=http://ourl.ca/17006>here</a>.
« Last Edit: October 03, 2012, 04:25:16 am by Art_of_camelot »

Offline chickendude

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 817
  • Rating: +90/-1
  • Pro-Riot Squad
    • View Profile
Re: [LuaZM] Pong++
« Reply #8 on: October 03, 2012, 07:22:18 am »
Other ideas:
-make a mix of phoenix/pong, where you have some enemies on screen trying to shoot you while you have to keep the ball alive.
-powerups that you have to hit with the ball (so either you or your opponent can get them, depending on who it was that hit the ball).
-expanding on Art_of_camelot's gun idea, give each player a certain amount of health and you can beat them either by making them miss the ball or killing them, you could also use the gun to change the ball's direction
-randomly changing spots on the board that make the ball "invisible", so that you can't see it until it leaves that area

There's lots more you can do, it just depends how much time you want to spend on it ;)

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55942
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: [LuaZM] Pong++
« Reply #9 on: October 21, 2012, 12:21:30 pm »
Is that still progressing by the way?
Now active at https://discord.gg/cuZcfcF (CodeWalrus server)

Offline flyingfisch

  • I'm 1337 now!
  • Members
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1620
  • Rating: +94/-17
  • Testing, testing, 1...2...3...4...5...6...7...8..9
    • View Profile
    • Top Page Website Design
Re: [LuaZM] Pong++
« Reply #10 on: October 21, 2012, 02:21:57 pm »
DJ: Well, I have gotten pretty busy lately and I didn't realize this thread was getting attention. I am planning on getting back to it sometime within the next few weeks ;)



Quote from: my dad
"welcome to the world of computers, where everything seems to be based on random number generators"



The Game V. 2.0

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55942
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: [LuaZM] Pong++
« Reply #11 on: October 21, 2012, 02:22:28 pm »
That's good to hear. :)
Now active at https://discord.gg/cuZcfcF (CodeWalrus server)