--- a/proto/Player.hh Sun Nov 09 22:02:03 2008 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,17 +0,0 @@
-#ifndef PLAYER_HH
-#define PLAYER_HH
-
-#include "coor.hh"
-
-class Player {
-public:
- Player()
- : xy(140.0, 140.0), xy2(140.0, 140.0) {
-
- }
-
- coor<double> xy;
- coor<double> xy2;
-};
-
-#endif
--- a/proto/coor.hh Sun Nov 09 22:02:03 2008 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-#ifndef COOR_H
-#define COOR_H
-
-//#define TYPE double
-
-template <typename TYPE>
-class coor {
-public:
- TYPE x;
- TYPE y;
- coor() {
- x = 0; y = 0;
- }
- coor(TYPE X, TYPE Y) {
- x = X;
- y = Y;
- }
- coor(const coor& c) {
- x = c.x;
- y = c.y;
- }
- void operator = (const coor& c) {
- x = c.x;
- y = c.y;
- }
- coor operator + (const coor& c) {
- return coor(x+c.x, y+c.y);
- }
- coor operator - (const coor& c) {
- return coor(x-c.x, y-c.y);
- }
- void operator += (const coor& c) {
- x += c.x;
- y += c.y;
- }
-
- coor operator * (const double d) {
- return coor(x*d, y*d);
- }
-
-};
-
-template<typename T>
-bool operator== (const coor<T>& c1, const coor<T>& c2) {
- return ((c1.x == c2.x) && (c1.y == c2.y));
-}
-
-#endif
--- a/proto/game_state.hh Sun Nov 09 22:02:03 2008 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,25 +0,0 @@
-#ifndef GAME_STATE_HH
-#define GAME_STATE_HH
-
-#include "Player.hh"
-
-class game_state {
-public:
- game_state() : cave_width(640), cave_height(480), cave(640*480) {
- for(int i = 0; i < 60000; i++) {
- int x = i%300;
- int y = i/300;
- cave[x+100+(y+100)*640] = 1;
- }
- }
- void addPlayer(Player p) {
- players.push_back(p);
- }
-
- std::vector<int> cave;
- int cave_width;
- int cave_height;
- std::vector<Player> players;
-};
-
-#endif
--- a/proto/t2t.cc Sun Nov 09 22:02:03 2008 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,115 +0,0 @@
-#include <ClanLib/core.h>
-#include <ClanLib/gl.h> //do I need this in linux?
-#include <ClanLib/display.h>
-#include <ClanLib/application.h>
-#include "coor.hh"
-#include "game_state.hh"
-#include "Player.hh"
-
-class CL_Game : public CL_ClanApplication {
-private:
- bool keep_going;
- void check_input() {
- if(CL_Keyboard::get_keycode(CL_KEY_ESCAPE))
- keep_going = false;
- if(CL_Keyboard::get_keycode(CL_KEY_UP)) {
- if(gs.cave[(int)(gs.players[0].xy.x+
- ((int)gs.players[0].xy.y+1)*640)] == 0) {
- gs.players[0].xy2.y += 4;
- }
- }
- if(CL_Keyboard::get_keycode(CL_KEY_LEFT)) {
- gs.players[0].xy2.x += 0.2;
- }
- if(CL_Keyboard::get_keycode(CL_KEY_RIGHT)) {
- gs.players[0].xy2.x -= 0.2;
- }
- }
-
-public:
- game_state gs;
-
- CL_Game() : keep_going(true) {}
- virtual int main(int argc, char **argv) {
- CL_SetupCore setup_init;
- CL_SetupDisplay setup_disp;
- CL_SetupGL setup_gl;
- gs.addPlayer(Player());
-
- CL_DisplayWindow win("ikkuna", 640, 480);
-// CL_Surface bg(CL_PNGProvider("image.png");
-
- unsigned int last_draw = CL_System::get_time();
- int r = 100, g = 100, b = 100;
- unsigned int frame_count = 0;
- bool R = false, G = false, B = false;
-
- while(keep_going) { //not good idea to put infinite loop
- CL_Display::clear(CL_Color(r, g, b));
-// bg.draw(0, 0);
-// CL_Display::fill_rect(CL_Rect((int)(x-10.0), (int)(y-10.0),
-// (int)(x+10.0),
-// (int)(y+10.0)), CL_Color(255-r, 255-g, 255-b));
- for(int i = 0; i < 640*480; i++) {
- int x = i%640;
- int y = i/640;
- CL_Color col = CL_Color(200, 100, 60);
- if(gs.cave[i] == 1) {
- col = CL_Color(50, 50, 200);
- }
- CL_Display::draw_pixel(x, y, col);
- }
- Player& pl1 = gs.players[0];
- int pl1xi = (int)(pl1.xy.x);
- int pl1yi = (int)(pl1.xy.y);
- CL_Display::fill_rect(CL_Rect(pl1xi-10, pl1yi-10,
- pl1xi+10, pl1yi+10), CL_Color(255-r, 255-g, 255-b));
-
- for(int i = 0; i < gs.players.size(); i++) {
- Player& pl2 = gs.players[i];
- pl2.xy2.y -= 0.2;
- double tmpx = pl2.xy.x, tmpy = pl2.xy.y;
- pl2.xy.x = 2*pl2.xy.x-pl2.xy2.x;
- pl2.xy.y = 2*pl2.xy.y-pl2.xy2.y;
- pl2.xy2.x = tmpx;
- pl2.xy2.y = tmpy;
- if(gs.cave[((int)(pl2.xy.x +
- ((int)pl2.xy.y)*640))%(640*480)] == 0) {
- pl2.xy = pl2.xy2;
- }
- }
-
- CL_Display::flip(1);
- frame_count++;
- unsigned int cur_draw = CL_System::get_time();
-
- check_input();
-
- if(R) { r++;
- } else { r--; }
- if(G) { g++;
- } else { g--; }
- if(B) { b++;
- } else { b--; }
- if(r < 0) r = 0;
- if(g < 0) g = 0;
- if(b < 0) b = 0;
- if(r > 255) r = 255;
- if(g > 255) g = 255;
- if(b > 255) b = 255;
-
- if(frame_count % 100 == 0) {
- R = rand()%2;
- G = rand()%2;
- B = rand()%2;
- }
-
- last_draw = cur_draw;
- CL_System::keep_alive();
-// sleep(10); //flip already wait a short amount of time
- }
- return 0;
- }
-};
-
-CL_Game inst;