Ping v1.0
by Presto
⤓ Download · 11.5 KBLet's just call it a dare... Okay, let's be more honest and call it a waste of time. But when GrymReaper suggested that it would be fun to have an in-game pongHUD, I just had to give it a try. This is the result: Ping version 1.0! Yeah, it's Breakout, not Pong, but hey I think it's more fun. By default it uses ALT-P and the keypad keys Up, Down, and Insert (start game). You can change these in the code - make sure to read the file before running it!
- Filename
Ping.cs- Size
- 11.5 KB (listed 11.5KB)
- Type
- CS
- Version
- 1.0
- Developer
- Presto
- Date
- 2009-01-15 (theexiled upload)
- Format
- ASCII text, with CRLF line terminators
Readme — Ping.cs (from the archive itself)
// -- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ------
// Ping.CS Presto, March '99
//
// The game of "Pong" (I know it's actually a breakout clone but
// "Pong" has a cooler name)
//
// I would have never even thought to write this script had it not been
// for an amazingly creative suggstion by GrymReaper...
//
// Requires the PrestoPack v0.92 or higher
//
// Installation:
// 1. Drop it in your config directory
// 2. Change this line from false to true:
$PrestoPref::Pong = true;
// 3. Change these keys as necessary:
$PrestoPref::PongUp = "numpad8";
$PrestoPref::PongDown = "numpad2";
$PrestoPref::PongStart = "numpad0";
$PrestoPref::PongToggle = "alt p";
// 4. Change the position as necessary
// Specify as "X Y ROWS COLUMNS"
$PrestoPref::PongPosition = "10 75 9 7";
// 5. Adjust the rest of these parameters to your liking
$Pong::ballsPerGame = 3;
$Pong::gameSpeed = 3; // increases with each level anyway
$Pong::frameRate = 0.05; // probably shouldn't touch. update speed.
// 6. Add it to your autoexec.cs if you want, or just exec(Ping);
// at the console.
//
// ---------------------------------------------------------------------------
Include("presto\\HUD.cs");
Include("presto\\Say.cs");
// ======================================
// Dyn routines
// ======================================
function Pong::PaddleDirY(%dir, %dy) {
$Pong::paddle[%dir] = %dy;
}
function Pong::BallDirY(%dy) {
$Pong::ballDY = %dy;
}
function Pong::BallDirX(%dx) {
$Pong::ballDX = %dx;
}
function Pong::MovePaddle() {
if ($Pong::mode == demo)
$Pong::paddleY = $Pong::ballY;
else {
$Pong::paddleY += $Pong::paddle[up];
$Pong::paddleY += $Pong::paddle[down];
if ($Pong::paddleY < 0)
$Pong::paddleY = 0;
if ($Pong::paddleY > $Pong::rows * $Pong::brickSizeY - 1)
$Pong::paddleY = $Pong::rows * $Pong::brickSizeY - 1;
}
Pong::DrawPaddle();
}
function Pong::MoveBall() {
if ($Pong::ballX == -999)
return;
%brickX = floor(($Pong::ballX + $Pong::ballDX) / $Pong::brickSizeX);
%brickY = floor($Pong::ballY / $Pong::brickSizeY);
if ($Pong::brickState[%brickX, %brickY] > 0) {
$Pong::ballDX = -$Pong::ballDX;
Pong::HitBrick(%brickX, %brickY);
%hit = true;
}
%brickX = floor($Pong::ballX / $Pong::brickSizeX);
%brickY = floor(($Pong::ballY + $Pong::ballDY) / $Pong::brickSizeY);
if ($Pong::brickState[%brickX, %brickY] > 0) {
$Pong::ballDY = -$Pong::ballDY;
Pong::HitBrick(%brickX, %brickY);
%hit = true;
}
if ($Pong::ballDX == 1 && $Pong::ballX >= $Pong::paddleX && $Pong::ballX < ($Pong::paddleX + 6)) {
%d = $Pong::ballY - $Pong::paddleY;
if (%d > -10 && %d < 10) {
if (%d < -3) {
if ($Pong::ballDY < 0)
$Pong::ballDY--;
else $Pong::ballDY = -1;
}
else if (%d > 3) {
if ($Pong::ballDY > 0)
$Pong::ballDY++;
else $Pong::ballDY = 1;
}
$Pong::ballDX = -$Pong::ballDX;
}
}
$Pong::ballY += $Pong::ballDY;
if ($Pong::ballY >= $Pong::rows * $Pong::brickSizeY - 1) {
$Pong::ballY = $Pong::rows * $Pong::brickSizeY - 1;
$Pong::ballDY = -$Pong::ballDY;
}
else if ($Pong::ballY <= 0) {
$Pong::ballY = 0;
$Pong::ballDY = -$Pong::ballDY;
}
$Pong::ballX += $Pong::ballDX;
if ($Pong::ballX >= 130)
Pong::Miss();
else if ($Pong::ballX <= 0) {
$Pong::ballX = 0;
$Pong::ballDX = -$Pong::ballDX;
}
if ($Pong::brickState == 0)
Pong::NewLevel();
else if (%hit)
Pong::DrawBricks();
Pong::DrawBall();
}
function Pong::Update() {
Pong::DisplayGameMode();
for (%i = 0; %i < $Pong::speed; %i++) {
Pong::MoveBall();
if ((%i/2) == floor(%i/2))
Pong::MovePaddle();
}
return $Pong::frameRate;
}
function Pong::NewPlayfield() {
%x = getWord($PrestoPref::PongPosition,0);
%y = getWord($PrestoPref::PongPosition,1);
%rows = getWord($PrestoPref::PongPosition,2);
%cols = getWord($PrestoPref::PongPosition,3);
if (%rows > 6)
$Pong::rows = %rows;
else $Pong::rows = 6;
if (%cols > 4)
$Pong::cols = %cols;
else $Pong::cols = 4;
HUD::NewFrame(hudPong, Pong::Update, %x,%y,200, $Pong::rows*$Pong::brickSizeY + 6);
$Pong::ball = HUD::AddObject(hudPong, FearGuiFormattedText, 4,-2,200,$Pong::rows*$Pong::brickSizeY + 6);
$Pong::objScore = HUD::AddObject(hudPong, FearGuiFormattedText, 0,0,200,$Pong::rows*$Pong::brickSizeY + 6);
$objPaddle = HUD::AddObject(hudPong, FearGuiFormattedText, 4 + $Pong::paddleX,-2,50,$Pong::rows*$Pong::brickSizeY + 6);
for (%c = 0; %c < %cols; %c++)
$Pong::col[%c] = HUD::AddObject(hudPong, FearGuiFormattedText, 4+(%c * $Pong::brickSizeX),-2,$Pong::brickSizeX,$Pong::rows*$Pong::brickSizeY + 6);
$objMessage = HUD::AddObject(hudPong, FearGuiFormattedText, 0,$Pong::rows*6-3,200,$Pong::brickSizeY);
$Pong::mode="";
Pong::SetGameMode(init);
}
function Pong::NewBricks() {
deleteVariables("$Pong::brickState*");
$Pong::brickState = 0;
for (%c = 0; %c < $Pong::cols; %c++) {
for (%r = 0; %r < $Pong::rows; %r++) {
if (%c == 0)
%brick = 0;
else if (getRandom() * 100 < $Pong::percent)
%brick = 2;
else %brick = 1;
$Pong::brickState[%c,%r] = %brick;
$Pong::brickState += $Pong::brickState[%c,%r];
}
}
Pong::DrawBricks();
}
function Pong::NewLevel() {
if ($pong::mode == "play") {
if ($Pong::percent < 100)
$Pong::percent += 25;
if ($Pong::speed < 10)
$Pong::speed += 0.75;
}
Pong::NewBricks();
Pong::NewBall();
}
function Pong::NewBall() {
$Pong::ballDY = 0;
$Pong::ballDX = 0;
$Pong::ballY = ($Pong::rows * $Pong::brickSizeY) / 2;
$Pong::ballX = ($Pong::cols * $Pong::brickSizeX) + 3;
if ($Pong::mode == "play") {
Pong::DrawScore();
Pong::PushGameMode(ready);
}
else Pong::LaunchBall();
}
function Pong::LaunchBall() {
$Pong::ballDY = 1;
$Pong::ballDX = 1;
}
function Pong::HitBrick(%x,%y) {
$Pong::brickState[%xSource: The Exiled — Tribes Repository
Original page: https://library.theexiled.pwnageservers.com/file.php?id=537
Archived source HTML: theexiled/mirror-html/file/537.html
Original page: https://library.theexiled.pwnageservers.com/file.php?id=537
Archived source HTML: theexiled/mirror-html/file/537.html