This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Skullblade's profile picture

[Game] SkullPong V1.10(Massively Amazing New Features!)

Started by Skullblade, 20 January 2013 - 06:45 PM
Skullblade #1
Posted 20 January 2013 - 07:45 PM
SkullPong V1.10

What is SkullPong?
SkullPong is a fairly basic pong game that I threw to gather in about an hour.
The basic features are…
-It works
-Score Keeper
-You can move your paddle
-Literally unbeatable computer opponent (Someone help me make the computer make mistakes….)
SkullPong Update V1.10
Massively Amazing Huge Update!!!
-Under the hood work(Implemented better moving systems)
-Fancy New Menu
-Amazing Pause Menu/Function(press f1)
-Info/Controls/Help Function
-Quit function
-Survival Mode, Screen flashes and you lose if the AI scores on you
-Local Multiplayer mode
-New Video:D
-And More
Future Features
-MultiPlayer over rednet
-Beatable computer opponent

Download!
pastebin get 8LU0sjFR SkullPong


Controls/Rules
Spoiler-You are the green paddle
-The AI is the red paddle
-Up arrow key brings your paddle up
-Down arrow key brings your paddle down
-Try to get a ball past the red paddle
-Dont let a ball past the green paddle
Screenshots
NEW Movie
Spoiler

Play the movies on a CC computer just get the file and run it :lol:/>
Video with amazing new features pastebin get XbKc68au movie

Old Obsolete Movie pastebin get erd5NRWK movie2
…recorded using lightshot

As always feedback is welcome :)/>
nitrogenfingers #2
Posted 20 January 2013 - 07:53 PM
I downloaded to give it a try, and got

skullpong:123: index expected, got nil.

Regarding AI opponents, the way "beatable" AI is usually done in such games is to have the computer opponent have a fixed or maximum speed (which increases with the difficulty), but have the ball incrementally increase in speed. Eventually it will move faster than the computer opponent can, which will usually cause him to lose.
The strategy and game play for pong is quite different in ComputerCraft than it is in the arcade/home originals, as they were played with analogue paddle controllers rather than digital keyboards, and had a much more fluid range of movement, so it demanded more precision than ComputerCraft versions can.
Skullblade #3
Posted 20 January 2013 - 08:05 PM
Thx for the quick reply nitro, I am always amazed at your level of knowledge of all things computers :P/> I'll have to work on variable movement speeds in the next update.

Also bug fixed…Dumba** mistake…very tired its 2am here…
I had forgotten to declare a table(yes I did bug test, the versions before this had the table but I changed the way it was implemented so the table was still running on the computer and i got no error)
TheOddByte #4
Posted 20 January 2013 - 09:32 PM
When you wrote "Unbeatable" you should have wrote "Non Moving"
Other than that It's pretty nice,
Maybe You Should do a menu So The One who Plays the game can select if they wanna
play againts an Al or If they want to play multiplayer.
Skullblade #5
Posted 21 January 2013 - 03:58 AM
Hellkid what do you mean non moving? It seemed to work fine in all my tests(I was tired and had a pounding headache though…)I was only able to score 2 points on the "AI"….time for more testing; can anyone second Hellkid?

Also Hellkid in the next version I will be implementing multiplayer support and there will be a menu(in OP)


EDIT: HellKid I just had a very good, funish game against the computer and it seems to be working perfectly…I scored 0 points the computer scored 7 :(/> (This was on a new computer in a new world) is it still not moving for you? Do you know that you are the green paddle and the controls are the up and down arrow keys…..?
GravityScore #6
Posted 21 January 2013 - 04:27 AM
Hey Skullblade. I like the pong game - nice and simple :D/>. I have a few suggestions for you,

1. Instead of storing the ball's direction as a string, then having to use 4-way if statements to update the position, why not just give the ball an x and y velocity, and just add that to the position. So for example, if it was moving down and to the right, you would give it an x velocity of 1, and a y velocity of 1, so that when you added it to the ball's position, the xpos and ypos would both be 1 larger. Another example: if the ball was moving to the top right, xvel = 1 and yvel = -1.

2. This could also be used to change the speed, by using 1.5 instead of 1, for example.

3. Also, when you hit a wall, all that would be needed to update is the corresponding value. Eg:
local w, h = term.getSize()
if ypos == h or ypos == 1 then yvel = yvel * -1 end
(if the y position of the ball is on the top row or the bottom row of the screen, change the direction it is going).

You may like your way, or you may decide to change it, I don't mind :P/>

I also made my own pong a few weeks ago if you need any ideas :P/>
Skullblade #7
Posted 21 January 2013 - 04:32 AM
actually Gravity I like your way….makes more sense I could really shorten the code using that thanks :)/>
is the "AI" moving for you, for some reason its not for HellKid….?

