-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstrobilates.cpp
More file actions
115 lines (93 loc) · 1.84 KB
/
Copy pathstrobilates.cpp
File metadata and controls
115 lines (93 loc) · 1.84 KB
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
111
112
113
114
115
#include "strobilates.h"
#include <stdint.h>
uint8_t swimframe = 0;
bool swimming = false;
const int growthModifier = 2;
strob::strob(int16_t xStart, int16_t yStart){
x = xStart;
y = yStart;
}
void strob::drawStrob(){
if (counter <= 14*growthModifier){
sprite.drawSelfMasked(x, y, strobolateAnimation, counter/growthModifier);
}
else if (counter > 14*growthModifier && swimming ==true){
sprite.drawSelfMasked(x, y, strobSwim, swimStrobPattern[swimframe]+ direct);
swimframe++;
}
else {
sprite.drawSelfMasked(x, y, strobSwim, direct);
}
if(swimframe > 8){
swimming = false;
swimframe = 0;
}
}
void strob::updateStrob(){
if (swimming == false){ setDirection(); }
if(frameCounter % 4 == 0 && counter > 14*growthModifier){
x--;
}
if (counter < 30){
counter++;}
else{
growing = false;
}
if( arduboy.justPressed(B_BUTTON) && growing == false){
swimming = true;
switch (direct){
case 0:
ySpeed =-4;
break;
case 1:
xSpeed = -4;
break;
case 2:
ySpeed = 4;
break;
case 3:
xSpeed = 4;
break;
}
}
x+= xSpeed;
y+= ySpeed;
if (xSpeed > 0){ xSpeed--;}
else if (xSpeed < 0){ xSpeed++;}
if (ySpeed > 0){ ySpeed--;}
else if (ySpeed < 0){ ySpeed++;}
if(x > 120){
x = 120;
}
else if( x < 0 ){
x = 0;
}
else if(y > 50){
y = 50;
}
else if( y < 13-6){
y = 13-6;
}
if(frameCounter % 15 == 0 ){
growCounter++;
}
if (growCounter > 30){
frameCounter = 0;
enteringStage = true;
GameStage = Medusa;
}
}
void strob::setDirection(){
if (playerDirection == up){
direct = 0;
}
else if (playerDirection == left){
direct = 1;
}
else if (playerDirection == down){
direct = 2;
}
else if (playerDirection == right){
direct = 3;
}
}