Pong 1.0

By sercan386 on Jan 24, 2009

Pong? Really?
Yes, this is Pong. A game I made in a few hours. You might know this as the first game ever made. Well, I recreated it for mIRC, with some additions. A two-player game in which you have to prevent the ball from hitting your side of the border of the screen.

What does it feature?
-Two-player game
-Pause function
-Point system
-Full-screen
-Cool!
-Smooth, buffered.

So how do you play it?
You put the whole script into your remote.ini or a new file.
Then, you can either type /pingpong or click right in a channel and click "Play Pong!".
Player left plays with the up and down arrow keys. Right uses the Home and End keys. For more info, start the game and click "Controls". Gotta pee? Press the spacebar to pause the game. Or press Q to quit the game.

Screenshot!
Image

;BOF
;Pong 1.1
;Made by CAsercan3 on February the 9th, 2009.
;To install, paste this script into your remotes (alt+R)
;Then type /pingpong, or right click the channel and click "Play Pong!".
;If you need any help, click on "Controls".
menu channel {
  Play pong!: pingpong
}
alias pingpong {
  window -paxdok0 +d @pongbuf
  window -paxdok0 +d @pong
  drawdot @pong 1 3000 0 0
  drawtext @pong 0 Algerian 150 400 200 Pong
  drawtext @pong 3 Algerian 20 530 200 Sercan's
  drawtext @pong 0 Algerian 20 530 400 Start Game
  drawtext @pong 0 Algerian 20 541 450 Controls
  drawtext @pong 0 Algerian 20 565 500 Quit
}
menu @pong {
  mouse: {
    if ( %game == 1 ) halt
    if ($true == $inpoly($mouse.x , $mouse.y , 560 , 500 , 560 , 540 , 650 , 540 , 650 , 500)) drawdot @pong 9 10 550 510
    if ($true != $inpoly($mouse.x , $mouse.y , 560 , 500 , 560 , 540 , 650 , 540 , 650 , 500)) drawdot @pong 1 10 550 510
    if ( %game2 == 1 ) halt
    if ($true == $inpoly($mouse.x , $mouse.y , 525 , 400 , 525 , 440 , 700 , 440 , 700 , 400)) drawdot @pong 9 10 515 410
    if ($true != $inpoly($mouse.x , $mouse.y , 525 , 400 , 525 , 440 , 700 , 440 , 700 , 400)) drawdot @pong 1 10 515 410
    if ($true == $inpoly($mouse.x , $mouse.y , 535 , 450 , 535 , 490 , 650 , 490 , 650 , 450)) drawdot @pong 9 10 525 460
    if ($true != $inpoly($mouse.x , $mouse.y , 535 , 450 , 535 , 490 , 650 , 490 , 650 , 450)) drawdot @pong 1 10 525 460
  }
  sclick: {
    if ($true == $inpoly($mouse.x , $mouse.y , 560 , 500 , 560 , 540 , 650 , 540 , 650 , 500)) && ( %game2 == 1 ) { window -c @pong | pingpong | unset %game2 }
    if ( %game == 1 ) || ( %game2 == 1 ) halt
    if ($true == $inpoly($mouse.x , $mouse.y , 525 , 400 , 525 , 440 , 700 , 440 , 700 , 400)) pp 
    if ($true == $inpoly($mouse.x , $mouse.y , 535 , 450 , 535 , 490 , 650 , 490 , 650 , 450)) {
      set %game2 1
      drawdot @pong 1 3000 0 0
      drawtext @pong 0 Arial 20 450 120 Pong was made by CAsercan3.
      drawtext @pong 0 Arial 20 250 140 This is a two-player game. Prevent the ball from hitting the left/right side!
      drawtext @pong 0 Arial 20 300 160 Left controls the white paddle with the up and down arrow keys. 
      drawtext @pong 0 Arial 20 300 180 Right controls the yellow pad with Home and End keys.
      drawtext @pong 0 Arial 20 300 200 Press space bar to pause/continue. Press Q to close the game.
      drawtext @pong 0 Arial 20 300 220 Thanks to BlueThen for interesting me with his fun picwins :D
      drawtext @pong 0 Arial 20 450 240 Be sure to visit IRC.CA-clan.com! 
      drawtext @pong 0 Algerian 20 565 500 Back
    }
    if ($true == $inpoly($mouse.x , $mouse.y , 560 , 500 , 560 , 540 , 650 , 540 , 650 , 500)) { window -c @pong
      window -c @pongbuf
    }
  }
}
alias -l pp {
  set %game 1
  window -paxdok0 +d @Pong
  .timerpong -m 0 18 screenupdate
  set %y 400
  set %2y 400
  set %direction 1
  set %xball 120
  set %yball 0
  set %rico 0
  set %base 450
  set %speed 7
  set %colorline 1
}
on *:keydown:@pong:*: {
  if ( $keyval == 40 ) set %40down 1
  if ( $keyval == 38 ) set %38down 1
  if ( $keyval == 35 ) set %35down 1
  if ( $keyval == 36 ) set %36down 1
  if ( $keyval == 32 ) && ( %game == 1 ) {
    if ( %gameover == 1 ) {
      unset %gameover %points
      pp
      halt
    }
    if ( %pause == 0 ) || ( %pause == $null ) { set %pause 1
      .timerpong -p
      .drawtext @pong 0 Alba 40 530 400 PAUSED
      halt
    }
    if ( %pause == 1 ) { set %pause 0
      .timerpong -r
      halt
    }
  }
  if ( $keyval == 81 ) {
    window -c @pong
    window -c @pongbuf
    unset %y %2y %xball %yball %base %direction %game %game2 %pause %gameover %speed %rico %40down %38down %points %35down %36down
    .timerpong off
  }
}
on *:keyup:@pong:*: {
  if ( $keyval == 40 ) set %40down 0
  if ( $keyval == 38 ) set %38down 0
  if ( $keyval == 35 ) set %35down 0
  if ( $keyval == 36 ) set %36down 0
}
on *:close:@pong: {
  unset %y %2y %xball %yball %base %direction %game %game2 %pause %gameover %speed %rico %40down %38down %points %35down %36down
  .timerpong off
}
alias -l screenupdate {
  inc %points .002
  if ( %xball < 0 ) {
    .timerpong off
    set %gameover 1
    drawtext @pong 0 Algerian 150 195 200 Game Over
    drawtext @pong 4 Tahoma 50 330 410 Right wins! Score: $calc(%points * %speed)
    drawtext @pong 0 Algerian 30 300 470 Press spacebar to restart, or Q to quit.
    halt
  }
  if ( %xball > $window(@pong).w ) {
    .timerpong off
    set %gameover 1
    drawtext @pong 0 Algerian 150 195 200 Game Over
    drawtext @pong 9 Tahoma 50 330 410 Left wins! Score: $calc(%points * %speed)
    drawtext @pong 0 Algerian 30 300 470 Press spacebar to restart, or Q to quit.
    halt
  }
  if ( %yball < 0 ) { set %rico $calc(%rico *-1) 
  set %base $calc(%yball - %base) }
  if ( %yball > $calc($window(@pong).h ) ) { 
    set %rico $calc(%rico *-1) 
    set %base $calc( $window(@pong).h - %base + %yball )  
  } 
  if ( %direction == 1 ) inc %xball $calc(%speed - $abs(%rico) *3)
  if ( %direction == 0 ) dec %xball $calc(%speed - $abs(%rico) *3)
  if ( $true == $inpoly(%xball , %yball , 98 , %y , 98 , $calc(%y + 100) , 118 , $calc(%y + 100) , 118 , %y )) {
    set %base %yball
    set %direction 1
    set %rico $calc($calc(%yball - 50 - %y) / $calc(37 - %speed))
    if ( %speed < 15 ) inc %speed .25
  }
  if ( $true == $inpoly(%xball , %yball , $calc($window(@pong).w - 98) , %2y , $calc($window(@pong).w - 98) , $calc(%2y + 100) , $calc($window(@pong).w - 118) , $calc(%2y + 100) , $calc($window(@pong).w - 118) , %2y )) {
    set %base %yball
    set %direction 0
    set %rico $calc($calc(%yball - 50 - %2y) / $calc(37 - %speed))
    if ( %speed < 15 ) inc %speed .25
  }
  if ( %35down == 1) && ( $calc(%2y + 100) !>= $window(@pong).h ) inc %2y 10
  if ( %36down == 1) && ( %2y !< 0 ) dec %2y 10
  if ( %40down == 1 ) && ( $calc(%y + 100) !>= $window(@pong).h ) inc %y 10
  if ( %38down == 1 ) && ( %y !< 0 ) dec %y 10
  if ( %direction == 1 ) set %yball $calc(%base + %rico * $calc(%xball - 100) )
  if ( %direction == 0 ) set %yball $calc(%base + -1 * %rico * $calc(%xball - $calc($window(@pong).w - 100)))
  drawdot @pongbuf 1 3000 0 0
  drawline @pongbuf 4 3 $calc($window(@pong).w - 100) %2y $calc($window(@pong).w - 100) $calc(%2y + 100)
  drawline @pongbuf 9 3 100 %y 100 $calc(%y + 100)
  ;if ( %speed >= 8 ) drawdot -r @pongbuf $hsv(%xball ,150, 240 ) 8 %xball %yball 
  ;else drawdot -r @pongbuf $hsv(%xball ,%xball, %xball ) 8 %xball %yball 
  drawdot -r @pongbuf $hsv(%xball ,240, 200) 8 %xball %yball 
  drawcopy @pongbuf 0 0 $window(@pong).w $window(@pong).h @pong 0 0
  ;drawtext @pongbuf 0 Arial 12 30 30 Score: $calc(%points * %speed)
}
alias -l hsv {   
  var %h $$1,%s $$2,%v $$3,%hi $calc($int($calc(%h / 60)) % 6),%f $calc(%h / 60 - %hi),%p $calc(%v * (1 - %s)),%q $calc(%v * (1 - %f * %s)),%t $calc(%v * (1 - (1 - %f) * %s))  
  if (%hi = 0) { var %r %v,%g %t,%b %p } 
  if (%hi = 1) { var %r %q,%g %v,%b %p }  
  if (%hi = 2) { var %r %p,%g %v,%b %t } 
  if (%hi = 3) { var %r %p,%g %q,%b %v }  
  if (%hi = 4) { var %r %t,%g %p,%b %v } 
  if (%hi = 5) { var %r %v,%g %p,%b %q }
  var %r $int($calc(%r * 255)),%g $int($calc(%g * 255)),%b $int($calc(%b * 255)) 
  return $rgb(%r, %g ,%b)
}
;EOF

