aboutsummaryrefslogtreecommitdiff
path: root/src/GameTick.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/GameTick.cpp')
-rw-r--r--src/GameTick.cpp83
1 files changed, 29 insertions, 54 deletions
diff --git a/src/GameTick.cpp b/src/GameTick.cpp
index f3ca51a..b7d0d64 100644
--- a/src/GameTick.cpp
+++ b/src/GameTick.cpp
@@ -25,8 +25,6 @@ extern int psychicaimkey;
extern int psychickey;
extern Decals decals;
-/********************> Tick() <*****/
-
#define maxfallvel 40
void Game::Splat(int k){
@@ -59,43 +57,25 @@ void Game::Splat(int k){
}
}
-void Game::Tick(){
- if(mainmenu){
-
- unsigned char theKeyMap[16];
-
- GetKeys( ( unsigned long * )theKeyMap );
-
- if(IsKeyDown(theKeyMap, MAC_SPACE_KEY)){
-
- mainmenu=0;
-
- }
+void Game::Tick()
+{
+ if (mainmenu) {
+ unsigned char theKeyMap[16];
+ GetKeys((unsigned long*) theKeyMap);
+ if (IsKeyDown(theKeyMap, MAC_SPACE_KEY))
+ mainmenu = 0;
GetMouse(&mouseloc);
-
- float mousex=mouseloc.h;
-
- float mousey=mouseloc.v;
-
- mousex=(float)mouseloc.h*640/screenwidth;
-
- mousey=480-(float)mouseloc.v*480/screenheight;
-
- oldmouseoverbutton=mouseoverbutton;
-
- mouseoverbutton=0;
-
- if(mousex>120&&mousex<560&&mousey>235&&mousey<305){
-
- mouseoverbutton=1;
-
- }
-
- if(mousex>120&&mousex<560&&mousey>112&&mousey<182){
-
- mouseoverbutton=2;
-
+ float mousex = (float) mouseloc.h * 640 / screenwidth;
+ float mousey = 480 - (float) mouseloc.v * 480 / screenheight;
+
+ oldmouseoverbutton = mouseoverbutton;
+ mouseoverbutton = 0;
+ if (mousex > 120 && mousex < 560) {
+ if (mousey > 235 && mousey < 305)
+ mouseoverbutton = 1;
+ else if (mousey > 112 && mousey < 182)
+ mouseoverbutton = 2;
}
if((Button()&&mouseoverbutton==1&&!gameinprogress&&!oldbutton)||!mainmenuness){
@@ -878,25 +858,20 @@ void Game::Tick(){
camera.targetoffset=0;
camera.targetoffset.z=-5;
- //Spawn people
- spawndelay-=multiplier;
- int blockspawnx,blockspawny;
- blockspawnx=0;
- blockspawny=0;
-
- int cyclenum;
- cyclenum=0;
-
- while((citypeoplenum[blockspawnx][blockspawny]>=max_people_block&&cyclenum<10)||blockspawnx==0){
-
- blockspawnx=((person[0].playercoords.x+block_spacing/2)/block_spacing)+Random()%2;
+ // Spawn people
+ int cyclenum = 0;
+ int blockspawnx = 0, blockspawny = 0;
+ do {
+ auto block = person[0].playercoords / block_spacing;
+ blockspawnx = block.x + 0.5f + Random() % 2;
+ blockspawny = block.z + 0.5f + Random() % 2;
- blockspawny=((person[0].playercoords.z+block_spacing/2)/block_spacing)+Random()%2;
-
- cyclenum++;
-
- }
+ auto& people = citypeoplenum[blockspawnx][blockspawny];
+ if (people < max_people_block)
+ break;
+ } while (++cyclenum < 10);
+ spawndelay -= multiplier;
if(cyclenum<10){
if(spawndelay<0&&numpeople<max_people){