games: revert to 60 fps, slower Snake base speed
Switched both games back to 60 fps (FRAME_MS = 16 ms) for smoother rendering and reduced Snake base speed from 150 to 90 px/sec (~60 ms -> ~100 ms per step at cell=9) so the snake is controllable and doesn't feel too fast. Progressive difficulty (+1 px/sec per 5 food) and turn queue are unchanged.
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+5
-5
@@ -107,8 +107,8 @@ static int tqn = 0; // number of queued turns
|
|||||||
static int foodx, foody;
|
static int foodx, foody;
|
||||||
static int score = 0;
|
static int score = 0;
|
||||||
static int best = 0;
|
static int best = 0;
|
||||||
static int speed = 90; // ms per step (derived from pps below)
|
static int speed = 100; // ms per step (derived from pps below)
|
||||||
static int pps = 150; // base speed px/sec; +1 px/sec per 5 food eaten
|
static int pps = 90; // base speed px/sec; +1 px/sec per 5 food eaten
|
||||||
static unsigned long nextTick = 0;
|
static unsigned long nextTick = 0;
|
||||||
static bool running = true;
|
static bool running = true;
|
||||||
static unsigned long now_ms() {
|
static unsigned long now_ms() {
|
||||||
@@ -166,7 +166,7 @@ static void reset_game() {
|
|||||||
dirx = 1; diry = 0;
|
dirx = 1; diry = 0;
|
||||||
tqn = 0;
|
tqn = 0;
|
||||||
score = 0;
|
score = 0;
|
||||||
pps = 150;
|
pps = 90;
|
||||||
update_speed();
|
update_speed();
|
||||||
place_food();
|
place_food();
|
||||||
state = PLAYING;
|
state = PLAYING;
|
||||||
@@ -224,7 +224,7 @@ static void step() {
|
|||||||
score += 10;
|
score += 10;
|
||||||
if (score > best) best = score;
|
if (score > best) best = score;
|
||||||
int food = score / 10; // food items eaten so far
|
int food = score / 10; // food items eaten so far
|
||||||
pps = 150 + food / 5; // +1 px/sec per 5 food eaten (progressive difficulty)
|
pps = 90 + food / 5; // +1 px/sec per 5 food eaten (progressive difficulty)
|
||||||
update_speed();
|
update_speed();
|
||||||
place_food();
|
place_food();
|
||||||
}
|
}
|
||||||
@@ -407,7 +407,7 @@ int main() {
|
|||||||
render();
|
render();
|
||||||
|
|
||||||
int xfd = ConnectionNumber(dpy);
|
int xfd = ConnectionNumber(dpy);
|
||||||
const unsigned long FRAME_MS = 1000 / 30; // 30 fps rendering
|
const unsigned long FRAME_MS = 1000 / 60; // 60 fps rendering
|
||||||
unsigned long frameStart = now_ms();
|
unsigned long frameStart = now_ms();
|
||||||
|
|
||||||
while (running) {
|
while (running) {
|
||||||
|
|||||||
@@ -520,7 +520,7 @@ int main() {
|
|||||||
render();
|
render();
|
||||||
|
|
||||||
int xfd = ConnectionNumber(dpy);
|
int xfd = ConnectionNumber(dpy);
|
||||||
const unsigned long FRAME_MS = 1000 / 30; // 30 fps rendering
|
const unsigned long FRAME_MS = 1000 / 60; // 60 fps rendering
|
||||||
unsigned long frameStart = now_ms();
|
unsigned long frameStart = now_ms();
|
||||||
|
|
||||||
while (running) {
|
while (running) {
|
||||||
|
|||||||
Reference in New Issue
Block a user