Squad selection

main
Cameron Murphy Reikes 2 years ago
parent bacc6e9f03
commit fe2c9d07c5

@ -235,6 +235,7 @@
<ClCompile Include="thirdparty\minilzo\minilzo.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="hueshift.gen.h" />
<ClInclude Include="ipsettings.h" />
<ClInclude Include="thirdparty\minilzo\lzoconf.h" />
<ClInclude Include="thirdparty\minilzo\lzodefs.h" />

@ -191,6 +191,9 @@
<ClInclude Include="thirdparty\minilzo\minilzo.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="hueshift.gen.h">
<Filter>Source Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="thirdparty\enet\enet_dll.cbp" />

@ -1,2 +1,3 @@
call shadergen.bat
set compileopts=/Fe"flight_debug" /Zi /FS /Fd"flight.pdb" /DSERVER_ADDRESS="\"127.0.0.1\"" /DDEBUG_RENDERING
call build_msvc.bat

@ -2,16 +2,12 @@
@REM what all the compile flags mean: https://learn.microsoft.com/en-us/cpp/build/reference/compiler-options-listed-by-category?view=msvc-170
WHERE sokol-shdc.exe
IF %ERRORLEVEL% NEQ 0 ECHO ERROR download sokol-shdc from https://github.com/floooh/sokol-tools-bin/blob/master/bin/win32/sokol-shdc.exe and put it in this folder
set OPUSLIB=%~dp0\thirdparty\opus\win32\VS2015\x64\Release\opus.lib
WHERE %OPUSLIB%
IF %ERRORLEVEL% NEQ 0 ECHO ERROR Couldn't find %OPUSLIB% compile opus by opening the visual studio project in win32\VS2015 and building the release setting
@REM example of how to compile shaders: sokol-shdc.exe --input triangle.glsl --output triangle.gen.h --slang glsl330:hlsl5:metal_macos
setlocal enabledelayedexpansion enableextensions
pushd thirdparty\Chipmunk2D\src
set MUNKSRC=

File diff suppressed because it is too large Load Diff

