OK, lets have a competition. Most complex PONG

Miscellaneous Forums/General Discussion/OK, lets have a competition. Most complex PONG

hey all.


Lets see who can come up with the most complex PONG code in any blitz.

Plain pong, no add-ons :)
Let's see what you can get :D

"Lets see who can come up with the most complex PONG code in any blitz.

Plain pong, no add-ons :)"



What kind of competition is that exactly? Plain pong and no add-ins but it's supposed to be the most complex pong competition? I don't get it. If there are no add in's what would make for the most complex pong? Are you talking about complex code?

yeah.. it's unclear ..

It should one of these:

- pong with millions o' bells & whistles.. unique additions, cool animations and whatnot
- simple pong made in Brainfuck'esque blitz.. all just to be complex :P

Yeah, hopefully better than that one dumb guy on that television show.

haha! Sorry guys, i rushed it after seeing the Blitz on TV thing.

Im talking complex code :) how rediculously complex can you get some pong code to be :)

so, the bottom ont on CS_TBL's list :)

Complexity is relative... clean code can look alien to a n00b..

C'mon! :) ok, what about.. Use as much code to do the smallest thing. I may give it a go later.

ok, I'll drop the for-loops ... there's your buckloads o' code ^_^

Lol :P

OK, bad idea on me... i was really just taking the piss out of the Pong demo on the TV thing :)

Well, the upper option would be a better one.. pong with all the bells & whistles. No loading/incbin, just everything (gfx, sound) created with code.

Hehe, this thread wins, it's almost like a Pong game in itself just watching Cyg and CS paddling posts back and forth... HAHAHA!!! :D

...wow

here's my entry ;-)
;demo01-01.bb - A Complete game of KONG

;Set up graphics mode
Graphics 800,600 

;Seed the random generator (make random numbers actually random)
SeedRnd(MilliSecs()) 

;Create a back buffer
SetBuffer BackBuffer()
;Set the handle to the center of images
AutoMidHandle True  


;CONSTS
;The following are key code constants
Const UPKEY = 200   ;Up
Const DOWNKEY = 208  ;Down
Const PAUSEKEY = 25  ;P


Const HUMANSPEED = 7 ;The human's max speed
Const COMPUTERSPEED = 6 ;The computer's max speed


;TYPES
;The player type: both the human and the opponent
Type player 
	Field y,score     ;y position and score
End Type

;The ball type: for the ball
Type ball 
	Field x,y,xv,yv     ;x, y coordinates, and x, y velocity
End Type

;IMAGES
;The picture of the human player
Global player1image = LoadImage("player1.bmp")   

;The picture of the computer player
Global player2image = LoadImage("player2.bmp") 

;The picture of the ball
Global ballimage = LoadImage("ball.bmp") ;Load the ball image

;TYPE INITIALIZATION

;Create a ball
Global ball.ball = New ball 
;Create the human
Global player1.player = New player 
;Create the computer
Global player2.player = New player 


;INITIALIZATION

Text 400,300,"Ready...Set"
;Wait for one second
Delay(1000) 
Text 420,330,"GO!!!"
Flip 
;Delay for 1/5 of a second
Delay(200) 

;Initialize the level
InitializeLevel() 


;Set inital scores
player1\score = 0 
player2\score = 0

;MAIN LOOP
While Not KeyDown(1)

;Clear the screen
Cls 

;Draw the ball
DrawImage (ballimage,ball\x,ball\y) 
;Draw the human
DrawImage (player1image, 60, player1\y) 
;Draw the computer
DrawImage (player2image, 740, player2\y) 

;Test what user pressed
TestKeyboard() 
;What should AI do?
TestAI() 
;Draw the HUD
DrawScore() 

Flip

Wend ;END OF MAIN LOOP

;FUNCTIONS
;INITIALIZELEVEL()
;Sets up starting values
Function InitializeLevel()

;Put ball in center of the screen
ball\x = 400 
ball\y = 300 

;Make the ball move in a random direction
ball\xv = Rand(2,6) 
ball\yv = Rand(-8,8)

;Place the players in their correct position
player2\y = 300 
player1\y = 300
End Function


;DRAWSCORE()
;Draws the HUD in the top right
Function DrawScore()
;Write the human score
Text 700,0,"Player 1: " + player1\score 
;Write the computer's score
Text 700,30,"Player 2: " + player2\score 
End Function

