--- a/src/proto2/Graphics.cc Thu Nov 20 23:20:00 2008 +0000
+++ b/src/proto2/Graphics.cc Thu Nov 20 23:45:33 2008 +0000
@@ -1,5 +1,7 @@
#include "Graphics.hh"
+#include "Physics.hh"
+#include "GameState.hh"
Graphics::Graphics (Engine &engine, GameState &state) :
engine(engine),
@@ -7,7 +9,30 @@
update_timer(GRAPHICS_UPDATE_INTERVAL_MS),
win(GRAPHICS_WINDOW_TITLE, GRAPHICS_RESOLUTION_WIDTH, GRAPHICS_RESOLUTION_HEIGHT),
keyboard(win.get_ic()->get_keyboard()) {
+
+ Vector tmp;
+ CL_Color color;
+ CL_PixelBuffer terr(MAP_WIDTH, MAP_HEIGHT, 3*MAP_WIDTH, CL_PixelFormat::rgb888);
+
+ for (tmp.x = 0; tmp.x < MAP_WIDTH; tmp.x++) {
+ for (tmp.y = 0; tmp.y < MAP_HEIGHT; tmp.y++) {
+ if (state.getType(tmp) == EMPTY) {
+ color = CL_Color(80, 35, 0);
+ } else if (state.getType(tmp) == DIRT) {
+ color = CL_Color(144, 82, 23);
+ } else if (state.getType(tmp) == ROCK) {
+ color = CL_Color(132, 136, 135);
+ } else {
+ // Fale
+ }
+ terr.draw_pixel(tmp.x, tmp.y, color);
+ }
+ }
+ terrain = CL_Surface(terr);
+
+ Engine::log(DEBUG, "Graphics") << "Taalla ollaan.";
+
// connect timer signal
slots.connect(update_timer.sig_timer(), this, &Graphics::on_update);
@@ -57,6 +82,9 @@
const float factorX = GRAPHICS_RESOLUTION_WIDTH / MAP_WIDTH;
const float factorY = GRAPHICS_RESOLUTION_HEIGHT / MAP_HEIGHT;
+ // draw terrain
+ terrain.draw(0,0, gc);
+
// draw players
for (std::list<Player*>::iterator it = state.player_list.begin(); it != state.player_list.end(); it++) {
Player *p = *it;