Comments

Sign in to comment.
TMFKSOFT   -  May 18, 2012

Not even that. Just do Ball x,y checking.
I've doing mine with a timer, checks ALL collision every .5 seconds.

 Respond  
Sorasyn   -  May 18, 2012

AI is easy, MountainDew has demonstrated this to a certain degree, in his Pong applet. Boolean would be quite useful for this, so when the ball bounces off your paddle it triggers the AI to track the incoming ball, thus setting the paddles Y coordinates to that of the ball.

 Respond  
TMFKSOFT   -  May 18, 2012

The AI!
IS SIMPLE! :)
You can do some maths to check where the Ball is. If its within 64 pixels of the second bat make the bat keep adding or taking 5. If you have a direction variable on the ball then you need to check the direction, give it some thought. I'm a games student at college so im willing to help. I'm writing my own version of this in mIRC myself!

 Respond  
  -  May 03, 2011

Awesome! Good work!

 Respond  
GreyFox   -  Mar 12, 2009

hmmm.... nice game... :)

 Respond  
Goldy58   -  Feb 16, 2009

try to make a socket to ur self. if it works for you, then it can work for anyone else ;). Looking fofward for your next update :). That wat i did to make my chat script.

PunkTuReD: btw there was a "mario" mirc game i once seen

Actually, there is. You find it at http://www.picwin.tk in the examples place.

 Respond  