;TESTKEYBOARD()
;Moves player up and down based on keyboard
Function TestKeyboard()

;If player hits up, move him up
If KeyDown(UPKEY)
	player1\y = player1\y - HUMANSPEED 
EndIf

;If player presses down, move him down
If KeyDown(DOWNKEY) 
	player1\y = player1\y + HUMANSPEED 
End If

;if player presses Pause, pause the game
If KeyHit(PAUSEKEY) 
	;make screen blank
	Cls 
	
	Text 400,300,"Press 'P' to Unpause Game"
	
	Flip 
	
	;wait for player to unpause
	While Not KeyHit(PAUSEKEY) 
	Wend

EndIf

End Function





;TESTAI()
;Updates ball and score and enemy
Function TestAI()

;If ball is above computer, move computer up
If ball\y > player2\y 
	player2\y = player2\y + COMPUTERSPEED 

;if ball is lower than computer, move computer down
ElseIf ball\y < player2\y
	player2\y = player2\y - COMPUTERSPEED 
	EndIf
	
;If ball hits human player, reflect it away from him and variate its velocity and direction
If ImagesOverlap(ballimage,ball\x,ball\y,player1image,60,player1\y) 
	ball\xv = -ball\xv + Rand(-4,4) 
	ball\yv = ball\yv + Rand(-4,4)
	
;If ball hits computer, reflect it away from computer and variate its velocity and direction
ElseIf ImagesOverlap(ballimage,ball\x,ball\y,player2image,740,player2\y) 
	ball\xv = -ball\xv + Rand(-4,4) 
	ball\yv = ball\yv + Rand(-4,4)
	
;If ball hits top wall, reflect it downwards
ElseIf ball\y <= 0  
	ball\yv = -ball\yv + Rand (-1,1) 
	ball\xv = ball\xv + Rand (-1,1)  
	
;If ball hits bottom wall, reflect it upwards
ElseIf ball\y >= 600 
	ball\yv = -ball\yv + Rand (-1,1) 
	ball\xv = ball\xv + Rand (-1,1)  
	
;if ball hits left wall, computer has scored so computer gets one more point
ElseIf ball\x <= 0  
	player2\score = player2\score + 1   ;computer scores
	Text 400,300,"Player 2 Scores!!!"
	Flip
	;wait two seconds
	Delay(2000) 
	
	;reset level
	InitializeLevel() 
	
;If ball hits right wall, human scored so give him a point
ElseIf ball\x >= 800 
	player1\score = player1\score + 1   ;human scores
	Text 400,300,"Player 1 Scores!!!"
	Flip 
	;wait 2 secs
	Delay(2000) 
	;reset level
	InitializeLevel() 
EndIf
	
	;update ball's position on screen
	ball\x = ball\x + ball\xv 
	ball\y = ball\y + ball\yv 
	
End Function
	


CS, that would indeed be cool, however!

I just wanted to see a crapload of pointless code. it makes me laugh :)

Besides, We already did a medialess code competition! :)



Hehe, this thread wins, it's almost like a Pong game in itself just watching Cyg and CS paddling posts back and forth... HAHAHA!!! :D



I lost, i took too long to respond :P

Khomy:

Lol! Maybe its not as bad as i first thought! :)

i call this "Pong1"! couldn't think of anything else. i have updated this to have proper serves. use up/down arrows and space. the game also now ends after first to 2 games. it's not very complex, but hmm, i'm working on it i guess. this is my first 2d game btw.

;Pong1, by markcw on 23/9/06

width=640
height=480

Graphics width,height,0,2
SetBuffer BackBuffer()

playery=height/2
cpuy=height/2

SeedRnd MilliSecs()

