Update of /cvsroot/qb2c/goengine/src/game
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18293/src/game
Modified Files:
game.cpp game.h gamefileinput.cpp gamefileinput.h
gameglobals.cpp gameglobals.h goengine.cpp
Log Message:
Engine/Editor Updates
added
- door opening animation
- brightness control for polies in editor
- 'h' key can only affect selected polies in editor
- camera hotspots / camera auto angling
Index: goengine.cpp
===================================================================
RCS file: /cvsroot/qb2c/goengine/src/game/goengine.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** goengine.cpp 8 Nov 2004 14:17:36 -0000 1.6
--- goengine.cpp 8 Nov 2004 16:28:27 -0000 1.7
***************
*** 1,25 ****
! /*
! Generation Olympia Engine - C++ Port
! Project Home: http://www.sourceforge.net/projects/qb2c/
!
! This program is free software; you can redistribute it and/or modify
! it under the terms of the GNU General Public License as published by
! the Free Software Foundation; either version 2 of the License, or
! (at your option) any later version.
!
! $Id$
! */
!
#include "../engine/engineglobals.h"
#include "../engine/render.h"
! #include "../engine/fileinput.h"
#include "gamefileinput.h"
#include "gameglobals.h"
#include "game.h"
!
! #include <stdio.h>
! #include <stdlib.h>
! #include <string.h>
--- 1,25 ----
! /*
! Generation Olympia Engine - C++ Port
! Project Home: http://www.sourceforge.net/projects/qb2c/
!
! This program is free software; you can redistribute it and/or modify
! it under the terms of the GNU General Public License as published by
! the Free Software Foundation; either version 2 of the License, or
! (at your option) any later version.
!
! $Id$
! */
!
#include "../engine/engineglobals.h"
#include "../engine/render.h"
! #include "../engine/fileinput.h"
#include "gamefileinput.h"
#include "gameglobals.h"
#include "game.h"
!
! #include <stdio.h>
! #include <stdlib.h>
! #include <string.h>
***************
*** 59,63 ****
camz = 66;
camy = 3.5;
! camrx = 40;
camry = 80;
--- 59,63 ----
camz = 66;
camy = 3.5;
! camrx = 30;
camry = 80;
***************
*** 72,75 ****
--- 72,82 ----
view_updated = FALSE;
zm = 40;
+
+ automode = TRUE;
+ hud = TRUE;
+
+ load_file_camera();
+
+
do
{
***************
*** 86,96 ****
checkkbd();
!
!
drawpolys();
drawhud();
process_trigger();
updphysics();
if (!view_updated) updscreen();
--- 93,104 ----
checkkbd();
!
drawpolys();
drawhud();
+ checkcam();
process_trigger();
updphysics();
+ updcam();
if (!view_updated) updscreen();
***************
*** 99,110 ****
clear_to_color(offscreen, 0);
! cycle = cycle + ripplewash * fpsr;
!
! while (cycle > 16) { cycle = cycle - 16; }
!
!
! planeinfo[50].zrot = u(planeinfo[50].zrot + 4 * 4 * fpsr);
!
! rotate_plane(50);
} while (!key[KEY_F12] && !key[KEY_ESC]);
--- 107,112 ----
clear_to_color(offscreen, 0);
! calcsteps();
! setup_scene();
} while (!key[KEY_F12] && !key[KEY_ESC]);
Index: gamefileinput.h
===================================================================
RCS file: /cvsroot/qb2c/goengine/src/game/gamefileinput.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** gamefileinput.h 8 Nov 2004 14:17:36 -0000 1.3
--- gamefileinput.h 8 Nov 2004 16:28:27 -0000 1.4
***************
*** 20,23 ****
--- 20,26 ----
void load_file_joypad();
void save_file_joypad();
+ void save_file_camera();
+ void load_file_camera();
+
Index: game.cpp
===================================================================
RCS file: /cvsroot/qb2c/goengine/src/game/game.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** game.cpp 8 Nov 2004 14:17:36 -0000 1.5
--- game.cpp 8 Nov 2004 16:28:27 -0000 1.6
***************
*** 1,22 ****
! /*
! Generation Olympia Engine - C++ Port
! Project Home: http://www.sourceforge.net/projects/qb2c/
!
! This program is free software; you can redistribute it and/or modify
! it under the terms of the GNU General Public License as published by
! the Free Software Foundation; either version 2 of the License, or
! (at your option) any later version.
!
! $Id$
! */
!
#include "../engine/fileinput.h"
#include "../engine/engineglobals.h"
! #include "../engine/render.h"
#include "gamefileinput.h"
#include "gameglobals.h"
! #include "game.h"
!
#include <math.h>
--- 1,22 ----
! /*
! Generation Olympia Engine - C++ Port
! Project Home: http://www.sourceforge.net/projects/qb2c/
!
! This program is free software; you can redistribute it and/or modify
! it under the terms of the GNU General Public License as published by
! the Free Software Foundation; either version 2 of the License, or
! (at your option) any later version.
!
! $Id$
! */
!
#include "../engine/fileinput.h"
#include "../engine/engineglobals.h"
! #include "../engine/render.h"
#include "gamefileinput.h"
#include "gameglobals.h"
! #include "game.h"
!
#include <math.h>
***************
*** 78,84 ****
}
!
! void checkkbd()
! {
float ofs;
--- 78,142 ----
}
!
! void checkcam()
! {
! float nsx, nsy, nsz, psx, psy, psz;
! int scx, scy, i;
!
! int whitec = makecol(255, 255, 255);
!
! for (i = 0; i < 9; i++)
! {
! if (camera[i].active)
! {
! nsx = camera[i].basex - focusofs[0];
! nsy = camera[i].basey - focusofs[1];
! nsz = camera[i].basez - focusofs[2];
!
! psx = nsx * prexx + nsy * preyx + nsz * prezx - camx;
! psy = nsx * prexy + nsy * preyy + nsz * prezy - camy;
! psz = nsx * prexz + nsy * preyz + nsz * prezz - camz;
!
! scx = short(xcenter + psx / psz * xzoomratio);
! scy = short(ycenter + psy / psz * yzoomratio - scrny);
!
! circle(offscreen, scx, scy, camera[i].endx, whitec);
! }
! }
!
! if (key[KEY_1] && freeze < timer) setcam(0);
! if (key[KEY_2] && freeze < timer) setcam(1);
! if (key[KEY_3] && freeze < timer) setcam(2);
! if (key[KEY_4] && freeze < timer) setcam(3);
! if (key[KEY_5] && freeze < timer) setcam(4);
! if (key[KEY_6] && freeze < timer) setcam(5);
! if (key[KEY_7] && freeze < timer) setcam(6);
! if (key[KEY_8] && freeze < timer) setcam(7);
! if (key[KEY_9] && freeze < timer) setcam(8);
!
!
! if (key[KEY_TAB] && freeze < timer)
! {
! freeze = timer + .001 * fpsr;
! automode = !automode;
! }
! if (key[KEY_A] && freeze < timer)
! {
! freeze = timer + .001 * fpsr;
! save_file_camera();
! }
! if (key[KEY_Z] && freeze < timer)
! {
! freeze = timer + .001 * fpsr;
! load_file_camera();
! }
!
!
!
! }
!
!
! void checkkbd()
! {
float ofs;
***************
*** 130,134 ****
!
if (key[KEY_F1]) gui_setkeys();
if (key[KEY_S] && freeze < timer)
--- 188,197 ----
! if (key[KEY_TILDE] && freeze < timer)
! {
! hud = !hud;
! freeze = timer + .001 * fpsr;
! }
!
if (key[KEY_F1]) gui_setkeys();
if (key[KEY_S] && freeze < timer)
***************
*** 291,295 ****
//if (key[KEY_S]) save_file_simple("1");
!
}
--- 354,358 ----
//if (key[KEY_S]) save_file_simple("1");
!
}
***************
*** 318,328 ****
//rectfill (offscreen, 0, yres - wideheight, xres - 1, yres - 1, 0);
! char tmp[100];
! sprintf(tmp, "%f", pratio);
!
! textout(offscreen, font, tmp, 320, 10, whitec);
//return;
!
char fpstext[100];
char vistext[100];
--- 381,416 ----
//rectfill (offscreen, 0, yres - wideheight, xres - 1, yres - 1, 0);
! if (!hud) return;
+ char tmp[100];
+ int i, c;
+
//return;
! win(0, 5, 38 + 16, 20 + text_length(font, "AutoCam ON "), 38+31);
! if (automode) textout(offscreen, font, "AutoCam ON", 10, 38+16+5, whitec);
! if (!automode)
! {
! textout(offscreen, font, "AutoCam OFF", 10, 38+16+5, whitec);
! c = 1;
! for (i = 0; i < 9; i++)
! {
! if (camera[i].active) c++;
! }
! win(0, 5, 38 + 32, 20 + text_length(font, "Active Cams"), 38+32 + 16 * c);
! textout(offscreen, font, "Active Cams", 10, 38 + 32 + 5, whitec);
!
! c = 0;
! for (i = 0; i < 9; i++)
! {
! if (camera[i].active)
! {
! c++;
! sprintf(tmp, " %d", i);
! textout(offscreen, font, tmp, 10, 38 + 32 + 5 + c * 16, whitec);
! }
! }
!
! }
!
char fpstext[100];
char vistext[100];
***************
*** 332,336 ****
sprintf(vistext, "%d/%d vis polys", vispolys, npolies);
! win(0, 5, 5, 11 + MAX(text_length(font, fpstext), text_length(font, vistext)), 37 + 16);
text_mode(-1);
--- 420,424 ----
sprintf(vistext, "%d/%d vis polys", vispolys, npolies);
! win(0, 5, 5, 20 + MAX(text_length(font, fpstext), text_length(font, vistext)), 37 + 16);
text_mode(-1);
***************
*** 345,350 ****
textout(offscreen, font, tmp, 10, 34, whitec);
}
!
void drawpolys()
--- 433,439 ----
textout(offscreen, font, tmp, 10, 34, whitec);
+
}
!
void drawpolys()
***************
*** 463,467 ****
!
void drawsprite(short spritenum)
{
--- 552,556 ----
!
void drawsprite(short spritenum)
{
***************
*** 819,822 ****
--- 908,912 ----
int p;
char tmp[100];
+ float sx;
p = getpixel(triggerbmp, 24, 24);
***************
*** 824,842 ****
if (p > 999)
{
! sprintf(tmp, "%d", (short)triggerinfo[p][0]);
! load_file_v1(tmp);
! setup_scene();
! playerx = triggerinfo[p][1];
! playery = triggerinfo[p][2];
! playerz = triggerinfo[p][3];
! focusofs[0] = playerx;
! focusofs[1] = playery;
! focusofs[2] = playerz;
! fightfocus[0] = playerx;
! fightfocus[1] = playery;
! fightfocus[2] = playerz;
}
}
--- 914,967 ----
if (p > 999)
{
! if (triggerinfo[p][4] == 1)
! {
! //focusofs[0] = focusofs[0] + (fightfocus[0] - focusofs[0]) * .09 * fpsr;
! sx = planeinfo[(short)triggerinfo[p][5]].yrot;
! sx = sx + (-80 - sx) * .05 * fpsr;
!
! planeinfo[(short)triggerinfo[p][5]].yrot = sx;
!
! //planeinfo[(short)triggerinfo[p][5]].yrot = planeinfo[(short)triggerinfo[p][5]].yrot u(planeinfo[(short)triggerinfo[p][5]].yrot - 275)
! rotate_plane((short)triggerinfo[p][5]);
!
! if (sx > -85 && sx < -75)
! {
! sprintf(tmp, "%d", (short)triggerinfo[p][0]);
! load_file_v1(tmp);
! setup_scene();
! load_file_camera();
!
! playerx = triggerinfo[p][1];
! playery = triggerinfo[p][2];
! playerz = triggerinfo[p][3];
! focusofs[0] = playerx;
! focusofs[1] = playery;
! focusofs[2] = playerz;
! fightfocus[0] = playerx;
! fightfocus[1] = playery;
! fightfocus[2] = playerz;
! }
!
! } else {
! sprintf(tmp, "%d", (short)triggerinfo[p][0]);
! load_file_v1(tmp);
! setup_scene();
! load_file_camera();
!
! playerx = triggerinfo[p][1];
! playery = triggerinfo[p][2];
! playerz = triggerinfo[p][3];
!
! focusofs[0] = playerx;
! focusofs[1] = playery;
! focusofs[2] = playerz;
!
! fightfocus[0] = playerx;
! fightfocus[1] = playery;
! fightfocus[2] = playerz;
! }
}
}
***************
*** 861,868 ****
}
! calcsteps();
! setup_scene();
}
void setup_scene()
{
--- 986,1004 ----
}
! }
+ void setcam(int camnum)
+ {
+ freeze = timer + .001 * fpsr;
+ camera[camnum].active = !camera[camnum].active;
+ camera[camnum].basex = playerx;
+ camera[camnum].basey = playery;
+ camera[camnum].basez = playerz;
+ camera[camnum].xrot = camrx;
+ camera[camnum].yrot = camry;
+ camera[camnum].zrot = camrz;
}
+
+
void setup_scene()
{
***************
*** 994,1004 ****
}
!
!
! void updphysics()
! {
! focusofs[0] = focusofs[0] + (fightfocus[0] - focusofs[0]) * .09 * fpsr;
! focusofs[1] = focusofs[1] + (fightfocus[1] - focusofs[1]) * .09 * fpsr;
focusofs[2] = focusofs[2] + (fightfocus[2] - focusofs[2]) * .09 * fpsr;
! }
--- 1130,1207 ----
}
!
! void updcam()
! {
! int c = 0, i;
! float d, mx = 0, my = 0, mz = 0, sx, sy, sz;
!
! if (automode)
! {
! for (i = 0; i < 9; i++)
! {
! if (camera[i].active)
! {
! c++;
! sx = playerx - camera[i].basex;
! sy = playery - camera[i].basey;
! sz = playerz - camera[i].basez;
! d = sqrt(sx * sx + sy * sy + sz * sz);
!
! d = d * d;
! if (d < 1) d = 1;
!
!
! mx += camera[i].xrot;
! my += camera[i].yrot;
! mz += camera[i].zrot;
!
! d = 1 / d;
! if (d < .1) d = 0;
! camera[i].endx = d;
!
!
! }
! }
!
!
!
! mx /= c;
! my /= c;
! mz /= c;
!
! float ax, ay, az;
!
! for (i = 0; i < 9; i++)
! {
! if (camera[i].active)
! {
! ax = camera[i].xrot;
! ay = camera[i].yrot;
! az = camera[i].zrot;
!
! ax = (camrx - ax) * camera[i].endx;
! ay = (camry - ay) * camera[i].endx;
! az = (camrz - az) * camera[i].endx;
! camrx = u(camrx - ax);
! camry = u(camry - ay);
! camrz = u(camrz - az);
! }
! }
! }
! }
!
!
! void updphysics()
! {
! focusofs[0] = focusofs[0] + (fightfocus[0] - focusofs[0]) * .09 * fpsr;
! focusofs[1] = focusofs[1] + (fightfocus[1] - focusofs[1]) * .09 * fpsr;
focusofs[2] = focusofs[2] + (fightfocus[2] - focusofs[2]) * .09 * fpsr;
!
! cycle = cycle + ripplewash * fpsr;
! while (cycle > 16) { cycle = cycle - 16; }
!
! planeinfo[50].zrot = u(planeinfo[50].zrot + 4 * 4 * fpsr);
! rotate_plane(50);
!
! }
Index: gameglobals.cpp
===================================================================
RCS file: /cvsroot/qb2c/goengine/src/game/gameglobals.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** gameglobals.cpp 8 Nov 2004 14:17:36 -0000 1.2
--- gameglobals.cpp 8 Nov 2004 16:28:27 -0000 1.3
***************
*** 1,22 ****
! /*
! Generation Olympia Engine - C++ Port
! Project Home: http://www.sourceforge.net/projects/qb2c/
!
! This program is free software; you can redistribute it and/or modify
! it under the terms of the GNU General Public License as published by
! the Free Software Foundation; either version 2 of the License, or
! (at your option) any later version.
!
! $Id$
! */
!
! #include "gameglobals.h"
!
! float playerx, playery, playerz, pratio;
! short pscx, pscy;
!
! short npcs, walkdir, curstatus;
! float curframe, triggerinfo[10000][9], cycle;
!
short gameflags[10000];
--- 1,22 ----
! /*
! Generation Olympia Engine - C++ Port
! Project Home: http://www.sourceforge.net/projects/qb2c/
!
! This program is free software; you can redistribute it and/or modify
! it under the terms of the GNU General Public License as published by
! the Free Software Foundation; either version 2 of the License, or
! (at your option) any later version.
!
! $Id$
! */
!
! #include "gameglobals.h"
!
! float playerx, playery, playerz, pratio;
! short pscx, pscy;
!
! short npcs, walkdir, curstatus;
! float curframe, triggerinfo[10000][9], cycle;
!
short gameflags[10000];
***************
*** 27,30 ****
BITMAP *surroundbmp, *surroundcbmp, *triggerbmp;
! BITMAP *frames[num_characters][num_animations][4][6];
!
--- 27,31 ----
BITMAP *surroundbmp, *surroundcbmp, *triggerbmp;
! BITMAP *frames[num_characters][num_animations][4][6];
!
! bool automode, view_updated, use_joy, hud;
\ No newline at end of file
Index: gameglobals.h
===================================================================
RCS file: /cvsroot/qb2c/goengine/src/game/gameglobals.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** gameglobals.h 8 Nov 2004 14:17:36 -0000 1.2
--- gameglobals.h 8 Nov 2004 16:28:27 -0000 1.3
***************
*** 1,19 ****
! /*
! Generation Olympia Engine - C++ Port
! Project Home: http://www.sourceforge.net/projects/qb2c/
!
! This program is free software; you can redistribute it and/or modify
! it under the terms of the GNU General Public License as published by
! the Free Software Foundation; either version 2 of the License, or
! (at your option) any later version.
!
! $Id$
! */
!
! #ifndef INCLUDED_GAMEGLOBALS_HEADER
! #define INCLUDED_GAMEGLOBALS_HEADER
!
! // The size of this file is exponentionaly propotional to the need of
! // refactoring
#include <allegro.h>
--- 1,19 ----
! /*
! Generation Olympia Engine - C++ Port
! Project Home: http://www.sourceforge.net/projects/qb2c/
!
! This program is free software; you can redistribute it and/or modify
! it under the terms of the GNU General Public License as published by
! the Free Software Foundation; either version 2 of the License, or
! (at your option) any later version.
!
! $Id$
! */
!
! #ifndef INCLUDED_GAMEGLOBALS_HEADER
! #define INCLUDED_GAMEGLOBALS_HEADER
!
! // The size of this file is exponentionaly propotional to the need of
! // refactoring
#include <allegro.h>
***************
*** 23,28 ****
#define status_standing 0
#define status_walking 1
! #define status_attacking 0
!
extern float playerx, playery, playerz, pratio;
extern short pscx, pscy;
--- 23,28 ----
#define status_standing 0
#define status_walking 1
! #define status_attacking 0
!
extern float playerx, playery, playerz, pratio;
extern short pscx, pscy;
***************
*** 39,43 ****
extern BITMAP *surroundbmp, *surroundcbmp, *triggerbmp;
! extern BITMAP *frames[num_characters][num_animations][4][6];
!
! #endif
--- 39,45 ----
extern BITMAP *surroundbmp, *surroundcbmp, *triggerbmp;
! extern BITMAP *frames[num_characters][num_animations][4][6];
!
! extern bool automode, view_updated, use_joy, hud;
!
! #endif
Index: game.h
===================================================================
RCS file: /cvsroot/qb2c/goengine/src/game/game.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** game.h 8 Nov 2004 14:17:36 -0000 1.3
--- game.h 8 Nov 2004 16:28:27 -0000 1.4
***************
*** 1,19 ****
! /*
! Generation Olympia Engine - C++ Port
! Project Home: http://www.sourceforge.net/projects/qb2c/
!
! This program is free software; you can redistribute it and/or modify
! it under the terms of the GNU General Public License as published by
! the Free Software Foundation; either version 2 of the License, or
! (at your option) any later version.
!
! $Id$
! */
!
! #ifndef INCLUDED_GAME_HEADER
! #define INCLUDED_GAME_HEADER
!
void calcsprites();
void checkkbd();
void cleanup_scene();
--- 1,20 ----
! /*
! Generation Olympia Engine - C++ Port
! Project Home: http://www.sourceforge.net/projects/qb2c/
!
! This program is free software; you can redistribute it and/or modify
! it under the terms of the GNU General Public License as published by
! the Free Software Foundation; either version 2 of the License, or
! (at your option) any later version.
!
! $Id$
! */
!
! #ifndef INCLUDED_GAME_HEADER
! #define INCLUDED_GAME_HEADER
!
void calcsprites();
+ void checkcam();
void checkkbd();
void cleanup_scene();
***************
*** 26,32 ****
void process_trigger();
void rotate_plane(int planenum);
! void setup_scene();
! void updphysics();
!
!
! #endif
--- 27,35 ----
void process_trigger();
void rotate_plane(int planenum);
! void setcam(int camnum);
! void setup_scene();
! void updcam();
! void updphysics();
!
!
! #endif
Index: gamefileinput.cpp
===================================================================
RCS file: /cvsroot/qb2c/goengine/src/game/gamefileinput.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** gamefileinput.cpp 8 Nov 2004 14:17:36 -0000 1.3
--- gamefileinput.cpp 8 Nov 2004 16:28:27 -0000 1.4
***************
*** 348,349 ****
--- 348,420 ----
+ void save_file_camera()
+ {
+
+ FILE *fp;
+
+ char tmp[100];
+ sprintf(tmp, "data/maps/%s.cam", mapfile);
+
+ fp = fopen(tmp, "w");
+
+
+ int a;
+
+ for (a = 0; a < 9; a++)
+ {
+ fprintf(fp, "%d\n", camera[a].active);
+ fprintf(fp, "%f\n", camera[a].basex);
+ fprintf(fp, "%f\n", camera[a].basey);
+ fprintf(fp, "%f\n", camera[a].basez);
+ fprintf(fp, "%f\n", camera[a].xrot);
+ fprintf(fp, "%f\n", camera[a].yrot);
+ fprintf(fp, "%f\n", camera[a].zrot);
+ }
+
+
+ fclose(fp);
+ }
+
+ void load_file_camera()
+ {
+ FILE *fp;
+ int a;
+
+ //fp = fopen("cam.dat", "r");
+
+
+ char tmp[100];
+ sprintf(tmp, "data/maps/%s.cam", mapfile);
+
+ if (!exists(tmp))
+ {
+ fp = fopen(tmp, "w");
+ for (a = 0; a < 9; a++)
+ {
+ fprintf(fp, "0\n");
+ fprintf(fp, "0\n");
+ fprintf(fp, "0\n");
+ fprintf(fp, "0\n");
+ fprintf(fp, "0\n");
+ fprintf(fp, "0\n");
+ fprintf(fp, "0\n");
+ }
+ fclose(fp);
+ }
+ fp = fopen(tmp, "r");
+
+
+ for (a = 0; a < 9; a++)
+ {
+ fscanf(fp, "%d", &camera[a].active);
+ fscanf(fp, "%f", &camera[a].basex);
+ fscanf(fp, "%f", &camera[a].basey);
+ fscanf(fp, "%f", &camera[a].basez);
+ fscanf(fp, "%f", &camera[a].xrot);
+ fscanf(fp, "%f", &camera[a].yrot);
+ fscanf(fp, "%f", &camera[a].zrot);
+ }
+ fclose(fp);
+
+ }
+
|