sercan386   -  Jan 26, 2009

An AI won't come, probably, I'm working on an online function. But i can't test those sockets when i dont have anyone to test it with :(

 Respond  
Firstmate   -  Jan 25, 2009

You can clean up some of the code. for example change:

alias endgame2 {
  .timerpong off
  set %gameover 1
  drawtext @pong 0 Algerian 150 195 200 Game Over
  drawtext @pong 9 Tahoma 50 330 410 Left wins! Score: $calc(%points * %speed)
  drawtext @pong 0 Algerian 30 300 470 Press spacebar to restart, or Q to quit.
  halt
}
alias endgame1 {
  .timerpong off
  set %gameover 1
  drawtext @pong 0 Algerian 150 195 200 Game Over
  drawtext @pong 4 Tahoma 50 330 410 Right wins! Score: $calc(%points * %speed)
  drawtext @pong 0 Algerian 30 300 470 Press spacebar to restart, or Q to quit.
  halt
}

TO:

alias endgame {
  .timerpong off
  set %gameover 1
  drawtext @pong 0 Algerian 150 195 200 Game Over
  drawtext @pong 9 Tahoma 50 330 410 $1 wins! Score: $calc(%points * %speed)
  drawtext @pong 0 Algerian 30 300 470 Press spacebar to restart, or Q to quit.
  halt
}