While Not KeyHit(1)
 Cls

 ;court line
 Rect width/2,0,1,height

 ;ball
 Oval ballx,bally,15,15

 If serve=0 Then ballx=60 : bally=playery+20
 If serve=2 Then ballx=width-60 : bally=cpuy+20

 ballx=ballx+ballxspd
 bally=bally+ballyspd
 If bally<0 Or bally>height-15 Then ballyspd=-ballyspd
 If ballyspd>8 Then ballyspd=8
 If ballyspd<-8 Then ballyspd=-8

 ;computer
 Rect width-50,cpuy,10,60

 If ballx>width-50 And ballx<width-40
  If bally>cpuy-8 And bally<cpuy+52
   ballxspd=-3 : ballyspd=ballyspd+(cpuyspd/2)
  EndIf
 EndIf

 If ballx>width/2
  If bally>cpuy+20 Then cpuyspd=4
  If bally<cpuy+20 Then cpuyspd=-4
  If Abs(cpuy+20-bally)<10 Then cpuyspd=cpuyspd/4
  If ballx>width-60 And Abs(ballyspd)<2 Then cpuyspd=2*(Rand(0,4)-2)
  If cpuy<0 Then cpuy=0
  If cpuy>height-60 Then cpuy=height-60
  cpuy=cpuy+cpuyspd
 Else
  If cpuy>height/2 Then cpuy=cpuy-2
  If cpuy<height/2 Then cpuy=cpuy+2
 EndIf

 If serve=2
  cpuyspd=2*(Rand(0,4)-2)
  serve=1 : ballxspd=-3 : ballyspd=ballyspd+(cpuyspd/2)
 EndIf

 ;player
 Rect 50,playery,10,60

 If ballx>50 And ballx<60
  If bally>playery-8 And bally<playery+52
   ballxspd=3 : ballyspd=ballyspd+(playeryspd/2)
  EndIf
 EndIf

 If KeyDown(200) Then playeryspd=-4 ;up key
 If KeyDown(208) Then playeryspd=4 ;down key
 If Not KeyDown(200) Or KeyDown(208) Then playeryspd=0
 If playery<0 Then playery=0
 If playery>height-60 Then playery=height-60
 playery=playery+playeryspd

 If serve=0 And KeyHit(57) ;space key
  serve=1 : ballxspd=3 : ballyspd=ballyspd+(playeryspd/2)
 EndIf

 ;points
 If nextpoint=0
  If ballx<0 Then cpupoint=cpupoint+1 : nextpoint=1
  If ballx>width Then playerpoint=playerpoint+1 : nextpoint=1
 EndIf
 If nextpoint>0 Then nextpoint=nextpoint+1
 If nextpoint>60
  nextpoint=0
  If cpupoint>10
   cpupoint=0 : playerpoint=0 : cpugame=cpugame+1
  EndIf
  If playerpoint>10
   cpupoint=0 : playerpoint=0 : playergame=playergame+1
  EndIf
  If cpupoint+playerpoint<5 Then serve=0 Else serve=2
  If cpupoint+playerpoint>9 Then serve=0
  ballxspd=0 : ballyspd=0
  If cpugame>1 Or playergame>1
   serve=3 : ballx=width/2-7 : bally=height/2-7
  EndIf
 EndIf

 If serve=3 And KeyDown(57) ;space key
  serve=0 : cpupoint=0 : cpugame=0 : playerpoint=0 : playergame=0
 EndIf

 Text width/2-140,0,"Player = "+playergame+" : "+playerpoint
 Text width/2+20,0,"Computer = "+cpugame+" : "+cpupoint
 If serve=3 Then Text width/2-40,40,"GAME  OVER"

 Flip
Wend


Good complex Pong code can't be created without prodigious use of the GOTO statement. :-)

Actually... thinking about it, we should write Pong using only the BASIC statements and commands available at the time Pong was initally available.

Barney

How about write it in VBA and run it in an Excel spreadsheet? That would surely generate a ton of pointless painful code.

Code pong with the Warcraft 3 editor. Then code an app in blitz that converts the map into instructions that control every aspect of the game.

There. That's complex.

Not hard enough? Use the extra BS in the map's data to generate random background images.

Look we all know that Ram would win, so stop arguing about it. ok?

Hmm, indeed. Just use wireframe mesh graphics, a nice Geometry Wars-style camera to follow that spinning star around, and then it would be in high-def, and push the 5.1 Dolby envelope, and submit to MS to see if it'll be part of Xbox Live Arcade. So there.

I thought you were going to have leaping ninja warriors instead of bats?

there should be 100 different pongs going on, each of which you control with the same two buttons, but all of them have different starting position balls/bats, and they should all be displayed next to each other down the screen, giving a res each with 64x48! On one 640x480 screen. :)