Oh and I also made a light shot movie of me playing it(Badly)…I put it in screenshots
GravityScore #8
Posted 21 January 2013 - 04:35 AM
I had to actually download it then to find out :P/> I made that assessment from looking at the code :P/>

After playing it, the AI works for me, although I think a better AI would simulate the ball's movements, and predict where it would land, then move to that point at a certain pace, instead of just following the ball's ypos.

You could simulate by just copying and pasting your ball moving code, and remove the sleeps, then run it until the xpos == screenwidth.

EDIT: I love the movie idea for screenshots and demonstrations… More people should do this!
Skullblade #9
Posted 21 January 2013 - 04:54 AM
The movie idea was just me being lazy and not wanting to take screenshots, crop them, and upload them….light shot is much faster and shows more:D

I originally had the AI predict the future ball positions but it was very buggy and I settled on what I have now but I will fix AI in my next update :D/>
TheOddByte #10
Posted 21 January 2013 - 10:45 AM
Hellkid what do you mean non moving? It seemed to work fine in all my tests(I was tired and had a pounding headache though…)I was only able to score 2 points on the "AI"….time for more testing; can anyone second Hellkid?

Also Hellkid in the next version I will be implementing multiplayer support and there will be a menu(in OP)


EDIT: HellKid I just had a very good, funish game against the computer and it seems to be working perfectly…I scored 0 points the computer scored 7 :(/> (This was on a new computer in a new world) is it still not moving for you? Do you know that you are the green paddle and the controls are the up and down arrow keys…..?
Yeah I know that but the red one isn't moving,
I should have mentioned that I run it with CCemu..
But the red one just stands still In the Middle :(/>

EDIT: Just deleted it and re downloaded , Works now :D/>
TheOddByte #11
Posted 21 January 2013 - 10:50 AM
So at it seems you have done so the Al follows the ball all the time,
Am I correct?
Since That seemed to be my error since it just bounced it the middle and not up and down,
So the Al just stood still..
Skullblade #12
Posted 21 January 2013 - 10:50 AM

Yeah I know that but the red one isn't moving,
I should have mentioned that I run it with CCemu..
But the red one just stands still In the Middle :(/>

EDIT: Just deleted it and re downloaded , Works now :D/>

yay :lol:/>
So at it seems you have done so the Al follows the ball all the time,
Am I correct?
Since That seemed to be my error since it just bounced it the middle and not up and down,
So the Al just stood still..
yeh, I am working on a more advanced "Ai" for the next update right now
Skullblade #13
Posted 22 January 2013 - 12:14 PM
SkullPong V1.10

Massively Amazing Huge Update!!!
-Under the hood work(Implemented better moving systems)
-Fancy New Menu
-Amazing Pause Menu/Function(press f1)
-Info/Controls/Help Function
-Quit function
-Survival Mode, Screen flashes and you lose if the AI scores on you
-Local Multiplayer mode
-And More
CCPoster #14
Posted 22 January 2013 - 12:50 PM
As for making the Computer miss you could just do a:

chance = math.random(1,2) -- Gives the Computer a 50% chance of missing math.random(1,8) will give the computer a 1/8 chance of missing
if chance = 1 then
  misses ball
else
  hits ball
end
Skullblade #15
Posted 22 January 2013 - 12:58 PM
PixelApp I have considered that and I might do it…if I do the odds would be 1/5 or 1/10 for it missing, but right now I'm trying to work on a more sophisticated way rather then it just "missing"(probably just by it stopping right before hitting the ball)
SuicidalSTDz #16
Posted 31 January 2013 - 01:54 PM
So we meet again Skullblade ;)/> After looking at your programs, I ran across SkullPong. I absolutely love it and would be honored if I could add it within EnderOS as one of the games(Plan to add more) Thanks again!
Skullblade #17
Posted 01 February 2013 - 12:59 AM
I would love for you to use skull pong in your OS If u have any question or find any bugs plz tell me. I also might try to get the rednet multiplayer mode working…it's got a pesky bug…

Off topic: have u tried the survival feature? It's loads of fun :D/>
SuicidalSTDz #18
Posted 01 February 2013 - 04:05 PM
I would love for you to use skull pong in your OS If u have any question or find any bugs plz tell me. I also might try to get the rednet multiplayer mode working…it's got a pesky bug…

Off topic: have u tried the survival feature? It's loads of fun :D/>
I have and… I LOVE it :3 I will also keep an eagle eye out for bugs(Even though it seems fairly flawless :)/>)
Skullblade #19
Posted 01 February 2013 - 04:52 PM
I would love for you to use skull pong in your OS If u have any question or find any bugs plz tell me. I also might try to get the rednet multiplayer mode working…it's got a pesky bug…

Off topic: have u tried the survival feature? It's loads of fun :D/>
I have and… I LOVE it :3 I will also keep an eagle eye out for bugs(Even though it seems fairly flawless :)/>)
Thanks I am quite proud of it but if you play survival for too long you might have a stroke(I take no responsibility :D/> )