And then just type /endgame [left/right]
Instead of putting a separate alias for both.

 Respond  
Kirby   -  Jan 25, 2009

Very well made Pong Game.
When I first saw it, I thought it was made by BlueThen. XD
Some things I would recommend:

  • Make it so you can play against a computer?
  • Speed up the ball as the game progresses?
  • Allow player(s) to change keys to move their "paddle" up/down?
 Respond  
Prelude   -  Jan 24, 2009

Deleted my comment again? Any reason you care to share for my 2 previous comments being removed?.

 Respond  
Firstmate   -  Jan 24, 2009

I don't like the fullscreen.
And I can't exit properly.

Otherwise, it's cool :D

 Respond  
Goldy58   -  Jan 24, 2009

Try making Sockets

10/10

 Respond  
irchainscriptz   -  Jan 24, 2009

yeah would be fun, like Andy did with the tank game. would be more fun also :)

 Respond  
BlueThen   -  Jan 24, 2009

You need to add some buffering. :)

 Respond  
sercan386   -  Jan 24, 2009

kk guys everything is fixed now u use the home n end keys sorry for the menu bug i dont have any menus on status windows so i didnt see... now all have fun. also sockets would be hard but i'll try.

 Respond  
PuNkTuReD   -  Jan 24, 2009

yea playin 2 player isnt fun unless youve got split personality disorder
yaaayyyyyyyy

reckon you could make it a socket to socket? lol

 Respond  
Aucun50   -  Jan 24, 2009

9/10 Fun but it does get boring :)

 Respond  
sercan386   -  Jan 24, 2009

its fixed now... and that pong text is not to be fixed by me atm.

 Respond  
PuNkTuReD   -  Jan 24, 2009

apart from my menu popping up every time i right clicked
i loved it pure 10/10 from me
i love to see mirc doing things like this
brilliant
btw there was a "mario" mirc game i once seen
it was basically one level with nothing to do in that level but maybe you could tinker with it

 Respond  
Aucun50   -  Jan 24, 2009

IF( Unknown command

IF( Unknown command

Still plus if you have a menu it shows up on screen when your right click.

The pong being off to the side my comps fault (wide screen)

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.