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:

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!

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

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.
I always love the idea of a weapon in pong-type games; for example, take a look at the first screenshot from my Doors CS Pong game in z80 assembly. This seems like a great start though; I look forward to your progress. Since I didn't get to load it onto my calculator yet, how fast does it run?
Its pretty fast, I am just worrying about what added functionality will do to the speed.

EDIT:
Also, I never thought of weapons. How do they work? Do you try to shoot the opponent or the ball?
flyingfisch wrote:
Its pretty fast, I am just worrying about what added functionality will do to the speed.

EDIT:
Also, I never thought of weapons. How do they work? Do you try to shoot the opponent or the ball?
At least in my implementation, you try to shoot the opponent. You usually lose the gun after a turn or two, and always if you lose a point, but I didn't implement that part in my game. Having to shoot the ball sounds more challenging though; I like it.
When I saw this, I was like, "OOH! PONG!", but then Kerm said weapons, and I was like, "OOH! DX BALL!" Someone should make a DX BALL game. I hope you'll be able to implement all that you want without slowing it down too much.
Spenceboy98 wrote:
When I saw this, I was like, "OOH! PONG!", but then Kerm said weapons, and I was like, "OOH! DX BALL!" Someone should make a DX BALL game. I hope you'll be able to implement all that you want without slowing it down too much.
I'm not familiar with this DX Ball of which you speak; is it a calculator game or a computer game?
KermMartian wrote:
Spenceboy98 wrote:
When I saw this, I was like, "OOH! PONG!", but then Kerm said weapons, and I was like, "OOH! DX BALL!" Someone should make a DX BALL game. I hope you'll be able to implement all that you want without slowing it down too much.
I'm not familiar with this DX Ball of which you speak; is it a calculator game or a computer game?

It is a computer game. It is pretty fun. I think it has weapons, but I'm not sure. It's made by the same people who made Pocket Tanks(if you don't know what that is, look them both up). Both really fun.
Yup, I am familiar with Pocket Tanks, and if I ever am so inclined, I always thought it would be fun to add multiple weapons to Prizm Obliterate for a Version 2. I'll take a look at it. As far as flyingfisch's project goes, I'd probably recommend sticking with the basic Pong rules for now with a few special features to make it a bit more interesting.
KermMartian wrote:
As far as flyingfisch's project goes, I'd probably recommend sticking with the basic Pong rules for now with a few special features to make it a bit more interesting.


Yeah, I think that's what I am going to do. I am going to integrate a powerups and then add an freeze powerup, which will change everything to blue and slow down ball speed for two turns.

Also, I think am going to keep this retro-looking and not use sprites.

@Kerm: what does zmg.clipRect() do?
flyingfisch wrote:

Also, I think am going to keep this retro-looking and not use sprites.
You mean use ASCII art instead? Sounds cool!

Quote:
@Kerm: what does zmg.clipRect() do?
It sets a clipping rectangle on the screen, outside of which elements do not render. By default the clipping rectangle is set to match the screen.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement