Skip to content

Commit

Permalink
A bunch of crap
Browse files Browse the repository at this point in the history
Broken shadow volumes
Broken motion blurs
Broken bump mapping
  • Loading branch information
Krishna committed Mar 22, 2010
1 parent 5879522 commit daa5376
Show file tree
Hide file tree
Showing 9 changed files with 515 additions and 551 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
SOURCES = $(wildcard *.cpp)
OBJECTS = $(SOURCES:.cpp=.o)
DEPENDS = $(SOURCES:.cpp=.d)
LDFLAGS = $(shell pkg-config --libs gtkmm-2.4 gtkglextmm-1.2 sdl) -lglut -lsdl_mixer
CPPFLAGS = $(shell pkg-config --cflags gtkmm-2.4 gtkglextmm-1.2 sdl)
LDFLAGS = $(shell pkg-config --libs gtkmm-2.4 gtkglextmm-1.2 sdl libpng) -lglut -lsdl_mixer
CPPFLAGS = $(shell pkg-config --cflags gtkmm-2.4 gtkglextmm-1.2 sdl libpng)
CXXFLAGS = $(CPPFLAGS) -W -Wall -g
CXX = g++ -m32
MAIN = game488
Expand Down
5 changes: 5 additions & 0 deletions algebra.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,11 @@ inline Point3D operator +(const Point3D& a, const Vector3D& b)
return Point3D(a[0]+b[0], a[1]+b[1], a[2]+b[2]);
}

inline bool operator ==(const Point3D& a, const Point3D& b)
{
return (a[0] == b[0] && a[1] == b[1] && a[2] == b[2]);
}

inline Vector3D operator -(const Point3D& a, const Point3D& b)
{
return Vector3D(a[0]-b[0], a[1]-b[1], a[2]-b[2]);
Expand Down
2 changes: 1 addition & 1 deletion appwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ AppWindow::AppWindow()
// which shuts down the application.
m_menu_app.items().push_back(MenuElem("_New Game", Gtk::AccelKey("n"), sigc::mem_fun(m_viewer, &Viewer::newGame ) ) );
m_menu_app.items().push_back(MenuElem("_Reset", Gtk::AccelKey("r"), sigc::mem_fun(m_viewer, &Viewer::resetView ) ) );
m_menu_app.items().push_back(MenuElem("_Pause", Gtk::AccelKey("p"), sigc::mem_fun(m_viewer, &Viewer::pauseGame ) ) );
m_menu_app.items().push_back(MenuElem("_Quit", Gtk::AccelKey("q"),
sigc::mem_fun(*this, &AppWindow::hide)));

m_menu_drawMode.items().push_back(MenuElem("_Wire-Frame", Gtk::AccelKey("w"), sigc::bind( draw_slot, Viewer::WIRE ) ) );
m_menu_drawMode.items().push_back(MenuElem("_Face", Gtk::AccelKey("f"), sigc::bind( draw_slot, Viewer::FACE ) ) );
m_menu_drawMode.items().push_back(MenuElem("_Texture 1", Gtk::AccelKey("t"), sigc::mem_fun(m_viewer, &Viewer::toggleTexture ) ) );
m_menu_drawMode.items().push_back(MenuElem("_Bump Mapping 1", Gtk::AccelKey("b"), sigc::mem_fun(m_viewer, &Viewer::toggleBumpMapping ) ) );
Expand Down
49 changes: 12 additions & 37 deletions game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
#define OBLOCKCOL 2
#define XCLEARBLOCKCOL 3
#define OCLEARBLOCKCOL 4

int counter = 0;
#define COUNTER_SPACE 16
int lastClearedRow = -1;
static const Piece PIECES[] = {
Piece(
Expand Down Expand Up @@ -166,7 +165,7 @@ Game::Game(int width, int height)
, score_(0)
{
int sz = board_width_ * (board_height_+4);

counter=0;
board_ = new int[ sz ];
std::fill(board_, board_ + sz, -1);
generateNewPiece();
Expand Down Expand Up @@ -312,7 +311,6 @@ void Game::placePiece(const Piece& p, int x, int y)
}
}
}
//dropShadowPiece();
}

void Game::generateNewPiece()
Expand Down Expand Up @@ -342,7 +340,7 @@ int Game::tick()
markBlocksForClearing();
collapse();
moveClearBar();
if (counter < 10)
if (counter < COUNTER_SPACE)
{
counter++;
placePiece(piece_, px_, py_);
Expand Down Expand Up @@ -385,10 +383,12 @@ int Game::tick()
++ny;
placePiece(piece_, px_, ny);*/
dropPiece(0);
counter = COUNTER_SPACE;
}
else if(get(ny-2, px_+1) == -1 && get(ny-2, px_+2) != -1)
{
dropPiece(1);
counter = COUNTER_SPACE;
}
int rm = 0;
/* int level = 1 + linesCleared_ / 10;
Expand Down Expand Up @@ -418,6 +418,7 @@ int Game::tick()
else
{
placePiece(piece_, px_, ny);
sy_ = py_;
py_ = ny;
return 0;
}
Expand Down Expand Up @@ -456,7 +457,8 @@ bool Game::moveLeft()
removePiece(piece_, px_, py_);
if(doesPieceFit(piece_, nx, py_)) {
placePiece(piece_, nx, py_);
px_ = nx;
sx_ = px_;
px_ = nx;
return true;
} else {
placePiece(piece_, px_, py_);
Expand All @@ -471,7 +473,8 @@ bool Game::moveRight()
removePiece(piece_, px_, py_);
if(doesPieceFit(piece_, nx, py_)) {
placePiece(piece_, nx, py_);
px_ = nx;
sx_ = px_;
px_ = nx;
return true;
} else {
placePiece(piece_, px_, py_);
Expand Down Expand Up @@ -503,6 +506,7 @@ bool Game::drop()
}
else
{
sy_ = py_;
py_ = ny;
return true;
}
Expand All @@ -511,7 +515,6 @@ bool Game::drop()
bool Game::rotateCW()
{
removePiece(piece_, px_, py_);
//removePiece(shadowPiece_, sx_, sy_);
Piece npiece = piece_.rotateCW();

if(doesPieceFit(npiece, px_, py_))
Expand All @@ -531,7 +534,6 @@ bool Game::rotateCW()
bool Game::rotateCCW()
{
removePiece(piece_, px_, py_);
// removePiece(shadowPiece_, sx_, sy_);
Piece npiece = piece_.rotateCCW();
if(doesPieceFit(npiece, px_, py_))
{
Expand All @@ -547,34 +549,7 @@ bool Game::rotateCCW()
}
}

void Game::dropShadowPiece()
{
removePiece(shadowPiece_, sx_, sy_);
int ny = sy_;
sx_ = px_;
while(true)
{
--ny;
if(!doesPieceFit(shadowPiece_, sx_, ny))
break;
}

++ny;

for(int r = 0; r < 4; ++r)
{
for(int c = 0; c < 4; ++c)
{
if(shadowPiece_.isOn(r, c))
get(ny-r, sx_+c) = shadowPiece_.getColourIndex(r, c);
}
}

if(ny != sy_)
sy_ = ny;
}

void Game::moveClearBar()
bool Game::moveClearBar()
{
if (clearBarPos > board_width_)
{
Expand Down
15 changes: 8 additions & 7 deletions game.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class Piece {
Piece rotateCCW() const;

bool isOn(int row, int col) const;

int margins_[4];
void removeHalf(int side)
{
Expand All @@ -51,7 +50,7 @@ class Piece {
desc_[ 2*4 + 2 ] = '.';
}
}

private:
void getColumn(int col, char *buf) const;
void getColumnRev(int col, char *buf) const;
Expand Down Expand Up @@ -136,9 +135,12 @@ void dropShadowPiece();
return clearBarPos;
}

void moveClearBar();
bool moveClearBar();
void pullDown(int x, int y);

int sx_, sy_;
int px_;
int py_;
int counter;
private:
bool doesPieceFit(const Piece& p, int x, int y) const;

Expand All @@ -162,11 +164,10 @@ void dropShadowPiece();

Piece piece_;
Piece shadowPiece_;
int px_, sx_;
int py_, sy_;

int* board_;

int* board_;

// Extra stuff
int score_, linesCleared_;
double clearBarPos;
Expand Down
Binary file added playButton.bmp
Binary file not shown.
Binary file added playButtonClicked.bmp
Binary file not shown.
Loading

0 comments on commit daa5376

Please sign in to comment.