While I don't think that I would call it flawless(the AI needs work and I want to update the collision detector) i appreciate the complement and cant wait to c skullpong used
SuicidalSTDz #20
Posted 01 February 2013 - 05:50 PM
I would love for you to use skull pong in your OS If u have any question or find any bugs plz tell me. I also might try to get the rednet multiplayer mode working…it's got a pesky bug…

Off topic: have u tried the survival feature? It's loads of fun :D/>
I have and… I LOVE it :3 I will also keep an eagle eye out for bugs(Even though it seems fairly flawless :)/>)
Thanks I am quite proud of it but if you play survival for too long you might have a stroke(I take no responsibility :D/> )

While I don't think that I would call it flawless(the AI needs work and I want to update the collision detector) i appreciate the complement and cant wait to c skullpong used
Lol, I look forward to seeing a new collision detector(About the only thing that is buggy) but still, no one else has made it so :)/>
bjornir90 #21
Posted 02 February 2013 - 05:43 AM
Really cool ! I like to see some games on computercraft because it is hard with all the restrictions :)/>
TheOddByte #22
Posted 02 February 2013 - 06:11 AM
Yeah It's gotten much nicer since last I tried this! :D/>
But may I maybe suggest a timer or something on survival so the player
can see how long they survived.
Skullblade #23
Posted 02 February 2013 - 09:20 AM
I was thinking about a timer and highscore board for survival where the points u get is based on the time u survive, I think that I am going to be able to get a update out soon if all goes well :D/>

Also this isn't the only (or first) time pong was made but it did turn out pretty nice
rob13 #24
Posted 02 February 2013 - 10:24 AM
This is really fun to play. Thanks for making it.
Skullblade #25
Posted 02 February 2013 - 10:38 AM
Thank u and ur welcome rob I had a lot of fun making it :)/>
billysback #26
Posted 02 February 2013 - 11:33 PM
Ok, so I found a few things wrong with this (just singleplayer) and fixed them (hope you don't mind) :P/>
I liked it but here are the things I changed (SP only):
-You can move using the mouse wheel (scrolling)
-The AI is not unbeatable, as it is in your current version (I tested this by pitching 2 AI against each other, the ball never went out of play)

Here are the sections of the code that I changed:
SpoilerJust above the "if event == "key" then"

if event=="mouse_scroll" then
								if vars~="Local" then
											Move()
								end
								if You[2]==0 then
										You[2]=1
								end
								if You[2]==17 then
										You[2]=16
								end
								You={You[1],You[2],You[2]+1,You[2]+2}
							end
Instead of the current AI updating system:

if vars~="Local" then
						   local inv = false
                        if vars == "surv" then inv = true end
                        Op = AI(Op, inv)
					end
Instead of the current "AI" function:

	function AI(user, inv)
		local nuser = user
		local osts = {}
		for i=1,30 do osts[#osts + 1] = 0 end
		for i=1,6 do osts[#osts + 1] = -1 end
		for i=1,6 do osts[#osts + 1] = 1 end
		local ost = osts[math.random(#osts)]
		if inv == true then ost = 0 end
		if Ball[2]+Ball[4]>user[2]+2+ost then
				if user[2]+3~=19 then
						nuser={user[1],user[2]+1,user[2]+2,user[2]+3}
				end
		end
		if Ball[2]+Ball[4]<user[2]+ost then
				if user[2]-1~=0 then
						nuser={user[1],user[2]-1,user[2],user[2]+1}
				end
		end
		return nuser
		
	end
Instead of the current "Move" function:

	function Move()
			if key==200 or key == -1 then
					You[2]=You[2]-1
			end
			if key==208 or key == 1 then
					You[2]=You[2]+1
			end
	end
I think that is it :)/>
Just some suggestions :P/>
Note: the AI IS still unbeatable in Survival :P/>
Skullblade #27
Posted 03 February 2013 - 04:47 AM
I like the idea of mouse wheel scrolling a lot and am definitely going to implement it. thank you so much for the long response and improvements of my code :D/>
YoYoYonnY #28
Posted 02 May 2014 - 04:56 PM
Noooooo… You stole my idea!!! Oh well, I never finish any ComputerCraft programs anyways.
BTW add screenies cuz I wanna use phone :(/>
apemanzilla #29
Posted 02 May 2014 - 05:22 PM
Noooooo… You stole my idea!!! Oh well, I never finish any ComputerCraft programs anyways.
BTW add screenies cuz I wanna use phone :(/>
Umm what? This thread is over a year old!
Agoldfish #30
Posted 06 May 2014 - 12:52 AM
This topic hurts my eyes.