Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ static void audio_mix(void *data, Uint8 *stream, int len)
float both = audio_index_value(&audio->back, 0) +
audio_index_value(&audio->hit, 0) +
audio_index_value(&audio->crash, 0);
float left = audio_index_value(&audio->left, audio->ship->lefton);
float right = audio_index_value(&audio->right, audio->ship->righton);
float left = audio_index_value(&audio->left, audio->ship->lefton || audio->ship->upon || audio->ship->downon);
float right = audio_index_value(&audio->right, audio->ship->righton || audio->ship->upon || audio->ship->downon);

buffer[i++] = audio_soft_clamp(right + both);
buffer[i++] = audio_soft_clamp(left + both);
Expand Down
16 changes: 7 additions & 9 deletions src/control.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,15 @@ static void control (Render* render, Audio* audio, Game* game, Input* input, Arg
static void player_control (Ship* player, Input* input, int game_mode)
{
#define K(k) (input->pressed[SDLK_##k])
bool up = K(DOWN) || K(UP) || K(w) || K(s);;
bool up = K(UP) || K(w);
bool left = K(LEFT) || K(LSHIFT) || K(LCTRL) || K(a);
bool right = K(RIGHT) || K(RSHIFT) || K(RCTRL) || K(d);

if (game_mode == ONE_BUTTON) {
player->lefton = player->righton = left || up || right;
}
else {
player->lefton = left || (up && !right);
player->righton = right || (up && !left);
}
bool down = K(DOWN) || K(s);

player->upon = up;
player->lefton = left;
player->righton = right;
player->downon = down;
}

static void args_init (Args* args, int argc, char* argv[])
Expand Down
18 changes: 14 additions & 4 deletions src/game.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ static void ship_init (Ship* ship, float radius)
ship->radius = radius;
ship->dist = FLT_MAX;
SET (ship->repulsion,0,1,0);
ship->lefton = ship->righton = false;
ship->lefton = ship->righton = ship->downon = ship->upon = false;
}

static void digger_init(Digger *digger, float radius)
Expand Down Expand Up @@ -230,18 +230,28 @@ void ship_move (Ship* ship, float dt)
{
float acc = THRUST*dt;
int roll = 0;


if(ship->upon) {
Vec3 up = { 0, acc*2.0, 0 };
ADD(ship->vel, up);
}

if(ship->lefton) {
Vec3 leftup = { -acc, acc/2, 0 };
Vec3 leftup = { -acc*2, acc/2.0, 0 };
ADD(ship->vel, leftup);
roll--;
}

if(ship->righton) {
Vec3 rightup = { +acc, acc/2, 0 };
Vec3 rightup = { +acc*2, acc/2.0, 0 };
ADD(ship->vel, rightup);
roll++;
}

if(ship->downon) {
Vec3 down = { 0, -acc*2, 0 };
ADD(ship->vel, down);
}

ship->vel[1] -= GRAVITY*dt;

Expand Down
4 changes: 2 additions & 2 deletions src/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ typedef struct Ship_struct
float radius;
Vec3 pos, vel, lookAt;
float roll;
bool lefton, righton;
bool lefton, righton, downon, upon;
float dist; // distance to cave wall
Vec3 repulsion; // normal to collision
float start;
Expand Down Expand Up @@ -113,7 +113,7 @@ extern const char* data_paths[];

#define GRAVITY 9.8
#define THRUST (GRAVITY*2)
#define VELOCITY 30.0
#define VELOCITY 120.0

#define MAX_CAVE_RADIUS (SHIP_RADIUS*30)
#define MIN_CAVE_RADIUS (SHIP_RADIUS*5)
Expand Down