Omnimaga

Calculator Community => Casio Calculators => Topic started by: flyingfisch on September 19, 2012, 04:40:13 pm

Title: [LuaZM] Pong++
Post by: flyingfisch 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
Title: Re: [LuaZM] Pong++
Post by: blfngl on September 19, 2012, 05:02:38 pm
Is this compatible with Ti Lua, not just Lua ZM?
Title: Re: [LuaZM] Pong++
Post by: flyingfisch 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?
Title: Re: [LuaZM] Pong++
Post by: TIfanx1999 on September 19, 2012, 07:36:39 pm
I think Jim Bauwens is working on some sort of cross compatibility.
Title: Re: [LuaZM] Pong++
Post by: blfngl 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
Title: Re: [LuaZM] Pong++
Post by: DJ Omnimaga 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
Title: Re: [LuaZM] Pong++
Post by: Yeong on October 01, 2012, 04:28:02 pm
@ffish: How about fireball? The ball goes through blox.
Title: Re: [LuaZM] Pong++
Post by: TIfanx1999 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>.
Title: Re: [LuaZM] Pong++
Post by: chickendude 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 ;)
Title: Re: [LuaZM] Pong++
Post by: DJ Omnimaga on October 21, 2012, 12:21:30 pm
Is that still progressing by the way?
Title: Re: [LuaZM] Pong++
Post by: flyingfisch 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 ;)
Title: Re: [LuaZM] Pong++
Post by: DJ Omnimaga on October 21, 2012, 02:22:28 pm
That's good to hear. :)