minor changes

This commit is contained in:
Gero Müller 2011-10-07 12:07:36 +02:00
parent dafe52c4cd
commit dbed4abb0b
4 changed files with 70 additions and 52 deletions

View File

@ -1,3 +1,5 @@
syntax: regexp syntax: regexp
^build$ ^build$
syntax: regexp
^libs/log4cplus/src/Makefile\.am$

View File

@ -16,6 +16,7 @@ endif(UNIX)
include_directories (${GREMLIN_SOURCE_DIR}/libs/glfw/include) include_directories (${GREMLIN_SOURCE_DIR}/libs/glfw/include)
include_directories (${GREMLIN_SOURCE_DIR}/libs/spark/include) include_directories (${GREMLIN_SOURCE_DIR}/libs/spark/include)
include_directories (${GREMLIN_SOURCE_DIR}/libs/enet/include) include_directories (${GREMLIN_SOURCE_DIR}/libs/enet/include)
include_directories (${GREMLIN_SOURCE_DIR}/libs/log4cplus/include)
include_directories (${GREMLIN_SOURCE_DIR}/libs/bullet) include_directories (${GREMLIN_SOURCE_DIR}/libs/bullet)
include_directories (${GREMLIN_SOURCE_DIR}/libs/yaml-cpp/include) include_directories (${GREMLIN_SOURCE_DIR}/libs/yaml-cpp/include)
include_directories (${GREMLIN_SOURCE_DIR}/libs/trimeshloader/include) include_directories (${GREMLIN_SOURCE_DIR}/libs/trimeshloader/include)
@ -26,6 +27,7 @@ add_subdirectory (libs/enet)
add_subdirectory (libs/pugixml) add_subdirectory (libs/pugixml)
add_subdirectory (libs/bullet) add_subdirectory (libs/bullet)
add_subdirectory (libs/yaml-cpp) add_subdirectory (libs/yaml-cpp)
add_subdirectory (libs/log4cplus)
add_subdirectory (libs/trimeshloader) add_subdirectory (libs/trimeshloader)
add_subdirectory (src/common) add_subdirectory (src/common)
add_subdirectory (src/server) add_subdirectory (src/server)

View File

@ -10,6 +10,7 @@
#include "Explosion.h" #include "Explosion.h"
#include "Time.h" #include "Time.h"
#include "btBulletDynamicsCommon.h"
#include <GL/glfw.h> #include <GL/glfw.h>
#include <stdio.h> #include <stdio.h>
@ -106,9 +107,10 @@ void draw_bomb(bomb_t *bomb) {
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
glPushMatrix(); glPushMatrix();
glTranslated(bomb->x, bomb->y, bomb->z); glTranslated(bomb->x, bomb->y, bomb->z);
gluSphere(quadratic, 3.f, 4, 4); gluSphere(quadratic, 0.5f, 4, 4);
glPopMatrix(); glPopMatrix();
} }
void draw_point(point_t *point) { void draw_point(point_t *point) {
if (point->status == 0) if (point->status == 0)
return; return;
@ -328,21 +330,24 @@ void Client::accelerate(double x, double y, double z) {
m << msg; m << msg;
network.send(m); network.send(m);
} }
#if 0
void Client::drop_bomb(double rx, double ry, double rz, double ttl) { void Client::drop_bomb(double rx, double ry, double rz, double ttl) {
bomb_drop_meesage_t msg; bomb_drop_meesage_t msg;
msg.x = game.local_player->x + rx * 20; btVector3 p = game.local_player->body->getWorldTransform().getOrigin();
msg.y = game.local_player->y + ry * 20; btVector3 v = game.local_player->body->getLinearVelocity();
msg.z = game.local_player->z + rz * 20;
msg.vx = game.local_player->vx + rx * 100; msg.x = p.x() + rx * 1;
msg.vy = game.local_player->vy + ry * 100; msg.y = p.y() + ry * 1;
msg.vz = game.local_player->vz + rz * 100; msg.z = p.z() + rz * 1;
msg.vx = v.x() + rx * 500;
msg.vy = v.y() + ry * 500;
msg.vz = v.z() + rz * 500;
msg.ttl = ttl; msg.ttl = ttl;
YAML::Emitter m; YAML::Emitter m;
m << msg; m << msg;
network.send(m); network.send(m);
} }
#endif
void Client::loadConsoleFont() { void Client::loadConsoleFont() {
GLuint font_id = 0; GLuint font_id = 0;
@ -380,8 +385,8 @@ void Client::prepareFrame(double rx, double ry, double rz) {
// Select and setup the modelview matrix // Select and setup the modelview matrix
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); glLoadIdentity();
gluLookAt(camX, camY, camZ, camX + rx * 10.0f, camY + ry * 10.0f, camZ + rz gluLookAt(camX, camY, camZ, camX + rx * 10.0f, camY + ry * 10.0f,
* 10.0f, 0.0f, 1.0f, 0.0f); camZ + rz * 10.0f, 0.0f, 1.0f, 0.0f);
} }
@ -413,6 +418,9 @@ void Client::initialize(Arguments &arg) {
accelerate_schudule.setExact(true); accelerate_schudule.setExact(true);
accelerate_schudule.setInterval(0.05); accelerate_schudule.setInterval(0.05);
theta = 0.0;
phi = 0.0;
loadConsoleFont(); loadConsoleFont();
// setup signals // setup signals
@ -435,6 +443,7 @@ void Client::update() {
} }
last_x = x; last_x = x;
last_y = y; last_y = y;
double rx = cos(phi) * cos(theta); double rx = cos(phi) * cos(theta);
double ry = sin(theta); double ry = sin(theta);
double rz = sin(phi) * cos(theta); double rz = sin(phi) * cos(theta);
@ -453,30 +462,33 @@ void Client::update() {
} else if (glfwGetKey('D')) { } else if (glfwGetKey('D')) {
accelerate(-rz * v, 0, rx * v); accelerate(-rz * v, 0, rx * v);
} }
#if 0 #if 0
if (glfwGetKey(GLFW_KEY_SPACE)) { if (glfwGetKey(GLFW_KEY_SPACE)) {
accelerate(game.local_player->vx * -0.1, game.local_player->vy accelerate(game.local_player->vx * -0.1,
* -0.1, game.local_player->vz * -0.1); game.local_player->vy * -0.1, game.local_player->vz * -0.1);
} }
#endif #endif
} }
#if 0
if (glfwGetKey(GLFW_KEY_LCTRL)) { if (glfwGetKey(GLFW_KEY_LCTRL)) {
if (time - last_bomb > 1.0) { if (time - last_bomb > 1.0) {
last_bomb = time; last_bomb = time;
drop_bomb(rx, ry, rz, 5.0); drop_bomb(rx, ry, rz, 5.0);
} }
} }
#endif
if (game.local_player) { if (game.local_player) {
camX = game.local_player->m[12]; btVector3 p = game.local_player->body->getWorldTransform().getOrigin();
camY = game.local_player->m[13];
camZ = game.local_player->m[14]; camX = p.x();
camY = p.y();
camZ = p.z();
} else { } else {
camX = 1000.0; camX = 1000.0;
camY = 1000.0; camY = 1000.0;
camZ = 1000.0; camZ = 1000.0;
} }
prepareFrame(rx, ry, rz); prepareFrame(rx, ry, rz);
setup_light(); setup_light();
glEnable(GL_LIGHT0); glEnable(GL_LIGHT0);
@ -489,19 +501,20 @@ void Client::update() {
for (size_t i = 0; i < GAME_PLAYER_COUNT; i++) for (size_t i = 0; i < GAME_PLAYER_COUNT; i++)
drawPlayer(&game.player[i]); drawPlayer(&game.player[i]);
// for (size_t i = 0; i < GAME_BOMB_COUNT; i++) for (size_t i = 0; i < GAME_BOMB_COUNT; i++)
// draw_bomb(&game.bomb[i]); draw_bomb(&game.bomb[i]);
// //
// for (size_t i = 0; i < GAME_POINT_COUNT; i++) // for (size_t i = 0; i < GAME_POINT_COUNT; i++)
// draw_point(&game.point[i]); // draw_point(&game.point[i]);
drawLevel(); drawLevel();
explosion.update(dt * 1000.0, camX, camY, camZ);
explosion.render();
glDisable(GL_LIGHT0); glDisable(GL_LIGHT0);
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
glDisable(GL_CULL_FACE); glDisable(GL_CULL_FACE);
explosion.update(dt * 1000.0, camX, camY, camZ);
explosion.render();
oglf_begin(&font, width, height); oglf_begin(&font, width, height);
size_t fy = 1; size_t fy = 1;
if (game.local_player) { if (game.local_player) {
@ -523,8 +536,8 @@ void Client::update() {
{ {
std::stringstream sstr; std::stringstream sstr;
sstr << "FPS: " << (int) (1 / dt) << " Time: " << floor(dt * 10000.0 sstr << "FPS: " << (int) (1 / dt) << " Time: "
+ 0.5) / 10.0; << floor(dt * 10000.0 + 0.5) / 10.0;
oglf_print(&font, 10, 25 * fy++, sstr.str().c_str()); oglf_print(&font, 10, 25 * fy++, sstr.str().c_str());
} }

View File

@ -214,6 +214,7 @@ player_t *Game::getFreePlayer() {
if (player[i].status == 0) if (player[i].status == 0)
return &player[i]; return &player[i];
} }
return 0;
} }
player_t *Game::spawnPlayer(Team *team) { player_t *Game::spawnPlayer(Team *team) {