Initial import
authorlimb <limb@bc5cbbab-a4ec-0310-bb52-ff3d296db539>
Tue, 14 Nov 2006 18:55:08 +0000 (18:55 +0000)
committerlimb <limb@bc5cbbab-a4ec-0310-bb52-ff3d296db539>
Tue, 14 Nov 2006 18:55:08 +0000 (18:55 +0000)
git-svn-id: svn+ssh://svn/var/repos/curfender@513 bc5cbbab-a4ec-0310-bb52-ff3d296db539

Makefile [new file with mode: 0644]
layout.txt [new file with mode: 0644]
main.cpp [new file with mode: 0644]

diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..dbb4a59
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,26 @@
+CXX = g++
+INST = /usr/local/bin
+
+
+main: main.o
+       g++ -o curfender main.o -lncurses
+main.o: main.cpp
+       $(CXX) -g -c main.cpp
+install:
+       cp curfender $(INST)
+remove:
+       rm $(INST)/curfender
+uninstall: remove
+
+clean:
+       rm *.o
+       rm curfender
+
+
+
+
+
+
+
+
+
diff --git a/layout.txt b/layout.txt
new file mode 100644 (file)
index 0000000..b551acc
--- /dev/null
@@ -0,0 +1,25 @@
+12345678901234567890123456789012345678901234567890123456789012345678901234567890
+2
+3
+4      {=}
+5      
+6
+7
+8
+9
+0
+1
+2                    [
+3                    ]
+4                    [
+5                    ]
+6                    [
+7                    ]                                 
+8                    ^                        <_==>    <x==>  -  -  -  
+9                   /|\            x + x +     
+0-------------------------------------------------------------------------------
+1Lv:<=><=><=><=>|                        /         \                           |
+2               |                                                              |
+3               |                                                              |
+4 Score:XXXXXX  |                        \         /                           |   
+5
diff --git a/main.cpp b/main.cpp
new file mode 100644 (file)
index 0000000..e62deaa
--- /dev/null
+++ b/main.cpp
@@ -0,0 +1,197 @@
+#include <ncurses.h>
+#include <cstring>
+#include <cstdlib>
+
+int score;
+int lives;
+
+struct game_object {
+  int number; //object number
+  int active; //object active, 1 or 0
+  int x; // x vert position
+  int y; // y horiz position
+  int direction; //direction, 10-key numbers 2-4-6-8 default to 5, stationary
+  int face; // facing 0 left or 1 right
+  int speed; //speed
+  char line0[6]; //object: left
+  char line1[6]; //object: left
+};
+
+game_object process_motion(game_object object){
+  if(object.direction==2){
+    object.x = object.x+object.speed;
+  };
+  if(object.direction==8){
+    object.x = object.x-object.speed;
+  };
+  if(object.direction==6){
+    object.y = object.y+object.speed;
+  };
+  if(object.direction==4){
+    object.y = object.y-object.speed;
+  };
+
+  //bounds check
+  if(object.x<=0){
+    object.x=1;
+    object.direction=5;
+    object.speed=0;
+  };
+  if(object.x>=19){
+     object.x=18;
+     object.direction=5;
+     object.speed=0;
+  };
+
+  return object;
+
+}
+
+game_object process_direction(game_object object, int input){
+  if(input==65){input=8;};
+  if(input==67){input=6;};
+  if(input==68){input=4;};
+  if(input==66){input=2;};
+  if(input==69){input=5;};
+  if(input==object.direction){
+    object.speed++;
+  } else {
+    object.direction = input;
+    object.speed = 1;
+  };
+  if(input==4){object.face=0;};
+  if(input==6){object.face=1;};
+  if(object.speed>4){object.speed=4;};
+  return object;
+
+}
+
+int draw_object(game_object object, int drawlocation){
+  if(object.number==1){
+    if((object.y-drawlocation<5) and (object.direction==4)){
+      drawlocation=drawlocation-object.speed;
+    };
+    if((object.y-drawlocation>70) and (object.direction==6)){
+      drawlocation=drawlocation+object.speed;
+    };
+  };
+
+  if(object.active==1){
+    if(object.face==0){
+      mvprintw(object.x,object.y-drawlocation,"%s",object.line0);
+    };
+    if(object.face==1){
+      mvprintw(object.x,object.y-drawlocation,"%s",object.line1);
+    };
+  };
+  
+  return drawlocation;
+
+}
+
+void draw_board(int location){
+  // mvprintw(row,col,string,vars)
+  //top
+  mvprintw(0,0,"--------------------------------------------------------------------------------\n");
+  //bottom
+  mvprintw(19,0,"--------------------------------------------------------------------------------\n");
+  //left side of map
+  mvprintw(20,16,"|");
+  mvprintw(21,16,"|");
+  mvprintw(22,16,"|");
+  mvprintw(23,16,"|");
+  //right side of map
+  mvprintw(20,79,"|");
+  mvprintw(21,79,"|");
+  mvprintw(22,79,"|");
+  mvprintw(23,79,"|");
+  //visible box on map 33, 43
+  mvprintw(20,41,"/");
+  mvprintw(20,51,"\\");
+  mvprintw(23,41,"\\");
+  mvprintw(23,51,"/");
+  //Score
+  mvprintw(23,1,"Score:%8d",score);
+  //Lives
+  mvprintw(20,1,"Lv:");
+  int count = lives;
+  for(int x=4;count>0;x=x+3){
+    mvprintw(20,x,"<=>");
+    count--;
+  };
+  //Location
+  mvprintw(22,1,"Location:%3d", location);
+  
+}
+
+int main(){
+  score = 0;
+  lives = 4;
+
+  game_object player;
+  player.number = 1;
+  player.active = 1;
+  player.x = 5;
+  player.y = 30;
+  player.direction = 5;
+  player.face = 1;
+  player.speed = 0;
+  strcpy (player.line0, "<==_>");
+  strcpy (player.line1, "<_==>");
+  initscr();
+
+  //Check screen size 80x25
+
+  //Initialize world
+  //main loop
+
+  int loopvar = 0;
+  int input = 0;
+  int drawlocation = 0;
+
+  cbreak();
+  halfdelay(1);
+  noecho();
+
+  while(loopvar == 0){
+    
+    clear();
+    // Draw board
+    draw_board(player.y);
+
+    //process object motion
+    player = process_motion(player);
+
+    // Draw player object 1
+    drawlocation = draw_object(player, drawlocation);
+
+    // Draw pods objects 2-9
+    score++;
+    
+    // Draw gate object 10
+
+    // Draw enemies
+    
+    // Draw shots
+    
+    input = getch();
+    int perm = input;
+
+    printw("%d", perm);
+
+    if(input=='q'){loopvar=1;};
+    //check for / process direction change
+    if(input==66||input==68||input==67||input==65||input==69){
+      player = process_direction(player, input);
+    };
+    
+    //check for /process player fire
+
+  }; //end main loop
+
+  endwin();
+
+  return 0;  
+}