Technically, my version cannot be beaten! BWahaha!
Note: Not actually a very functioning Pong game, I just had a few minutes of free time to piss about. ;)

Graphics 640,480,16,2
SetBuffer BackBuffer()

Type pong
Field bat[1], ballx#, bally#, balla#
End Type

Dim zpong.pong(9,9)
For x=0 To 9
For y=0 To 9
	zpong(x,y) = New pong
	zpong(x,y)\bat[0] = Rnd(36)
	zpong(x,y)\bat[1] = Rnd(36)
	zpong(x,y)\ballx = 32
	zpong(x,y)\bally = 24
	zpong(x,y)\balla = Rnd(-4,4)*45
Next
Next

While Not KeyDown(1)
	Cls
	ky = (KeyDown(208) - KeyDown(200))
	For x=0 To 9
	For y=0 To 9
		zpong(x,y)\bat[0] = zpong(x,y)\bat[0] + ky
		If zpong(x,y)\bat[0] < 0 zpong(x,y)\bat[0] = 0
		If zpong(x,y)\bat[0] > 36 zpong(x,y)\bat[0] = 36
		zpong(x,y)\bat[1] = zpong(x,y)\bally-5
		If zpong(x,y)\bat[1] < 0 zpong(x,y)\bat[1] = 0
		If zpong(x,y)\bat[1] > 36 zpong(x,y)\bat[1] = 36
		
		ix = x*64
		iy = y*48
		Color 255,255,0
		Rect ix+32,iy,1,47,0
		Color 255,255,255
		Rect ix,iy,63,47,0
		Rect ix+4,iy+zpong(x,y)\bat[0],2,10,0
		Rect ix+57,iy+zpong(x,y)\bat[1],2,10,0
		
		zpong(x,y)\ballx = zpong(x,y)\ballx + Sin(zpong(x,y)\balla) * .75
		zpong(x,y)\bally = zpong(x,y)\bally + Cos(zpong(x,y)\balla) * .75
		
		If zpong(x,y)\ballx < 1
			Color 255,0,0
			Rect ix,iy,64,48
			zpong(x,y)\ballx = 32
			zpong(x,y)\bally = 24
			zpong(x,y)\balla = Rnd(-4,4)*45
		EndIf
		
		If zpong(x,y)\ballx > 61
			Color 0,255,0
			Rect ix,iy,64,48
			zpong(x,y)\ballx = 32
			zpong(x,y)\bally = 24
			zpong(x,y)\balla = Rnd(-4,4)*45
		EndIf
		
		If zpong(x,y)\bally < 1 zpong(x,y)\balla = 180-zpong(x,y)\balla
		If zpong(x,y)\bally > 45 zpong(x,y)\balla = 180-zpong(x,y)\balla
		
		If zpong(x,y)\ballx => 3 And zpong(x,y)\ballx =< 6 And zpong(x,y)\bally => zpong(x,y)\bat[0] And zpong(x,y)\bally =< zpong(x,y)\bat[0] + 10
			zpong(x,y)\balla = -zpong(x,y)\balla
		EndIf
		
		If zpong(x,y)\ballx => 56 And zpong(x,y)\ballx =< 57 And zpong(x,y)\bally => zpong(x,y)\bat[1] And zpong(x,y)\bally =< zpong(x,y)\bat[1] + 10
			zpong(x,y)\balla = -zpong(x,y)\balla
		EndIf
		
		Rect ix+zpong(x,y)\ballx-1, iy+zpong(x,y)\bally-1, 3,3
		
	Next
	Next
	Flip
Wend
End


there should be 100 different pongs going on... etc etc etc


Okay, that was funny. :o)

Hmm....

Lol.

Ooh, let's see what Warpy does!

Well, needed a version of Pong that would make the game more "Jetsons" than "Jet Li" in order to appeal to a better crowd. Using mesh wireframes may actually be pretty cool in the long haul.

EDIT: Also, don't let that thing in my siggy fool you, it's gonna be completely wireframe, no true solid objects whatsoever are gonna be used. I have something in mind that'll bring Pong to that "Virtual" dimension, as it were. I promise a slow crafted design, it'll be out when it's done (hopefully by the holidays).

I didn't actually read the rules.. >_>