Skip to content

Commit c0e0633

Browse files
authored
Update main.c
1 parent 90532d1 commit c0e0633

File tree

1 file changed

+76
-22
lines changed

1 file changed

+76
-22
lines changed

main.c

+76-22
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,11 @@ uint focus = 0; // focus mode
141141
uint grounded = 0;// is on ground (not flying)
142142
vec plook; // 2D look direction (zero Z axis) (not normalised)
143143
int health = 100; // health
144+
int mhealth = 100;// max health
144145
uint xp = 0; // total xp gained
145146
uint weapon = 0; // weapon unlock level
146147
uint wield = 0; // currently wielded weapon
148+
uint sticky = 0; // sticky/toggle mouse clicking (afking)
147149

148150
// islands
149151
#define MAX_ISLANDS 21
@@ -274,14 +276,14 @@ void doAttack()
274276
if(enemy_health[i] <= 0) // uh-oh dead
275277
{
276278
xp += (1+enemy_type[i])*(1+enemy_type[i]);
277-
if (xp > 113422){weapon = 8, wield = weapon;}
278-
else if(xp > 49314 ){weapon = 7, wield = weapon;}
279-
else if(xp > 21441 ){weapon = 6, wield = weapon;}
280-
else if(xp > 9322 ){weapon = 5, wield = weapon;}
281-
else if(xp > 4053 ){weapon = 4, wield = weapon;}
282-
else if(xp > 1762 ){weapon = 3, wield = weapon;}
283-
else if(xp > 766 ){weapon = 2, wield = weapon;}
284-
else if(xp > 333 ){weapon = 1, wield = weapon;}
279+
if (xp > 113422){weapon = 8, mhealth = 500; wield = weapon;}
280+
else if(xp > 49314 ){weapon = 7, mhealth = 450; wield = weapon;}
281+
else if(xp > 21441 ){weapon = 6, mhealth = 400; wield = weapon;}
282+
else if(xp > 9322 ){weapon = 5, mhealth = 350; wield = weapon;}
283+
else if(xp > 4053 ){weapon = 4, mhealth = 300; wield = weapon;}
284+
else if(xp > 1762 ){weapon = 3, mhealth = 250; wield = weapon;}
285+
else if(xp > 766 ){weapon = 2, mhealth = 200; wield = weapon;}
286+
else if(xp > 333 ){weapon = 1, mhealth = 150; wield = weapon;}
285287

286288
updateTitle();
287289
enemy_pos[i] = (vec){0.f, 0.f, 0.f};
@@ -684,7 +686,7 @@ if(health > 0)
684686
if(itm_pos[i].x != 0.f || itm_pos[i].y != 0.f || itm_pos[i].z != 0.f)
685687
{
686688
const uint m = 16+(i%14); // lol yes im that frugal on memory today
687-
if(health < 100 && vDistSq(mpp, itm_pos[i]) < 0.003f)
689+
if(health < mhealth && vDistSq(mpp, itm_pos[i]) < 0.003f)
688690
{
689691
if(m == 16 || m == 17){health += 1;}
690692
else if(m == 18){health += 2;}
@@ -941,7 +943,7 @@ if(health > 0)
941943
if(t > 5.f && t < 10.f)
942944
{
943945
if(t < 9.f){glUniform1f(opacity_id, 1.f);}
944-
else {glUniform1f(opacity_id, 1.f-(t-9.f));}
946+
else {glUniform1f(opacity_id, 1.f-(t-9.f)); focus = 0;} // kill smooth drop-in now [3]
945947
vec ld = look_dir;
946948
vMulS(&ld, ld, 1.79f);
947949
vec np = (vec){-pp.x, -pp.y, pp.z};
@@ -1022,6 +1024,10 @@ static void key_callback(GLFWwindow* window, int key, int scancode, int action,
10221024
zoom = 0.f;
10231025
}
10241026
}
1027+
else if(key == GLFW_KEY_V) // sticky mouse clicks
1028+
{
1029+
sticky = 1 - sticky;
1030+
}
10251031
else if(key == GLFW_KEY_1 && weapon >= 0){wield = 0;}
10261032
else if(key == GLFW_KEY_2 && weapon >= 1){wield = 1;}
10271033
else if(key == GLFW_KEY_3 && weapon >= 2){wield = 2;}
@@ -1062,6 +1068,8 @@ void scroll_callback(GLFWwindow* window, double xoffset, double yoffset)
10621068
}
10631069
void mouse_button_callback(GLFWwindow* window, int button, int action, int mods)
10641070
{
1071+
static uint left_sticky_state = 0;
1072+
static uint right_sticky_state = 0;
10651073
static float lz = 0.f;
10661074
if(action == GLFW_PRESS)
10671075
{
@@ -1076,34 +1084,78 @@ void mouse_button_callback(GLFWwindow* window, int button, int action, int mods)
10761084
}
10771085
if(button == GLFW_MOUSE_BUTTON_LEFT)
10781086
{
1079-
swipe = 1;
1080-
swipe_phase = 0;
1081-
swipe_lt = 0.f;
1082-
attack = 1;
1087+
if(sticky == 0)
1088+
{
1089+
swipe = 1;
1090+
swipe_phase = 0;
1091+
swipe_lt = 0.f;
1092+
attack = 1;
1093+
}
1094+
else
1095+
{
1096+
if(left_sticky_state == 0)
1097+
{
1098+
swipe = 1;
1099+
swipe_phase = 0;
1100+
swipe_lt = 0.f;
1101+
attack = 1;
1102+
}
1103+
else
1104+
{
1105+
swipe = 0;
1106+
swipe_phase = 0;
1107+
swipe_lt = 0.f;
1108+
attack = 0;
1109+
}
1110+
left_sticky_state = 1 - left_sticky_state;
1111+
}
10831112
}
1084-
if(button == GLFW_MOUSE_BUTTON_RIGHT)
1113+
else if(button == GLFW_MOUSE_BUTTON_RIGHT)
10851114
{
1086-
if(zoom >= -0.11f)
1115+
if(sticky == 0)
10871116
{
1088-
lz = -0.10f;
1089-
zoom = -0.18f;
1090-
}else{lz = 0.f;}
1091-
focus = 1;
1117+
if(zoom >= -0.11f)
1118+
{
1119+
lz = -0.10f;
1120+
zoom = -0.18f;
1121+
}else{lz = 0.f;}
1122+
focus = 1;
1123+
}
1124+
else
1125+
{
1126+
if(right_sticky_state == 0)
1127+
{
1128+
if(zoom >= -0.11f)
1129+
{
1130+
lz = -0.10f;
1131+
zoom = -0.18f;
1132+
}else{lz = 0.f;}
1133+
focus = 1;
1134+
}
1135+
else
1136+
{
1137+
if(lz != 0.f){zoom = lz;}
1138+
focus = 0;
1139+
}
1140+
right_sticky_state = 1 - right_sticky_state;
1141+
}
10921142
}
10931143
}
1094-
else if(action == GLFW_RELEASE)
1144+
else if(sticky == 0 && action == GLFW_RELEASE)
10951145
{
10961146
if(button == GLFW_MOUSE_BUTTON_LEFT)
10971147
{
10981148
swipe = 0;
10991149
swipe_phase = 0;
11001150
swipe_lt = 0.f;
11011151
attack = 0;
1152+
left_sticky_state = 0;
11021153
}
11031154
else if(button == GLFW_MOUSE_BUTTON_RIGHT)
11041155
{
11051156
if(lz != 0.f){zoom = lz;}
11061157
focus = 0;
1158+
right_sticky_state = 0;
11071159
}
11081160
}
11091161
}
@@ -1157,6 +1209,7 @@ int main(int argc, char** argv)
11571209
printf("Space = Jet Pack\n");
11581210
printf("1-9 = Weapon Change\n");
11591211
printf("C = Toggle between First and Third person\n");
1212+
printf("V = Toggle between stickey/toggle mouse clicks (good for afk)\n");
11601213
printf("----\n");
11611214
printf("Tux made by Andy Cuccaro\n");
11621215
printf("https://sketchfab.com/3d-models/tux-157de95fa4014050a969a8361a83d366\n");
@@ -1346,7 +1399,8 @@ int main(int argc, char** argv)
13461399
//
13471400
islands_type[0] = 5;
13481401
for(uint i=1; i < MAX_ISLANDS; i++){islands_type[i] = esRand(5, 7);}
1349-
pp = (vec){0.f, 0.5f, 0.2f};
1402+
pp = (vec){0.f, 0.5f, 0.9f};
1403+
focus = 1; // smooth drop-in [3]
13501404
t = fTime();
13511405
lfct = t;
13521406

0 commit comments

Comments
 (0)