@ -770,6 +770,7 @@ enum GameVersion
VRemovedTest,
VChangedVectorSerializing,
VAddedLastUsedMedbay,
VAddedSquads,
VMax, // this minus one will be the version used
};
@ -808,6 +809,7 @@ SerMaybeFailure ser_inputframe(SerState* ser, InputFrame* i)
SER_VAR(&i->tick);
SER_VAR(&i->id);
SER_MAYBE_RETURN(ser_V2(ser, &i->movement));
SER_VAR(&i->take_over_squad);
SER_VAR(&i->seat_action);
SER_MAYBE_RETURN(ser_entityid(ser, &i->seat_to_inhabit));
@ -829,6 +831,8 @@ SerMaybeFailure ser_player(SerState* ser, Player* p)
if (p->connected)
{
SER_VAR(&p->unlocked_bombs);
if(ser->version >= VAddedSquads)
SER_VAR(&p->squad);
SER_MAYBE_RETURN(ser_entityid(ser, &p->entity));
if (ser->version >= VAddedLastUsedMedbay)
SER_MAYBE_RETURN(ser_entityid(ser, &p->last_used_medbay));
@ -912,6 +916,8 @@ SerMaybeFailure ser_entity(SerState* ser, GameState* gs, Entity* e)
{
SER_ASSERT(e->no_save_to_disk);
SER_MAYBE_RETURN(ser_entityid(ser, &e->currently_inside_of_box));
if(ser->version >= VAddedSquads)
SER_VAR(&e->presenting_squad);
SER_VAR(&e->goldness);
}
@ -1468,6 +1474,27 @@ void process(GameState* gs, float dt)
// process input
PLAYERS_ITER(gs->players, player)
{
if (player->input.take_over_squad >= 0)
{
if (player->input.take_over_squad == SquadNone)
{
player->squad = SquadNone;
}
else {
bool squad_taken = false;
PLAYERS_ITER(gs->players, other_player)
{
if (other_player->squad == player->input.take_over_squad)
{
squad_taken = true;
break;
}
}
if (!squad_taken)
player->squad = player->input.take_over_squad;
}
player->input.take_over_squad = -1;
}
Entity* p = get_entity(gs, player->entity);
if (p == NULL)
{
@ -1482,6 +1509,7 @@ void process(GameState* gs, float dt)
entity_ensure_in_orbit(p);
}
assert(p->is_player);
p->presenting_squad = player->squad;
#ifdef INFINITE_RESOURCES
p->damage = 0.0f;

@ -0,0 +1,53 @@
@module hueshift
@vs vs
in vec4 coord;
out vec2 texUV;
void main() {
gl_Position = vec4(coord.xy, 0.0, 1.0);
texUV = coord.zw;
}
@end
@fs fs
uniform sampler2D iChannel0;
uniform uniforms {
int is_colorless; // if greater than zero, no color
float target_hue;
};
in vec2 texUV;
out vec4 fragColor;
vec3 rgb2hsv(vec3 c)
{
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
float d = q.x - min(q.w, q.y);
float e = 1.0e-10;
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
}
vec3 hsv2rgb(vec3 c)
{
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
}
void main() {
vec4 outColor = texture(iChannel0, texUV);
vec3 hsv = rgb2hsv(outColor.rgb);
if(is_colorless > 0)
{
hsv.y = 0.0f;
} else if(hsv.y > 0.5) {
hsv.x = target_hue;
}
fragColor = vec4(hsv2rgb(hsv), outColor.a);
}
@end
@program program vs fs

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

593
main.c

File diff suppressed because it is too large Load Diff

@ -253,6 +253,7 @@ void server(void* info_raw)
#ifdef UNLOCK_ALL
gs.players[player_slot].unlocked_bombs = true;
#endif
gs.players[player_slot].squad = SquadPurple;
}
}
break;
@ -296,6 +297,8 @@ void server(void* info_raw)
// for these "event" inputs, only modify the current input if the event is true.
// while processing the gamestate, will mark it as false once processed. This
// prevents setting the event input to false before it's been processed.
if (cur_input.take_over_squad >= 0)
gs.players[player_slot].input.take_over_squad = cur_input.take_over_squad;
if (cur_input.seat_action)
{
gs.players[player_slot].input.seat_action = cur_input.seat_action;

@ -0,0 +1,6 @@
WHERE sokol-shdc.exe
IF %ERRORLEVEL% NEQ 0 ECHO ERROR download sokol-shdc from https://github.com/floooh/sokol-tools-bin/blob/master/bin/win32/sokol-shdc.exe and put it in this folder
@REM example of how to compile shaders: sokol-shdc.exe --input triangle.glsl --output triangle.gen.h --slang glsl330:hlsl5:metal_macos
sokol-shdc.exe --format sokol --input hueshift.glsl --output hueshift.gen.h --slang glsl330:hlsl5:metal_macos

@ -121,6 +121,16 @@ enum CompassRotation
RotationLast,
};
enum Squad
{
SquadNone,
SquadRed,
SquadGreen,
SquadBlue,
SquadPurple,
SquadLast,
};
// when generation is 0, invalid ID
typedef struct EntityID
{
@ -141,6 +151,8 @@ typedef struct InputFrame
size_t id; // each input has unique, incrementing, I.D, so server doesn't double process inputs. Inputs to server should be ordered from 0-max like biggest id-smallest. This is done so if packet loss server still processes input
V2 movement;
int take_over_squad; // -1 means not taking over any squad
bool seat_action;
EntityID seat_to_inhabit;
V2 hand_pos; // local to player transationally but not rotationally unless field below is not null, then it's local to that grid
@ -172,6 +184,7 @@ typedef struct Entity
// player
bool is_player;
enum Squad presenting_squad;
EntityID currently_inside_of_box;
float goldness; // how much the player is a winner
@ -206,6 +219,7 @@ typedef struct Player
{
bool connected;
bool unlocked_bombs;
enum Squad squad;
EntityID entity;
EntityID last_used_medbay;
InputFrame input;
@ -236,6 +250,7 @@ typedef struct GameState
#define PLAYERS_ITER(players, cur) for(Player * cur = players; cur < players+MAX_PLAYERS; cur++) if(cur->connected)
#define PI 3.14159f
#define TAU (PI*2.0f)
// returns in radians
static float rotangle(enum CompassRotation rot)
@ -391,8 +406,6 @@ static OpusPacket* push_packet(OpusBuffer* buff)
return to_return;
}
// how many unpopped packets there are, can't check for null on pop_packet because
// could be a skipped packet. This is used in a for loop to flush a packet buffer
static int num_queued_packets(OpusBuffer* buff)
{
int to_return = 0;
@ -558,6 +571,12 @@ static float lerp(float a, float b, float f)
return a * (1.0f - f) + (b * f);
}
static float lerp_angle(float p_from, float p_to, float p_weight) {
float difference = fmodf(p_to - p_from, (float)TAU);
float distance = fmodf(2.0f * difference, (float)TAU) - difference;
return p_from + distance * p_weight;
}
static V2 V2floor(V2 p)
{
return (V2) { floorf(p.x), floorf(p.y) };

Loading…
Cancel
Save