Browse Source

Update addamsfamily.c

Rudy Boudewijn van Etten 5 years ago
parent
commit
d1dfb9621e
1 changed files with 33 additions and 23 deletions
  1. 33 23
      games/addamsfamily.c

+ 33 - 23
games/addamsfamily.c

@@ -1,6 +1,6 @@
 
 
 #include "raylib.h"
 #include "raylib.h"
-//#include <math.h>
+#include <math.h>
 
 
 #define MAX_AI 100
 #define MAX_AI 100
 #define MAX_BULLETS 100
 #define MAX_BULLETS 100
@@ -46,9 +46,9 @@ typedef struct player{
     int lives;
     int lives;
     int hits;
     int hits;
 	int blinking;
 	int blinking;
-    int blinkingdelay;
+    double blinkingdelay;
     int blink;
     int blink;
-    int blinktimer;
+    double blinktimer;
 }player;
 }player;
 
 
 typedef struct ai{
 typedef struct ai{
@@ -103,7 +103,7 @@ typedef struct rot{
 static struct bullet arr_bullet[MAX_BULLETS]={0};
 static struct bullet arr_bullet[MAX_BULLETS]={0};
 static struct ai arr_ai[MAX_AI]={0};
 static struct ai arr_ai[MAX_AI]={0};
 static struct money arr_money[MAX_MONEY]={0};
 static struct money arr_money[MAX_MONEY]={0};
-static struct rot arr_rot[MAX_ROT]={0};
+static struct rot arr_rot[MAX_ROT] = {0};
 static game g = {0};
 static game g = {0};
 static player p = {0};
 static player p = {0};
 
 
@@ -117,7 +117,6 @@ static void inigame(void);
 static void gravity(void);   
 static void gravity(void);   
 static bool rectmapcollision(int x, int y, int w, int h, int offx, int offy);
 static bool rectmapcollision(int x, int y, int w, int h, int offx, int offy);
 static bool pmcollision(int offx,int offy);
 static bool pmcollision(int offx,int offy);
-static bool pmcollision2(int offx,int offy);
 static void playercontrols(void);
 static void playercontrols(void);
 static bool playerright(void);
 static bool playerright(void);
 static bool playerleft(void);
 static bool playerleft(void);
@@ -138,6 +137,7 @@ static void inimoney(int x,int y);
 static void updatemoney(void);static void drawrot(void);
 static void updatemoney(void);static void drawrot(void);
 static void updaterot(void);
 static void updaterot(void);
 static void inirot(int x,int y);
 static void inirot(int x,int y);
+static void playerblinkingeffect(void);
 
 
     
     
 int main(void)
 int main(void)
@@ -164,6 +164,7 @@ int main(void)
         updatebullets();
         updatebullets();
         updaterot();
         updaterot();
         gravity();
         gravity();
+        playerblinkingeffect();
         updatemoney();
         updatemoney();
         playercontrols();
         playercontrols();
         playerslide();
         playerslide();
@@ -372,8 +373,8 @@ void inigame(){
     p.duckheight = 32;
     p.duckheight = 32;
 	p.hits = 3;
 	p.hits = 3;
 	p.lives = 1;    
 	p.lives = 1;    
-	p.blinkingdelay = GetTime() + 3000;
-	p.blinktimer = 50;
+	p.blinkingdelay = GetTime() + 5;
+	p.blinktimer = 0.05f;
 	p.blink = true;
 	p.blink = true;
 
 
 	g.cx = 0;//;33//;;88
 	g.cx = 0;//;33//;;88
@@ -415,19 +416,6 @@ void gravity(){
 	}
 	}
 }
 }
 
 
-bool pmcollision2(int offx,int offy){
-	switch (p.state){
-		case 0:
-        return rectmapcollision(GetMouseX(),GetMouseY(),48,80,offx,offy);
-		break;
-        case 1:
-        return rectmapcollision(GetMouseX(),GetMouseY(),48,80,offx,offy);
-        break;
-    }
-    return false;
-}
-
-
 bool pmcollision(int offx,int offy){
 bool pmcollision(int offx,int offy){
 	switch (p.state){
 	switch (p.state){
 		case 0:
 		case 0:
@@ -828,9 +816,10 @@ void drawrot(){
 }
 }
 
 
 void inirot(int x,int y){
 void inirot(int x,int y){
-	for(int i;i<MAX_ROT;i++){
+    
+	for(int i=0;i<MAX_ROT;i++){
         if(arr_rot[i].active==false){
         if(arr_rot[i].active==false){
-            arr_rot[i].active=true;
+            arr_rot[i].active = true;
             arr_rot[i].ang = 90;
             arr_rot[i].ang = 90;
             arr_rot[i].ballx = x;
             arr_rot[i].ballx = x;
             arr_rot[i].bally = y+48;
             arr_rot[i].bally = y+48;
@@ -840,9 +829,30 @@ void inirot(int x,int y){
             arr_rot[i].chainy[1] = 0.0f;
             arr_rot[i].chainy[1] = 0.0f;
             arr_rot[i].chainx[2] = 0.0f;
             arr_rot[i].chainx[2] = 0.0f;
             arr_rot[i].chainy[2] = 0.0f;
             arr_rot[i].chainy[2] = 0.0f;
-
+            
             return;
             return;
         }
         }
     }
     }
 }
 }
 
 
+void playerblinkingeffect(){
+    
+	if(p.blinkingdelay > GetTime()){
+
+		if(p.blinktimer < GetTime()){
+            //weasel=14298;
+			if(p.blink==true){
+                p.blink = false;
+                }else{
+                p.blink = true;
+            }            
+            p.blinktimer = GetTime() + 0.2f;;            
+        }
+			
+		}else{
+            
+		                
+        p.blink = true ;
+	}
+
+}