Pickle's Ping Pong game!

By pickle16 on Dec 10, 2009

Its a ping pong game!
you use the mouse to move your paddle
while the AI tries to hit the ball which it sometimes doesn't succed so its possible to win :)

i hope you like :)

-fixes:
Pysics engine (ball now bounces in the same direction it was original going)
removed the unnesscary click and restart.

################################
## Pickle's ping pong v2.0    ##
## use mouse to move player 1 ##
##    press p to puase        ##
################################
alias pp.START {
  window -paohCzdk0 +tnbL @pp.hide 5 5 500 350 |  window -paCzdk0 +tnbL @Pickle's_Ping 5 5 500 350 
  set %d + | set %p 140 | set %p2 140 | set %pp 250 | set %pp2 160 | set %pscore 0 | set %pscore2 0
  .timerpong -mo 0 100 pp.draw 
}
alias pp.draw {
  clear @pp.hide
  if (%pp isnum 450 - 451 && %pp2 isnum %p - $calc(%p + 35)) { 
    if (%d2 == d) { set %d2 d } 
    else { set %d2 u }
    set %d - | beep 1
  }
  if (%pp isnum 450 - 451 && %pp2 isnum %p - $calc(%p + 5)) { set %d - | unset %d2 | beep 1 }
  if (%pp isnum 450 - 451 && %pp2 isnum $calc(%p + 25) - $calc(%p + 30)) { 
    if (%d2 == u) { set %d2 u }
    else { set %d2 d }
    set %d - | beep 1
  }
  if (%pp isnum 40 - 45 && %pp2 isnum %p2 - $calc(%p2 + 35)) { set %d + | unset %d2 | beep 1 }
  if (%pp isnum 40 - 45 && %pp2 isnum %p2 - $calc(%p2 + 5)) { 
    if (%d2 == d) { set %d2 d }
    else { set %d2 u }
    set %d + | beep 1
  }
  if (%pp isnum 40 - 45 && %pp2 isnum $calc(%p2 + 25) - $calc(%p2 + 30)) { 
    if (%d2 == u) { set %d2 u }
    else { set %d2 d }
    set %d + | beep 1 
  }  
  if (%pp isnum  0- 500 && %pp2 isnum  0-10) { set %d2 d }
  if (%pp isnum  0- 500 && %pp2 isnum  319 - 350) { set %d2 u }
  if (%pp isnum  490- 500 && %pp2 isnum  0-500) { set %d + | inc %pscore 1 | set %pp 250 | set %pp2 160 | unset %d2 | set %p 140 | set %p2 140 | set %pp 250 | set %pp2 160 | timerpong -p | .timertemp 1 1  .timerpong -r }
  if (%pp isnum  0- 10 && %pp2 isnum  0-500) { set %d - | inc %pscore2 1 | set %pp 250 | set %pp2 160 | unset %d2 | set %p 140 | set %p2 140 | set %pp 250 | set %pp2 160 | timerpong -p | .timertemp 1 1  .timerpong -r }
  if (%d2 == d) { set %pp2 $calc(%pp2 + 10) }
  if (%d2 == u) { set %pp2 $calc(%pp2 - 10) }
  set %pp $calc(%pp %d 10) 
  drawfill @pp.hide 1 1 1 1
  drawtext @pp.hide 0 arial 25 320 2 %pscore2
  drawtext @pp.hide 0 arial 25 150 2 %pscore 
  drawline @pp.hide 0 6 250 0 250 400
  drawline @pp.hide 0 5 450 %p 450 $calc(%p + 30) 
  drawline @pp.hide 0 5 40 %p2 40 $calc(%p2 + 30) 
  drawdot @pp.hide 0 5 %pp %pp2
  if (%pa == p) { drawtext @pp.hide 0 arial 5 250 25 Paused! }
  PP.AI
  drawcopy -t @pp.hide 14 1 1 500 350  @Pickle's_Ping 1 1 500 350
}
alias PP.AI {
  if (%pp isnum 0-250) { 
    if (%pp2 > $calc(%p2 -15)) { set %p2 $calc(%p2 + 15) }
    if (%pp2 < $calc(%p2 +15)) { set %p2 $calc(%p2 - 15) }
  }   
  else {
    if (%p2 >= 130) { set %p2 $calc(%p2 - 15) }
    if (%p2 <= 160) { set %p2 $calc(%p2 + 15) }
    if (%p2 == 145) { set %p2 145 }
  }
}
alias endping { window -c @pp.hide | .timerpong* off | unset %p* | unset %d* | unset %pa }
menu nicklist,status,channel,menubar {
  games :
  .Ping : pp.start
}
menu @Pickle's_ping {
  mouse : { set %p $calc($mouse.y - 10) }
}
on *:keydown:@Pickle's_ping:*:{
  if ($keyval == 80) {  
    if (%pa == $null) { set %pa p | .timerpong -p }
    elseif (%pa == p) { unset %pa | .timerpong -r }
  }
}
on *:close:@Pickle's_ping:{ endping }

Comments

Sign in to comment.
pickle16   -  Dec 12, 2009

there all fixed.
always wonder why people putted dots before timers, thanks :)

 Respond  
Testor   -  Dec 12, 2009

.Timer[Stuff .. ] (So basically a . at the start).

 Respond  
pickle16   -  Dec 12, 2009

yeah the click is intentional i putted there so i could reset the game when i was testing it... i remove it. :)
and how do i silence timers?

 Respond  
Testor   -  Dec 11, 2009
  • Timer pong activated
  • Timer pong paused
    Silencing your timers is a good idea, so you dont get that. Also there's a bug. idk if it can be fixed, or is intentional, but when you click it resets :3.
    Also, i believe using elseif in statement two here should remove the need to Halt it.

on :keydown:@Pickle's_ping::{
if ($keyval == 80) {
if (%pa == $null) { set %pa p | timerpong -p | halt }
if (%pa == p) { unset %pa | timerpong -r }
}
}

 Respond  
DarkCoder   -  Dec 10, 2009

Good game, fix the ball always going the same direction o.o?

 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.