Skip to content

Commit 7c13021

Browse files
authored
Add files via upload
1 parent fcb2a41 commit 7c13021

9 files changed

+872
-0
lines changed

BUILD

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
-To make "numberattack" you must have the following dependencies installed:-
2+
3+
libncurses/libcurses/libncurses5-dev build-essential
4+
5+
6+
-After the dependencies are installed type the following to compile (ignore the warnings...):
7+
8+
make
9+
10+
11+
-To install, type the following:
12+
13+
./install.sh
14+
15+
-To uninstall, type the following:
16+
17+
./uninstall.sh

COPYING

+674
Large diffs are not rendered by default.

INSTALL

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
To install, type "./install.sh".
2+
This script copys the compiled binary to /usr/games
3+
4+
One can change the location of the install if desired... altho uninstall.sh will no longer work.

LICENSE

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"Number Attack!" is provided under the GNU General Public License version 3 (GNU GPLv3)
2+
3+

Makefile

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CC=gcc
2+
CFLAGS=-lcurses
3+
#DEPS = libncurses5
4+
5+
#%.o %.c $(DEPS)
6+
# $(CC) -c -o $@ $< $(CFLAGS)
7+
8+
mainfile: numattack.c
9+
$(CC) -o numattack numattack.c $(CFLAGS)
10+
11+
$(info ignore the warnings...)

UNINSTALL

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
To uninstall, type "./uninstall.sh".
2+
This script deletes the file "/usr/games/numattack"
3+
4+
if you installed "Number Attack!" into a different directory,
5+
don't use this script!

install.sh

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
3+
#This script installs the game "Number Attack!" onto the system at /usr/games/numattack
4+
5+
echo Make sure this script is run as root!
6+
7+
mkdir /usr/games/numattack
8+
cp ./numattack /usr/games/numattack
9+
chmod 555 /usr/games/numattack/numattack
10+
echo Done.

numattack.c

+141
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
/* Copyright 2019
2+
3+
This program is free software; you can redistribute it and/or modify
4+
it under the terms of the GNU General Public License as published by
5+
the Free Software Foundation, Inc., 675 Mass Ave, Cambridge MA 02139,
6+
USA; either version 2 of the License, or (at your option) any later
7+
version; incorporated herein by reference.
8+
*/
9+
10+
#include <stdio.h>
11+
#include <curses.h>
12+
#include <time.h>
13+
#include <math.h>
14+
15+
int wall[7];
16+
int score=0;
17+
int enemyx;
18+
int enemyy;
19+
int enemyval;
20+
int play=1;
21+
int enemydelay=5000;
22+
int tmp;
23+
int counter;
24+
int level=1;
25+
bool debug=0;
26+
WINDOW *canvas;
27+
time_t startstamp;
28+
time_t endstamp;
29+
int main(int argc, char *argv[])
30+
{
31+
if(argc==2){
32+
if(!strcmp(argv[1],"-d")){
33+
debug=1;
34+
}
35+
}
36+
printf("(U");
37+
startstamp=time(NULL);
38+
srand(time(NULL));
39+
//init
40+
canvas=initscr();
41+
noecho();
42+
cbreak();
43+
nodelay(stdscr,TRUE);
44+
curs_set(0);
45+
newenemy();
46+
//main loop
47+
while(play){
48+
enemyx--;
49+
draw();
50+
refresh();
51+
if(enemyx==0){
52+
draw();
53+
beep();
54+
if(wall[enemyy]==0){
55+
wall[enemyy]=1;
56+
score=score-enemyval;
57+
newenemy();
58+
}else{
59+
play=0;
60+
}
61+
}
62+
for(counter=0;counter<enemydelay;counter++){
63+
usleep(1);
64+
tmp=getch();
65+
if(tmp != -1){
66+
attack();
67+
}
68+
}
69+
}
70+
endwin();
71+
printf("Your score was: %d\n",score);
72+
endstamp=time(NULL);
73+
printf("You have been playing for %d seconds\n",endstamp-startstamp);
74+
printf("Thank you for playing Number Attack!\n");
75+
return 0;
76+
}
77+
int draw(){
78+
clear();
79+
for(int a=0;a<7;a++){
80+
move(a,0);
81+
if(wall[a]==0){
82+
printw("#");
83+
}else{
84+
printw(" ");
85+
}
86+
}
87+
move(enemyy,enemyx);
88+
printw("%d",enemyval);
89+
mvprintw(7,0,"score: %d",score);
90+
if(debug){
91+
mvprintw(8,0,"enemy delay: %d", enemydelay);
92+
}
93+
}
94+
int newenemy(){
95+
enemyval=(rand()%10);
96+
enemyx=22;
97+
enemyy=(rand()%7);
98+
}
99+
int attack(){
100+
if((tmp==48)&&(enemyval==0)){ //winning
101+
score++;
102+
beep();
103+
if((score%10)==0){
104+
level++;
105+
}
106+
if(enemydelay>1000){
107+
enemydelay-=100;
108+
}else{
109+
enemydelay=1000;
110+
}
111+
newenemy();
112+
}
113+
if((tmp==49)&&(enemyval==1)){
114+
enemyval--;
115+
}
116+
if((tmp==50)&&(enemyval==2)){
117+
enemyval--;
118+
}
119+
if((tmp==51)&&(enemyval==3)){
120+
enemyval--;
121+
}
122+
if((tmp==52)&&(enemyval==4)){
123+
enemyval--;
124+
}
125+
if((tmp==53)&&(enemyval==5)){
126+
enemyval--;
127+
}
128+
if((tmp==54)&&(enemyval==6)){
129+
enemyval--;
130+
}
131+
if((tmp==55)&&(enemyval==7)){
132+
enemyval--;
133+
}
134+
if((tmp==56)&&(enemyval==8)){
135+
enemyval--;
136+
}
137+
if((tmp==57)&&(enemyval==9)){
138+
enemyval--;
139+
}
140+
draw();
141+
}

uninstall.sh

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/sh
2+
3+
#This script is used to uninstall "Number Attack!" from /usr/games/
4+
5+
echo Make sure this script is run as root!
6+
rm -R /usr/games/numattack
7+
echo Done.

0 commit comments

Comments
 (0)