// C Source File
// Created 1/14/2001; 01:31:52 PM
// Finished 2/14/2001; 06:28:12 PM
// Open Source C File with description#define RETURN_VALUE // Return Pushed Expression
#define OPTIMIZE_ROM_CALLS // Use ROM Call Optimization
#define SAVE_SCREEN // Save/Restore LCD Contents
#include <tigcclib.h> // Include All Header Files
short _ti89; // Produce .89Z File
int key,SPRITE_HEIGHT=16,x1=0,x2=0,y1=0,y2=0; // Define Vars
static unsigned int tank[] = // Define tank Sprite
{0x1FC0, 0x2ABF, 0x5550, 0xAAA8, 0xFFFF, 0x8889, 0x5DDE, 0x288C, 0x1FF8};
static unsigned int home[] = // Define home Sprite
{ 0x0780, 0x2FC0, 0x2FC0, 0x2780, 0x7308, 0x8B1C, 0x7336, 0x232A, 0x2355, 0x236B, 0x2336, 0x231C, 0x2336, 0x232A, 0xFFFF, 0xFFFF};void intro(void) { // Introduction
clrscr (); // Clear Screen
DrawStr (1,1,"Press ESC to exit",A_NORMAL); // Draws text to screen at x,y
DrawStr (1,9,"Press or Hold Buttons",A_NORMAL);
DrawStr (1,17,"Up, Down, Left,",A_NORMAL);
DrawStr (1,25,"or Right for movement.",A_NORMAL);
DrawStr (1,33,"Get to the BASE",A_NORMAL);
DrawStr (1,70,"Press Enter",A_NORMAL);
ngetchx (); // Waits for keypress
}inline void draw(int x1, int y1) { // Draws tank sprite to screen
Sprite16(x1, y1, 9, tank, LCD_MEM, SPRT_XOR);
}inline void erase(int x1, int y1) { // Erases (Redraws) tank sprite to screen
draw(x1,y1);
}void victory() { // Plays Victory screen
if (key != KEY_ESC) {
clrscr ();
DrawStr (1,2,"Victory!",A_NORMAL);
DrawStr (1,10,"You arrived at base.",A_NORMAL);
DrawStr (1,18,"*Press ESC*",A_NORMAL);
ngetchx (); // Waits for keypress
} else {
clrscr ();
DrawStr (1,2,"Loseory!",A_NORMAL);
ngetchx ();
}
}
void moveUp() { // Sets movements: UP
y1-=5;if (y1 < 1) {
y1=91;
} else if (y1 > 91) {
y1=1;
}
}void moveDown() { // Sets movements: DOWN
y1+=5;if (y1 < 1) {
y1=91;
} else if (y1 > 91) {
y1=1;
}
}void moveLeft() { // Sets movements: LEFT
x1-=5;if (x1 < 1) {
x1=144;
} else if (x1 > 144) {
x1=1;
}
}void moveRight() { // Sets movements: RIGHT
x1+=5;if (x1 < 1) {
x1=144;
} else if (x1 > 144) {
x1=1;
}
}void _main(void) { // Executes Commands
x2=random(144); // Random Placement of base
y2=random(84); // ""
intro();
clrscr();
draw(x1,y1);
Sprite16(x2, y2, SPRITE_HEIGHT, home, LCD_MEM, SPRT_XOR); //Places Base
while ((key = ngetchx()) != KEY_ESC) {
erase(x1,y1);
if (x1==(x2)|x1==(x2-1)|x1==(x2-2)|x1==(x2-3)|x1==(x2-4)|x1==(x2-5)|x1==(x2+1)|x1==(x2+2)|x1==(x2+3)|x1==(x2+4)|x1==(x2+5)|y1==(y2)|y1==(y2-1)|y1==(y2-2)|y1==(y2-3)|y1==(y2-4)|y1==(y2-5)|y1==(y2+1)|y1==(y2+2)|y1==(y2+3)|y1==(y2+4)|y1==(y2+5)) { // This checks for the placesment of the tank, if it is within 5 pixels left, right, up, or down it executes loop
break; // Thanx to a person on the net I found this command to break out of loops
} else if (key == KEY_UP) { //Reasons keypress and changes x and y
moveUp();
} else if (key == KEY_DOWN) {
moveDown();
} else if (key == KEY_LEFT) {
moveLeft();
} else if (key == KEY_RIGHT) {
moveRight();
} else if (key == KEY_UPRIGHT) {
moveUp();
moveRight();
} else if (key == KEY_DOWNLEFT) {
moveDown();
moveLeft();
}
draw(x1,y1);
}
victory(); // Executes victorypush_quantum(0xE9);
}/* This Project possible by:
David Ratliff: For his tutorials & mods.
Xavier Vassor: For the almighty TIGCC environment
Nick: I made it. *//* I request that if you modify this program please give me credit
for the hours I have spent on this educational tool. Hopefully
I will have a new version where you can shoot bullets and enemy
tanks.
Thank You*/