feat: add given files

Signed-off-by: Julien CLEMENT <julien.clement@epita.fr>
This commit is contained in:
juju committed 2021-07-12 15:57:08 +02:00
commit 7178dbb6a7
151 files changed
+13845

No files matched your search

+2
View File
@@ -0,0 +1,2 @@
* bucchi_m (Matthieu Bucchianeri)
* voltz_r (Renaud Voltz)
+59
View File
@@ -0,0 +1,59 @@
#
# Copyright (c) LSE
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY LSE AS IS AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL LSE BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
TARGET = skate
OBJS = \
gfx.o \
park.o \
skate.o \
skater.o \
ROM_TITLE = "skate"
ROM_FILES = \
res/box.bmp \
res/boxup.bmp \
res/crash.bmp \
res/flip1.bmp \
res/flip2.bmp \
res/flip3.bmp \
res/flip4.bmp \
res/flip5.bmp \
res/logo.bmp \
res/rail.bmp \
res/rotate1.bmp \
res/rotate2.bmp \
res/rotate3.bmp \
res/rotate4.bmp \
res/rotate5.bmp \
res/skater1.bmp \
res/skater2.bmp \
res/skater3.bmp \
res/skater4.bmp \
res/skater5.bmp \
res/skater6.bmp \
res/skaterup.bmp \
res/slide1.bmp \
res/slide2.bmp \
include ../roms.mk
+48
View File
@@ -0,0 +1,48 @@
/*
* Copyright (c) LSE
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY LSE AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL LSE BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "skate.h"
struct gfx graphics[] = {
{TRICK_NONE, 7, RES_PATH "/res/skater1.bmp " RES_PATH "/res/skater2.bmp", NULL},
{TRICK_RUN, 7, RES_PATH "/res/skater3.bmp " RES_PATH "/res/skater4.bmp " RES_PATH "/res/skater5.bmp " RES_PATH "/res/skater6.bmp", NULL},
{TRICK_FLIP, 5, RES_PATH "/res/flip1.bmp " RES_PATH "/res/flip2.bmp " RES_PATH "/res/flip3.bmp " RES_PATH "/res/flip4.bmp " RES_PATH "/res/flip5.bmp", NULL},
{TRICK_UP, 4, RES_PATH "/res/skaterup.bmp", NULL},
{TRICK_SLIDE, 6, RES_PATH "/res/slide1.bmp " RES_PATH "/res/slide2.bmp", NULL},
{TRICK_CRASH, 6, RES_PATH "/res/crash.bmp", NULL},
{TRICK_ROTATE, 8, RES_PATH "/res/rotate1.bmp " RES_PATH "/res/rotate2.bmp " RES_PATH "/res/rotate3.bmp " RES_PATH "/res/rotate4.bmp " RES_PATH "/res/rotate5.bmp", NULL},
{BOX_UP, 0, RES_PATH "/res/boxup.bmp", NULL},
{BOX, 0, RES_PATH "/res/box.bmp", NULL},
{BOX_RAIL, 0, RES_PATH "/res/rail.bmp", NULL},
{0, 0, NULL, NULL}
};
void gfx_init(void)
{
for (int i = 0; graphics[i].filename; i++) {
if (graphics[i].delay)
graphics[i].gfx = load_anim(graphics[i].filename, graphics[i].delay);
else
graphics[i].gfx = load_image(graphics[i].filename);
}
}
+150
View File
@@ -0,0 +1,150 @@
/*
* Copyright (c) LSE
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY LSE AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL LSE BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "skate.h"
#define array_size(A) (sizeof (A) / sizeof (*A))
static const enum e_gfx park_begin[] = {
NO_BOX, NO_BOX, NO_BOX, NO_BOX, BOX_UP, BOX, BOX, NO_BOX, NO_BOX, BOX_UP
};
static const enum e_gfx park_loop[] = {
NO_BOX, BOX_RAIL, BOX_RAIL, NO_BOX, BOX_UP, BOX, BOX, NO_BOX, NO_BOX, BOX_UP
};
struct scrolling scrolling;
enum e_gfx get_park(size_t box) {
if (box < array_size(park_begin))
return park_begin[box];
return park_loop[(box - array_size(park_begin)) % array_size(park_loop)];
}
void scroll_stop(void)
{
scrolling.timer1 = scrolling.timer2 = jiffies;
scrolling.freq = 6;
}
static void scroll_init(void)
{
scrolling.step = 2;
scrolling.width = 0;
scrolling.current_box = 0;
scrolling.x = 0;
scroll_stop();
}
void park_init(void)
{
scroll_init();
}
int get_box(int x)
{
return x / BOX_WIDTH;
}
int get_shift(int x)
{
return x % BOX_WIDTH;
}
int box_height(int box, int shift)
{
switch (get_park(box)) {
case BOX_UP:
return shift;
case BOX_RAIL:
if (skater.slide)
return 15;
else
return 0;
case BOX:
return BOX_HEIGHT;
default:
return 0;
}
}
void park_draw(void)
{
int box = get_box(scrolling.x);
int x = -get_shift(scrolling.x);
do {
enum e_gfx p = get_park(box);
if (graphics[p].gfx)
draw_image_alpha(graphics[p].gfx,
x, GRAPHIC_HEIGHT - 10 - BOX_HEIGHT,
BG_COLOR);
x += BOX_WIDTH;
box++;
} while (x < GRAPHIC_WIDTH);
}
void scroll(void)
{
// automatic slow down
if (!skater.slide)
if (jiffies - scrolling.timer1 >= 20) {
scrolling.timer1 = jiffies;
scroll_slowdown();
}
// scroll left
if (jiffies - scrolling.timer2 >= (unsigned long)scrolling.freq) {
scrolling.timer2 = jiffies;
if (scrolling.freq < 6) {
if (skater.x < GRAPHIC_WIDTH / 2 - BOX_WIDTH)
skater.x += scrolling.step;
else {
scrolling.x += scrolling.step;
scrolling.width += scrolling.step;
}
}
}
//
if (scrolling.width == BOX_WIDTH) {
scrolling.width = 0;
scrolling.current_box++;
}
}
int scroll_slowdown(void)
{
scrolling.freq++;
if (scrolling.freq > 6)
scrolling.freq = 6;
return scrolling.freq;
}
int scroll_speedup(void)
{
scrolling.freq -= 2;
if (scrolling.freq <= 0)
scrolling.freq = 0;
return scrolling.freq;
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

+224
View File
@@ -0,0 +1,224 @@
/*
* Copyright (c) LSE
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY LSE AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL LSE BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "skate.h"
unsigned long jiffies = 0;
char *trick[10];
int hhh[10];
struct {
enum e_gfx trick;
char *name;
int points;
int duration;
} tricks[] = {
{TRICK_ROTATE, "360", 30, 25},
{TRICK_ROTATE, "720", 30, 25},
{TRICK_FLIP, "flip", 20, 20},
{TRICK_SLIDE, "slide", 1, 1},
{TRICK_NONE, NULL, 0, 0}
};
static void draw_trick(void)
{
int i;
int j;
for (i = 0; tricks[i].name; i++)
if (tricks[i].trick == skater.trick)
break;
if (tricks[i].trick != TRICK_NONE && tricks[i].trick != TRICK_SLIDE)
if (skater.trick_delay == tricks[i].duration - 1) {
// if (skater.rotation < 720)
for (j = 0; j < 9; j++) {
trick[j] = trick[j + 1];
hhh[j] = hhh[j + 1];
}
trick[9] = tricks[i].name;
hhh[9] = skater.y - skater.height - 10;
if (hhh[9] <= hhh[8] + 9)
hhh[9] = hhh[8] + 10;
}
for (i = 0; i < 10; i++) {
if (--hhh[i] <= 20)
trick[i] = NULL;
if (trick[i])
draw_text(trick[i], skater.x + 10, hhh[i], YELLOW,
BG_COLOR);
}
}
static void splash_screen(void)
{
unsigned long t;
int blink = 0;
struct image *logo = load_image(RES_PATH "/res/logo.bmp");
while (getkey() < 0) {
draw_clear(BG_COLOR);
draw_image(logo, 10, 20);
draw_text("K skater", 200, 40, RED, BG_COLOR);
draw_text("Kernel option - LSE - 2006-2007", 5, 190, BLUE,
BG_COLOR);
if (blink >= 5)
draw_text("Any key to start", 170, 90, WHITE, 0);
draw_end();
blink = (blink + 1) % 10;
t = gettick();
while (gettick() - t < 66) ;
}
}
void speed(void)
{
int x = 10;
int y = 120;
if (scrolling.freq < 6)
draw_fillrect(x, y - 10, x + 7, y, BLACK, GREEN);
if (scrolling.freq < 5)
draw_fillrect(x, y - 20, x + 7, y - 10, BLACK, YELLOW);
if (scrolling.freq < 4)
draw_fillrect(x, y - 30, x + 7, y - 20, BLACK, ORANGE);
if (scrolling.freq < 3)
draw_fillrect(x, y - 40, x + 7, y - 30, BLACK, RED);
if (scrolling.freq < 2)
draw_fillrect(x, y - 50, x + 7, y - 40, BLACK, PURPLE);
if (scrolling.freq < 1)
draw_fillrect(x, y - 60, x + 7, y - 50, BLACK, AQUA);
}
void draw_score(void)
{
char buf[12] = { 0 };
draw_trick();
// draw_text("Time: ", 10, 10, PURPLE, BG_COLOR);
sprintf(buf, "%d", jiffies / 50);
draw_text(buf, 10, 10, PURPLE, BG_COLOR);
draw_text("Trick: ", GRAPHIC_WIDTH / 2 - 45, 10, BLUE, BG_COLOR);
sprintf(buf, "%d", score_tmp);
draw_text(buf, GRAPHIC_WIDTH / 2 + 5, 10, BLUE, BG_COLOR);
if (skater.combo > 1) {
draw_text("Combo x", GRAPHIC_WIDTH / 2 - 45, 20, RED, BG_COLOR);
sprintf(buf, "%d", skater.combo);
draw_text(buf, GRAPHIC_WIDTH / 2 + 15, 20, RED, BG_COLOR);
}
draw_text("Score: ", GRAPHIC_WIDTH - 90, 10, GREEN, BG_COLOR);
sprintf(buf, "%d", score);
draw_text(buf, GRAPHIC_WIDTH - 40, 10, GREEN, BG_COLOR);
}
/*
* the splash screen with sexy chiche's face.
*/
static void game_loop(void)
{
while (1) {
unsigned long t = gettick();
if (!skater.trick_delay)
switch (getkey()) {
case KEY_SPACE:
skater_jump(scrolling.freq);
break;
case KEY_RIGHT:
scroll_speedup();
break;
case KEY_DOWN:
skater_slide();
break;
case KEY_LEFT:
skater_rotate();
break;
case KEY_UP:
skater_flip();
break;
case KEY_ESC:
return;
default:
break;
}
draw_clear(BG_COLOR);
// background();
park_draw();
skater_draw();
draw_score();
speed();
draw_end();
/*
* 8ms between frames
*/
while (gettick() - t <= 8) ;
jiffies++;
scroll();
}
}
/*
* game entry point.
*/
void entry(void)
{
int i;
gfx_init();
switch_graphic();
while (1) {
splash_screen();
for (i = 0; i < 10; i++)
trick[i] = NULL;
jiffies = 0;
score = 0;
park_init();
skater_init();
game_loop();
}
/*
* we should never arrive here...
*/
switch_text();
}
+110
View File
@@ -0,0 +1,110 @@
/*
* Copyright (c) LSE
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY LSE AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL LSE BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef SKATE_H_
#define SKATE_H_
#include <graphic.h>
#include <sound.h>
#include <stdlib.h>
enum e_gfx {
TRICK_NONE = 0,
TRICK_RUN,
TRICK_FLIP,
TRICK_UP,
TRICK_SLIDE,
TRICK_CRASH,
TRICK_ROTATE,
BOX_UP,
BOX,
BOX_RAIL,
NO_BOX
};
struct skater {
int x;
int y;
int height;
int width;
int fly;
int jump;
int trick_delay;
unsigned int trick;
int slide;
int rotation;
int combo;
int current_box;
};
struct scrolling {
unsigned long timer1;
unsigned long timer2;
int freq;
int step;
int x;
int current_box;
int width;
};
struct gfx {
enum e_gfx id;
int delay;
char *filename;
void *gfx;
};
#define BG_COLOR BLACK
#define BOX_WIDTH 40
#define BOX_HEIGHT 40
#define SPEED 2
extern struct scrolling scrolling;
extern unsigned long jiffies;
extern struct skater skater;
extern int score;
extern int score_tmp;
extern struct gfx graphics[];
extern char *trick[];
int scroll_slowdown(void);
int scroll_speedup(void);
void scroll(void);
enum e_gfx get_park(size_t box);
void park_init(void);
void park_draw(void);
int box_height(int box, int shift);
int get_box(int x);
int get_shift(int x);
void skater_init(void);
void skater_draw(void);
void skater_jump(int height);
void skater_flip(void);
void skater_rotate(void);
void skater_slide(void);
void gfx_init(void);
#endif /* !SKATE_H_ */
+198
View File
@@ -0,0 +1,198 @@
/*
* Copyright (c) LSE
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY LSE AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL LSE BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "skate.h"
struct skater skater;
struct anim *anim[7];
int score = 0;
int score_tmp = 0;
static void skater_anim(void)
{
if (skater.trick_delay)
skater.trick_delay--;
if (skater.fly) {
if (!skater.trick_delay)
skater.trick = TRICK_NONE;
} else if (!skater.trick_delay) {
switch (get_park(skater.current_box)) {
case BOX_UP:
skater.trick = TRICK_UP;
break;
case BOX_RAIL:
if (skater.slide)
break;
/* Falls through. */
default:
if (scrolling.freq < 6)
skater.trick = TRICK_RUN;
else
skater.trick = TRICK_NONE;
break;
}
}
draw_anim(graphics[skater.trick].gfx, skater.x, skater.y - skater.height, jiffies);
}
void skater_jump(int height)
{
if (!skater.fly && !skater.jump)
skater.jump = skater.y - 14 - 8 * ((6 - height));
}
void skater_flip(void)
{
if (skater.trick_delay || !skater.fly)
return;
skater.rotation = 0;
skater.trick_delay = 20;
skater.trick = TRICK_FLIP;
skater.combo++;
score_tmp += 20;
}
void skater_rotate(void)
{
if (skater.trick_delay || !skater.fly)
return;
skater.trick_delay = 25;
skater.trick = TRICK_ROTATE;
skater.rotation += 360;
skater.combo++;
score_tmp += 30;
}
static void skater_crash(void)
{
skater.trick_delay = 100;
skater.trick = TRICK_CRASH;
skater.rotation = 0;
score_tmp = skater.combo = 0;
}
void skater_slide(void)
{
if (skater.trick_delay || get_park(skater.current_box) != BOX_RAIL)
return;
if (scrolling.freq > 5)
return;
skater.slide = 1;
if (skater.trick != TRICK_SLIDE && !skater.fly)
skater.combo++;
skater.trick = TRICK_SLIDE;
score_tmp += 3;
}
void skater_init(void)
{
skater.x = 0;
skater.y = GRAPHIC_HEIGHT - 10;
skater.height = 50;
skater.width = 50;
skater.fly = 0;
skater.jump = 0;
skater.trick_delay = 0;
skater.trick = TRICK_RUN;
skater.slide = 0;
skater.rotation = 0;
skater.combo = 0;
score_tmp = 0;
}
int skater_height(int pos)
{
int y_max = 0;
int x_max = pos - 6;
int x;
int y;
for (x = pos - 6; x < pos + 6; x++) {
y = box_height(get_box(x), get_shift(x));
if (y > y_max) {
y_max = y;
x_max = x;
}
}
return x_max;
}
void skater_height_update(int floor_height)
{
if (skater.jump) {
skater.y -= 2;
if (skater.y <= skater.jump)
skater.jump = 0;
} else {
if (skater.y < floor_height)
skater.y += 2;
else
skater.y = floor_height;
}
skater.fly = (skater.y < floor_height) ? 1 : 0;
if (!skater.fly)
skater.rotation = 0;
if (!skater.fly && skater.trick_delay && skater.trick != TRICK_CRASH)
skater_crash();
}
void skater_draw(void)
{
int floor;
int max_x;
max_x = skater_height(skater.x + skater.width / 2 + scrolling.x);
skater.current_box = get_box(max_x);
if (get_park(skater.current_box) != BOX_RAIL)
skater.slide = 0;
floor = GRAPHIC_HEIGHT - 10 - box_height(skater.current_box, get_shift(max_x));
skater_height_update(floor);
skater_anim();
if (!skater.trick_delay && !skater.slide && !skater.fly) {
if (skater.trick != TRICK_CRASH) {
score += score_tmp;
if (skater.combo)
score += (10 + skater.combo) * (skater.combo - 1);
skater.combo = 0;
score_tmp = 0;
}
}
}
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.