-
Notifications
You must be signed in to change notification settings - Fork 2
/
hero.c
111 lines (96 loc) · 3.55 KB
/
hero.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#include "raylib.h"
#include "hero.h"
void heroLogic(float section, Texture2D hero, int *heroFramesCounter, int heroFramesSpeed, int *heroCurrentFrame,
Rectangle *heroFrameRec){
if(section != 48){
if (IsKeyDown(KEY_UP)){
(*heroFrameRec).y = section*3;
(*heroFramesCounter)++;
if(*heroFramesCounter >= (15/heroFramesSpeed)){
*heroFramesCounter = 0;
(*heroCurrentFrame)++;
if(*heroCurrentFrame > 2){
*heroCurrentFrame = 0;
}
(*heroFrameRec).x = (float)*heroCurrentFrame * (float)hero.width/12;
}
}
}
if (IsKeyDown(KEY_RIGHT)){
(*heroFrameRec).y = section*2;
(*heroFramesCounter)++;
if(*heroFramesCounter >= (15/heroFramesSpeed)){
*heroFramesCounter = 0;
(*heroCurrentFrame)++;
if(*heroCurrentFrame > 2){
*heroCurrentFrame = 0;
}
(*heroFrameRec).x = (float)*heroCurrentFrame * (float)hero.width/12;
}
}
if (IsKeyDown(KEY_LEFT)){
(*heroFrameRec).y = section;
(*heroFramesCounter)++;
if(*heroFramesCounter >= (15/heroFramesSpeed)){
*heroFramesCounter = 0;
(*heroCurrentFrame)++;
if(*heroCurrentFrame > 2){
*heroCurrentFrame = 0;
}
(*heroFrameRec).x = (float)*heroCurrentFrame * (float)hero.width/12;
}
}
if (IsKeyDown(KEY_DOWN)){
(*heroFrameRec).y = section*0;
(*heroFramesCounter)++;
if(*heroFramesCounter >= (15/heroFramesSpeed)){
*heroFramesCounter = 0;
(*heroCurrentFrame)++;
if(*heroCurrentFrame > 2){
*heroCurrentFrame = 0;
}
(*heroFrameRec).x = (float)*heroCurrentFrame * (float)hero.width/12;
}
}
}
void drawHero(float x, float y,Texture2D hero, Rectangle *heroFrameRec, Vector2 heroPosition){
DrawTextureRec(
hero,
*heroFrameRec,
(Vector2){heroPosition.x - x, heroPosition.y - y },
WHITE
);
}
void controlHero(float * ballPositionx,float * ballPositiony){
if (IsKeyDown(KEY_RIGHT)) (*ballPositionx) += 3.0f;
if (IsKeyDown(KEY_LEFT)) (*ballPositionx) -= 3.0f;
if (IsKeyDown(KEY_UP)) (*ballPositiony) -= 3.0f;
if (IsKeyDown(KEY_DOWN)) (*ballPositiony) += 3.0f;
}
void deathHero(int *books, float *ballPositionx,float *ballPositiony,int *soltaInimigo1,int *soltaInimigo2,int * book3,int *power,float x,float y){
(*ballPositionx) = x;
(*ballPositiony)= y;
(*soltaInimigo2) = 0;
(*soltaInimigo1) = 0;
(*book3) = 0;
(*power) = 0;
(*books) = 0;
}
void deathHero2(int *tempo, float *playerpositionx,float *playerpositiony,float *enemyPositionx,float *enemyPositiony,float *enemyPosition2x,float *enemyPosition2y,int *lifes){
(*playerpositionx) = 80;
(*playerpositiony)= 79;
(*enemyPosition2x) = 33;
(*enemyPosition2y) = 256;
(*enemyPositionx) = 600;
(*enemyPositiony) = 20;
(*lifes)--;
(*tempo) = 0;
}
int hacker(){
if(IsKeyDown(KEY_M) && IsKeyDown(KEY_A) && IsKeyDown(KEY_R)) return 1;
else return 0;
}
int powerPoison(int power){
if(IsKeyDown(KEY_SPACE) && power == 1) return 1;
else return 0;
}