feat: add given files
Signed-off-by: Julien CLEMENT <julien.clement@epita.fr>
No files matched your search
@@ -0,0 +1 @@
|
||||
* choute_f (Fabien Chouteau)
|
||||
@@ -0,0 +1,39 @@
|
||||
#
|
||||
# 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 = hunter
|
||||
OBJS = hunter.o
|
||||
ROM_TITLE = "chichehunter"
|
||||
ROM_FILES = \
|
||||
res/ball.bmp \
|
||||
res/ball.csf \
|
||||
res/bush.bmp \
|
||||
res/chef_big.bmp \
|
||||
res/chef.bmp \
|
||||
res/chiche_b.bmp \
|
||||
res/chiche.bmp \
|
||||
res/intro.csf \
|
||||
res/seine_w.bmp
|
||||
|
||||
include ../roms.mk
|
||||
@@ -0,0 +1,312 @@
|
||||
/*
|
||||
* 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 <graphic.h>
|
||||
#include <sound.h>
|
||||
|
||||
/*
|
||||
* the splash screen with sexy chiche's face.
|
||||
*/
|
||||
|
||||
static int splash_screen(void)
|
||||
{
|
||||
unsigned long t;
|
||||
struct image *imgchiche = load_image(RES_PATH "/res/chiche_b.bmp");
|
||||
struct image *imgchef = load_image(RES_PATH "/res/chef_big.bmp");
|
||||
int blink = 0;
|
||||
struct melody *intro = load_sound(RES_PATH "/res/intro.csf");
|
||||
int sel = 1;
|
||||
int k = 0;
|
||||
int mouse_x, mouse_y, buttons;
|
||||
|
||||
playsound(intro, -1);
|
||||
|
||||
if (!imgchef || !imgchiche)
|
||||
blue_screen("Unable to load chiche.bmp");
|
||||
|
||||
getmouse(&mouse_x, &mouse_y, &buttons);
|
||||
while (k != KEY_ENTER && !(buttons & 1)) {
|
||||
t = gettick();
|
||||
|
||||
getmouse(&mouse_x, &mouse_y, &buttons);
|
||||
k = getkey();
|
||||
if (k == KEY_UP || mouse_y > 0)
|
||||
sel = 1;
|
||||
|
||||
if (k == KEY_DOWN || mouse_y < 0)
|
||||
sel = 0;
|
||||
|
||||
draw_begin();
|
||||
draw_image(imgchiche, 5, 10);
|
||||
draw_image(imgchef, 5, 100);
|
||||
draw_text(" ChicheHunter ", 160, 50, RED, 0);
|
||||
if (blink >= 5)
|
||||
draw_text("Any key to start", 160, 90, WHITE, 0);
|
||||
draw_text("Monde de Merde 2008", 5, 190, BLUE, 0);
|
||||
|
||||
if (sel)
|
||||
draw_text("<==", 80, 40, BLUE, 0);
|
||||
else
|
||||
draw_text("<==", 80, 130, BLUE, 0);
|
||||
|
||||
draw_end();
|
||||
|
||||
/*
|
||||
* 66 ms frame sync
|
||||
*/
|
||||
|
||||
blink = (blink + 1) % 10;
|
||||
while (gettick() - t < 33)
|
||||
continue;
|
||||
}
|
||||
|
||||
playsound(NULL, -1);
|
||||
|
||||
clear_sound(intro);
|
||||
clear_image(imgchef);
|
||||
clear_image(imgchiche);
|
||||
return sel;
|
||||
}
|
||||
|
||||
#define WIDTH 320
|
||||
|
||||
#define MONSTERS_COLS 6
|
||||
#define NB_MONSTERS 20
|
||||
#define MONSTER_X_BBOX 20
|
||||
#define MONSTER_Y_BBOX 24
|
||||
|
||||
#define P_SIZE 15
|
||||
#define NUM_MOVE 20
|
||||
#define GAP_HIT 7
|
||||
|
||||
#define FACTOR_X 1.7
|
||||
#define FACTOR_Y 1
|
||||
|
||||
/*
|
||||
* game loop.
|
||||
*/
|
||||
|
||||
static void game_loop(struct image * img)
|
||||
{
|
||||
unsigned long t;
|
||||
int px, py;
|
||||
int k;
|
||||
float mx = 0, my = 0, mdx, mdy, max, may, alive;
|
||||
float les_mx[] = {
|
||||
320, 0, 0, 0, 320, 0, 320, 320, 320, 0, 0, 320, 0, 320, 320, 0, 0, 320, 320, 320, 0
|
||||
};
|
||||
float les_dx[] = {
|
||||
-5, 5, 5, 5, -5, 5, -5, -5, -5, 5, 5, -5, 5, -5, -5, 5, 5, -5, -5, -5, 5
|
||||
};
|
||||
float les_my[] = {
|
||||
50, 30, 20, 35, 50, 25, 25, 20, 50, 40, 46, 41, 36, 30, 28, 47, 33, 42, 51, 46
|
||||
};
|
||||
float les_dy[] = {
|
||||
-2, -2, -1, -3, -2, -1, -2, -2, -2.5, -1, -3, -2, -1, -1, -3, -1, -2, -1, -2, -2
|
||||
};
|
||||
int les_index = 0;
|
||||
int i = 0;
|
||||
int standby = 0;
|
||||
int fin = 0;
|
||||
int monsters = -1;
|
||||
int hit[NB_MONSTERS];
|
||||
int dead_monsters = 0;
|
||||
struct melody *sound = load_sound(RES_PATH "/res/ball.csf");
|
||||
int mouse_x, mouse_y, buttons;
|
||||
struct image *bush = load_image(RES_PATH "/res/bush.bmp");
|
||||
char score[] = "score: xx/xx";
|
||||
int choot, can_choot;
|
||||
|
||||
if (!img)
|
||||
blue_screen("Unable to load chiche.bmp");
|
||||
|
||||
px = 160;
|
||||
py = 100;
|
||||
mdx = 0;
|
||||
mdy = 0;
|
||||
max = 0;
|
||||
may = 0.1;
|
||||
alive = 0;
|
||||
can_choot = 1;
|
||||
|
||||
for (i = 0; i < NB_MONSTERS; i++)
|
||||
hit[i] = 0;
|
||||
|
||||
while (1) {
|
||||
t = gettick();
|
||||
|
||||
choot = 0;
|
||||
|
||||
draw_begin();
|
||||
draw_clear(240);
|
||||
|
||||
getmouse(&mouse_x, &mouse_y, &buttons);
|
||||
k = getkey();
|
||||
if (k > 0) {
|
||||
if (k == KEY_ESC)
|
||||
standby = !standby;
|
||||
|
||||
if ((standby || fin) && k == KEY_ENTER)
|
||||
return;
|
||||
}
|
||||
if (!standby && !fin) {
|
||||
px += mouse_x;
|
||||
py -= mouse_y;
|
||||
|
||||
if (can_choot && (buttons & 1)) {
|
||||
choot = 1;
|
||||
can_choot = 0;
|
||||
}
|
||||
|
||||
if (!(buttons & 1))
|
||||
can_choot = 1;
|
||||
|
||||
if (px <= 10)
|
||||
px = 11;
|
||||
if (px >= 320 - 10)
|
||||
px = 320 - 11;
|
||||
if (py <= 10)
|
||||
py = 11;
|
||||
if (py >= 200 - 10)
|
||||
py = 200 - 11;
|
||||
}
|
||||
|
||||
/*
|
||||
* move and draw monsters.
|
||||
*/
|
||||
if (alive) {
|
||||
if (!standby && !fin) {
|
||||
mdx += max;
|
||||
mdy += may;
|
||||
my += mdy;
|
||||
mx += mdx;
|
||||
}
|
||||
|
||||
if (my > 150 || mx < 0 || mx > 320) {
|
||||
alive = 0;
|
||||
hit[monsters] = 0;
|
||||
}
|
||||
|
||||
if (!fin)
|
||||
draw_image_alpha(img, mx, my, 0);
|
||||
} else {
|
||||
alive = 1;
|
||||
monsters++;
|
||||
mx = les_mx[les_index];
|
||||
my = les_my[les_index];
|
||||
mdy = les_dy[les_index] * FACTOR_Y;
|
||||
mdx = les_dx[les_index] * FACTOR_X;
|
||||
les_index = (les_index + 1) % NUM_MOVE;
|
||||
if (monsters == NB_MONSTERS)
|
||||
fin = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* draw BUSH.
|
||||
*/
|
||||
draw_fillrect(0, 150, 320, 200, 0, 0);
|
||||
draw_image_alpha(bush, 0, 0, 0);
|
||||
|
||||
/*
|
||||
* draw player.
|
||||
*/
|
||||
//draw_image (img, px, py);
|
||||
draw_line(px, py - 10, px, py + 10, RED);
|
||||
draw_line(px - 10, py, px + 10, py, RED);
|
||||
|
||||
/*
|
||||
* draw, move and inpact bullet.
|
||||
*/
|
||||
if (!standby && !fin && (buttons & 1)) {
|
||||
for (i = 0; i < NB_MONSTERS; i++) {
|
||||
if (alive && choot
|
||||
&& (px >= mx && px <= (mx + MONSTER_X_BBOX))
|
||||
&& (py >= my
|
||||
&& py <= (my + MONSTER_Y_BBOX))) {
|
||||
playsound(sound, 1);
|
||||
dead_monsters++;
|
||||
alive = 0;
|
||||
hit[monsters] = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* draw HIT.
|
||||
*/
|
||||
for (i = 0; i < NB_MONSTERS; i++)
|
||||
draw_text("|", 79 + i * GAP_HIT, 182,
|
||||
hit[i] ? WHITE : RED, BLACK);
|
||||
|
||||
/*
|
||||
* draw PAUSE.
|
||||
*/
|
||||
if (standby && !fin) {
|
||||
draw_text("PAUSE", 135, 50, WHITE, BLACK);
|
||||
draw_text("ESC key to continue", 90, 70, WHITE, BLACK);
|
||||
draw_text("ENTER key to quit", 93, 90, WHITE, BLACK);
|
||||
}
|
||||
|
||||
/*
|
||||
* draw FIN.
|
||||
*/
|
||||
if (fin) {
|
||||
score[7] = dead_monsters / 10 + '0';
|
||||
score[8] = dead_monsters % 10 + '0';
|
||||
score[10] = NB_MONSTERS / 10 + '0';
|
||||
score[11] = NB_MONSTERS % 10 + '0';
|
||||
draw_text(score, 110, 70, WHITE, BLACK);
|
||||
draw_text("ENTER key to quit", 90, 100, WHITE, BLACK);
|
||||
}
|
||||
|
||||
draw_end();
|
||||
|
||||
/*
|
||||
* 33 ms sync between each frame.
|
||||
*/
|
||||
while (gettick() - t <= 10)
|
||||
continue;
|
||||
}
|
||||
|
||||
clear_image(img);
|
||||
}
|
||||
|
||||
/*
|
||||
* game entry point.
|
||||
*/
|
||||
|
||||
void entry(void)
|
||||
{
|
||||
switch_graphic();
|
||||
|
||||
while (1) {
|
||||
game_loop(splash_screen()? load_image(RES_PATH "/res/chiche.bmp") :
|
||||
load_image(RES_PATH "/res/chef.bmp"));
|
||||
}
|
||||
/*
|
||||
* we should never arrive here...
|
||||
*/
|
||||
|
||||
switch_text();
|
||||
}
|
||||
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 64 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 7.0 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 7.0 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
@@ -0,0 +1,2 @@
|
||||
* bucchi_m (Matthieu Bucchianeri)
|
||||
* voltz_r (Renaud Voltz)
|
||||
@@ -0,0 +1,34 @@
|
||||
#
|
||||
# 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 = pong
|
||||
OBJS = pong.o
|
||||
ROM_TITLE = "pong"
|
||||
ROM_FILES = \
|
||||
res/ball.bmp \
|
||||
res/ball.ksf \
|
||||
res/chiche.bmp \
|
||||
res/intro.ksf \
|
||||
|
||||
include ../roms.mk
|
||||
@@ -0,0 +1,244 @@
|
||||
/*
|
||||
* 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 <graphic.h>
|
||||
#include <sound.h>
|
||||
|
||||
/*
|
||||
* the splash screen with sexy chiche's face.
|
||||
*/
|
||||
|
||||
static void splash_screen(void)
|
||||
{
|
||||
unsigned long t;
|
||||
struct image *img = load_image(RES_PATH "/res/chiche.bmp");
|
||||
int blink = 0;
|
||||
struct melody *intro = load_sound(RES_PATH "/res/intro.ksf");
|
||||
|
||||
playsound(intro, -1);
|
||||
|
||||
if (!img)
|
||||
blue_screen("Unable to load chiche.bmp");
|
||||
|
||||
while (getkey() < 0) {
|
||||
t = gettick();
|
||||
|
||||
draw_begin();
|
||||
draw_image(img, 5, 10);
|
||||
draw_text(" Chiche Pong ", 160, 50, RED, 0);
|
||||
draw_text("powered by Chiche", 160, 60, ORANGE, 0);
|
||||
if (blink >= 5)
|
||||
draw_text("Any key to start", 160, 90, WHITE, 0);
|
||||
draw_text("Kernel option - LSE - 2006-2007", 5, 190, BLUE, 0);
|
||||
draw_end();
|
||||
|
||||
/*
|
||||
* 66 ms frame sync
|
||||
*/
|
||||
|
||||
blink = (blink + 1) % 10;
|
||||
while (gettick() - t <= 66) ;
|
||||
}
|
||||
|
||||
playsound(NULL, -1);
|
||||
|
||||
clear_sound(intro);
|
||||
clear_image(img);
|
||||
}
|
||||
|
||||
/*
|
||||
* game loop.
|
||||
*/
|
||||
|
||||
static void game_loop(void)
|
||||
{
|
||||
unsigned long t;
|
||||
struct image *ball = load_image(RES_PATH "/res/ball.bmp");
|
||||
int player1;
|
||||
int player2;
|
||||
int x, y;
|
||||
int dx, dy;
|
||||
int k;
|
||||
int standby = 80;
|
||||
struct melody *sound = load_sound(RES_PATH "/res/ball.ksf");
|
||||
|
||||
if (!ball)
|
||||
blue_screen("Unable to load ball.bmp");
|
||||
|
||||
player1 = 100;
|
||||
x = 160;
|
||||
y = 100;
|
||||
dx = 2;
|
||||
dy = 2;
|
||||
|
||||
while (1) {
|
||||
t = gettick();
|
||||
|
||||
draw_begin();
|
||||
|
||||
/*
|
||||
* draw screen borders
|
||||
*/
|
||||
|
||||
draw_line(0, 0, 319, 0, 64);
|
||||
draw_line(0, 199, 319, 199, 64);
|
||||
draw_line(0, 1, 319, 1, 192);
|
||||
draw_line(0, 198, 319, 198, 192);
|
||||
|
||||
if (!standby) {
|
||||
/*
|
||||
* player actions.
|
||||
*/
|
||||
|
||||
k = getkey();
|
||||
if (k > 0) {
|
||||
if (k == KEY_DOWN)
|
||||
player1 += 5;
|
||||
if (k == KEY_UP)
|
||||
player1 -= 5;
|
||||
if (k == KEY_ESC)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (player1 + 20 >= 200)
|
||||
player1 = 179;
|
||||
if (player1 - 20 < 0)
|
||||
player1 = 20;
|
||||
|
||||
/*
|
||||
* ball movement.
|
||||
*/
|
||||
|
||||
if (!standby) {
|
||||
x += dx;
|
||||
y += dy;
|
||||
}
|
||||
|
||||
/*
|
||||
* edges.
|
||||
*/
|
||||
|
||||
if (y + 8 >= 200) {
|
||||
y = 191;
|
||||
dy = -dy;
|
||||
playsound(sound, 1);
|
||||
}
|
||||
if (y - 8 < 0) {
|
||||
y = 8;
|
||||
dy = -dy;
|
||||
playsound(sound, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* computer player bar.
|
||||
*/
|
||||
|
||||
player2 = y;
|
||||
if (player2 + 20 >= 200)
|
||||
player2 = 179;
|
||||
if (player2 - 20 < 0)
|
||||
player2 = 20;
|
||||
|
||||
if (standby) {
|
||||
draw_text("Ready ?", 130, 96, RED, 0);
|
||||
standby--;
|
||||
}
|
||||
|
||||
/*
|
||||
* draw players.
|
||||
*/
|
||||
|
||||
draw_fillrect(0, player1 - 20, 10, player1 + 20, 71, 71);
|
||||
draw_fillrect(309, player2 - 20, 319, player2 + 20, 23, 23);
|
||||
|
||||
if (!standby)
|
||||
draw_image(ball, x - 8, y - 8);
|
||||
|
||||
if (x + 5 >= 309) {
|
||||
dx = -dx;
|
||||
playsound(sound, 1);
|
||||
}
|
||||
if (x - 5 < 10) {
|
||||
/*
|
||||
* player bar collision test.
|
||||
*/
|
||||
|
||||
if (player1 - 20 < y + 3 && player1 + 20 > y - 3) {
|
||||
dx = -dx;
|
||||
playsound(sound, 1);
|
||||
} else {
|
||||
draw_text("You loose...", 112, 96, RED, 0);
|
||||
draw_end();
|
||||
while (gettick() - t < 1000) ;
|
||||
player1 = 100;
|
||||
x = 160;
|
||||
y = 100;
|
||||
dx = 3;
|
||||
dy = 3;
|
||||
standby = 80;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
draw_end();
|
||||
|
||||
/*
|
||||
* 33 ms sync between each frame.
|
||||
*/
|
||||
|
||||
while (gettick() - t <= 33) ;
|
||||
}
|
||||
|
||||
clear_sound(sound);
|
||||
clear_image(ball);
|
||||
}
|
||||
|
||||
/*
|
||||
* game entry point.
|
||||
*/
|
||||
|
||||
void entry(void)
|
||||
{
|
||||
#if 0
|
||||
unsigned long t;
|
||||
|
||||
printf
|
||||
("\n\n\n\t== La demonstration qui suit a ete realisee sans trucages ==\n\n\n\n\n");
|
||||
|
||||
t = gettick();
|
||||
while (gettick() - t < 7000) ;
|
||||
#endif
|
||||
|
||||
switch_graphic();
|
||||
|
||||
while (1) {
|
||||
splash_screen();
|
||||
game_loop();
|
||||
}
|
||||
|
||||
/*
|
||||
* we should never arrive here...
|
||||
*/
|
||||
|
||||
switch_text();
|
||||
}
|
||||
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 24 KiB |
@@ -0,0 +1 @@
|
||||
* choute_f (Fabien Chouteau)
|
||||
@@ -0,0 +1,38 @@
|
||||
#
|
||||
# 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 = vaders
|
||||
OBJS = vaders.o
|
||||
ROM_TITLE = "vaders"
|
||||
ROM_FILES = \
|
||||
res/ball.bmp \
|
||||
res/ball.csf \
|
||||
res/chef_big.bmp \
|
||||
res/chef.bmp \
|
||||
res/chiche_b.bmp \
|
||||
res/chiche.bmp \
|
||||
res/intro.csf \
|
||||
res/seine_w.bmp \
|
||||
|
||||
include ../roms.mk
|
||||
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 7.0 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 7.0 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
@@ -0,0 +1,370 @@
|
||||
/*
|
||||
* 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 <graphic.h>
|
||||
#include <sound.h>
|
||||
|
||||
struct monster {
|
||||
int x;
|
||||
int y;
|
||||
int alive;
|
||||
};
|
||||
|
||||
/*
|
||||
* the splash screen with sexy chiche's face.
|
||||
*/
|
||||
|
||||
static int splash_screen(void)
|
||||
{
|
||||
unsigned long t;
|
||||
struct image *imgchiche = load_image(RES_PATH "/res/chiche_b.bmp");
|
||||
struct image *imgchef = load_image(RES_PATH "/res/chef_big.bmp");
|
||||
int blink = 0;
|
||||
struct melody *intro = load_sound(RES_PATH "/res/intro.csf");
|
||||
int sel = 1;
|
||||
int k = 0;
|
||||
|
||||
playsound(intro, -1);
|
||||
|
||||
if (!imgchef || !imgchiche)
|
||||
blue_screen("Unable to load chiche.bmp");
|
||||
|
||||
while (k != KEY_ENTER) {
|
||||
|
||||
k = getkey();
|
||||
if (k == KEY_UP)
|
||||
sel = 1;
|
||||
|
||||
if (k == KEY_DOWN)
|
||||
sel = 0;
|
||||
|
||||
draw_begin();
|
||||
draw_image(imgchiche, 5, 10);
|
||||
draw_image(imgchef, 5, 100);
|
||||
draw_text(" ChicheVaders ", 160, 50, RED, 0);
|
||||
if (blink >= 5)
|
||||
draw_text("Any key to start", 160, 90, WHITE, 0);
|
||||
draw_text("Monde de Merde 2008", 5, 190, BLUE, 0);
|
||||
|
||||
if (sel)
|
||||
draw_text("<==", 80, 40, BLUE, 0);
|
||||
else
|
||||
draw_text("<==", 80, 130, BLUE, 0);
|
||||
|
||||
draw_end();
|
||||
|
||||
/*
|
||||
* 66 ms frame sync
|
||||
*/
|
||||
|
||||
blink = (blink + 1) % 10;
|
||||
t = gettick();
|
||||
while (gettick() - t < 66) ;
|
||||
}
|
||||
|
||||
playsound(NULL, -1);
|
||||
|
||||
clear_sound(intro);
|
||||
clear_image(imgchef);
|
||||
clear_image(imgchiche);
|
||||
return sel;
|
||||
}
|
||||
|
||||
#define WIDTH 320
|
||||
|
||||
#define MONSTERS_COLS 6
|
||||
#define NB_MONSTERS 1 //24
|
||||
#define X_INIT_MONSTERS 10
|
||||
#define X_GAP_MONSTERS 25
|
||||
#define MONSTER_X_BBOX 20
|
||||
#define MONSTER_Y_BBOX 24
|
||||
|
||||
#define SEINE_W_X_BBOX 20
|
||||
#define SEINE_W_Y_BBOX 24
|
||||
|
||||
#define P_SIZE 15
|
||||
#define NUM_MOVE 10
|
||||
/*
|
||||
* game loop.
|
||||
*/
|
||||
|
||||
static void game_loop(struct image * img)
|
||||
{
|
||||
unsigned long t;
|
||||
int p;
|
||||
int w, dw;
|
||||
int wx, wy;
|
||||
int k;
|
||||
int x, y;
|
||||
int dx, dy;
|
||||
int mdx, mdy, mcnt;
|
||||
struct monster monsters[NB_MONSTERS];
|
||||
int ym = X_INIT_MONSTERS;
|
||||
int i = 0;
|
||||
int good = 0;
|
||||
int standby = 0;
|
||||
int fin = 0;
|
||||
int win = 0;
|
||||
int dead_monsters = 0;
|
||||
int kill_seine_w = 0;
|
||||
struct image *imgw = load_image(RES_PATH "/res/seine_w.bmp");
|
||||
struct melody *sound = load_sound(RES_PATH "/res/ball.csf");
|
||||
|
||||
if (!img)
|
||||
blue_screen("Unable to load chiche.bmp");
|
||||
|
||||
p = 160;
|
||||
w = 2;
|
||||
dw = 2;
|
||||
wx = -1;
|
||||
wy = -1;
|
||||
x = -1;
|
||||
y = -1;
|
||||
dx = 0;
|
||||
dy = -5;
|
||||
mdx = 1;
|
||||
mdy = 2;
|
||||
mcnt = 0;
|
||||
|
||||
/*
|
||||
* init monsters.
|
||||
*/
|
||||
for (i = 0; i < NB_MONSTERS; i++) {
|
||||
if (i % MONSTERS_COLS == 0)
|
||||
ym += X_GAP_MONSTERS;
|
||||
monsters[i].y = ym;
|
||||
monsters[i].x =
|
||||
15 + (i % MONSTERS_COLS) * (WIDTH / MONSTERS_COLS);
|
||||
monsters[i].alive = 1;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
t = gettick();
|
||||
|
||||
draw_begin();
|
||||
|
||||
k = getkey();
|
||||
if (k > 0) {
|
||||
if (k == KEY_ESC)
|
||||
standby = !standby;
|
||||
|
||||
if ((standby || fin) && k == KEY_ENTER)
|
||||
return;
|
||||
|
||||
if (!standby && !fin) {
|
||||
if (k == KEY_LEFT && p > (P_SIZE / 2 + 5))
|
||||
p -= 5;
|
||||
if (k == KEY_RIGHT
|
||||
&& p < (WIDTH - (P_SIZE / 2 + 5)))
|
||||
p += 5;
|
||||
|
||||
if ((k == KEY_SPACE) && x == -1 && y == -1) {
|
||||
x = p;
|
||||
y = 200 - (P_SIZE / 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* move and draw seine_w.
|
||||
*/
|
||||
if (!standby && !fin) {
|
||||
if (w >= 319 - MONSTER_X_BBOX || w <= 1)
|
||||
dw = -dw;
|
||||
w += dw;
|
||||
draw_image(imgw, w, 2);
|
||||
}
|
||||
|
||||
/*
|
||||
* draw, move and inpact seine_w bullet.
|
||||
*/
|
||||
if (wx != -1 || wy != -1) {
|
||||
if (!standby && !fin) {
|
||||
wx += dx;
|
||||
wy -= dy;
|
||||
|
||||
if (wx >= (p - (P_SIZE / 2))
|
||||
&& wx <= (p + (P_SIZE / 2))
|
||||
&& wy >= (198 - (P_SIZE / 2))) {
|
||||
playsound(sound, 1);
|
||||
fin = 1;
|
||||
win = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (wy >= 200) {
|
||||
wx = -1;
|
||||
wy = -1;
|
||||
} else
|
||||
draw_line(wx, wy, wx, wy + 2, RED);
|
||||
} else if (w >= (p - (P_SIZE / 2)) && w <= (p + (P_SIZE / 2))) {
|
||||
wx = w;
|
||||
wy = SEINE_W_Y_BBOX;
|
||||
}
|
||||
|
||||
/*
|
||||
* move and draw monsters.
|
||||
*/
|
||||
for (i = 0; i < NB_MONSTERS; i++) {
|
||||
if (i % MONSTERS_COLS == 0)
|
||||
mdx = -mdx;
|
||||
|
||||
if (monsters[i].alive) {
|
||||
if (!standby && !fin) {
|
||||
if (mcnt == NUM_MOVE)
|
||||
monsters[i].y += mdy;
|
||||
monsters[i].x += mdx;
|
||||
|
||||
if (monsters[i].y + MONSTER_Y_BBOX >=
|
||||
200) {
|
||||
fin = 1;
|
||||
win = 0;
|
||||
}
|
||||
}
|
||||
draw_image(img, monsters[i].x, monsters[i].y);
|
||||
}
|
||||
}
|
||||
|
||||
if (++mcnt > NUM_MOVE) {
|
||||
mdx = -mdx;
|
||||
mcnt = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* draw screen borders
|
||||
*/
|
||||
draw_line(0, 0, 319, 0, 64); /* H 1 */
|
||||
draw_line(0, 199, 319, 199, 64); /* H 2 */
|
||||
draw_line(0, 0, 0, 199, 64); /* V 1 */
|
||||
draw_line(319, 0, 319, 199, 64); /* V 2 */
|
||||
|
||||
/*
|
||||
* draw player.
|
||||
*/
|
||||
draw_fillrect(p - (P_SIZE / 2), 198 - (P_SIZE / 2),
|
||||
p + (P_SIZE / 2), 198, WHITE, WHITE);
|
||||
draw_line(p, 198 - P_SIZE, p, 198, WHITE);
|
||||
|
||||
/*
|
||||
* draw, move and inpact bullet.
|
||||
*/
|
||||
if (x != -1 || y != -1) {
|
||||
|
||||
if (!kill_seine_w && x >= w && x <= (w + SEINE_W_X_BBOX)
|
||||
&& y < SEINE_W_Y_BBOX + 20) {
|
||||
draw_line(w, SEINE_W_Y_BBOX + 5,
|
||||
w + SEINE_W_X_BBOX,
|
||||
SEINE_W_Y_BBOX + 5, BLUE);
|
||||
draw_line(w, 0, w, SEINE_W_Y_BBOX + 5, BLUE);
|
||||
draw_line(w + SEINE_W_X_BBOX, 0,
|
||||
w + SEINE_W_X_BBOX,
|
||||
SEINE_W_Y_BBOX + 5, BLUE);
|
||||
}
|
||||
|
||||
good = 0;
|
||||
if (!standby && !fin) {
|
||||
x += dx;
|
||||
y += dy;
|
||||
for (i = 0; i < NB_MONSTERS; i++) {
|
||||
if (monsters[i].alive
|
||||
&& (x >= monsters[i].x
|
||||
&& x <=
|
||||
(monsters[i].x +
|
||||
MONSTER_X_BBOX))
|
||||
&& (y >= monsters[i].y
|
||||
&& y <=
|
||||
(monsters[i].y +
|
||||
MONSTER_Y_BBOX))) {
|
||||
playsound(sound, 1);
|
||||
dead_monsters++;
|
||||
monsters[i].alive = 0;
|
||||
good = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (dead_monsters == NB_MONSTERS)
|
||||
kill_seine_w = 1;
|
||||
|
||||
if (kill_seine_w
|
||||
&& (x >= w && x <= (w + SEINE_W_X_BBOX)
|
||||
&& y <= SEINE_W_Y_BBOX)) {
|
||||
playsound(sound, 1);
|
||||
fin = 1;
|
||||
win = 1;
|
||||
}
|
||||
}
|
||||
if (good || y <= 0) {
|
||||
x = -1;
|
||||
y = -1;
|
||||
} else
|
||||
draw_line(x, y, x, y + 2, WHITE);
|
||||
}
|
||||
|
||||
/*
|
||||
* draw PAUSE.
|
||||
*/
|
||||
if (standby && !fin) {
|
||||
draw_text("PAUSE", 135, 50, WHITE, RED);
|
||||
draw_text("ESC key to continue", 90, 90, WHITE, RED);
|
||||
draw_text("ENTER key to quit", 90, 130, WHITE, RED);
|
||||
}
|
||||
|
||||
/*
|
||||
* draw FIN.
|
||||
*/
|
||||
if (fin) {
|
||||
draw_text(win ? "YOU WIN!" : "YOU LOOSE!", 110, 70,
|
||||
WHITE, RED);
|
||||
draw_text("ENTER key to quit", 90, 130, WHITE, RED);
|
||||
}
|
||||
|
||||
draw_end();
|
||||
/*
|
||||
* 33 ms sync between each frame.
|
||||
*/
|
||||
|
||||
while (gettick() - t <= 33) ;
|
||||
}
|
||||
|
||||
clear_image(img);
|
||||
}
|
||||
|
||||
/*
|
||||
* game entry point.
|
||||
*/
|
||||
|
||||
void entry(void)
|
||||
{
|
||||
switch_graphic();
|
||||
|
||||
while (1) {
|
||||
game_loop(splash_screen()? load_image(RES_PATH "/res/chiche.bmp") :
|
||||
load_image(RES_PATH "/res/chef.bmp"));
|
||||
}
|
||||
/*
|
||||
* we should never arrive here...
|
||||
*/
|
||||
|
||||
switch_text();
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
* grande_n (Nicolas Grandemange)
|
||||
@@ -0,0 +1,43 @@
|
||||
#
|
||||
# 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 = perrod
|
||||
OBJS = perrod.o
|
||||
ROM_TITLE = "perrodlauncher"
|
||||
ROM_FILES = \
|
||||
res/1.bmp \
|
||||
res/2.bmp \
|
||||
res/3.bmp \
|
||||
res/4.bmp \
|
||||
res/5.bmp \
|
||||
res/6.bmp \
|
||||
res/7.bmp \
|
||||
res/8.bmp \
|
||||
res/ball.csf \
|
||||
res/intro.csf \
|
||||
res/nuage.bmp \
|
||||
res/sol.bmp \
|
||||
res/yaka.bmp \
|
||||
|
||||
include ../roms.mk
|
||||
@@ -0,0 +1,300 @@
|
||||
/*
|
||||
* 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 <graphic.h>
|
||||
#include <sound.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/*
|
||||
* the splash screen with yaka face.
|
||||
*/
|
||||
|
||||
static void splash_screen(void)
|
||||
{
|
||||
unsigned long t;
|
||||
struct image *img = load_image(RES_PATH "/res/yaka.bmp");
|
||||
int blink = 0;
|
||||
struct melody *intro = load_sound(RES_PATH "/res/intro.csf");
|
||||
|
||||
playsound(intro, -1);
|
||||
|
||||
if (!img)
|
||||
blue_screen("Unable to load yaka.bmp");
|
||||
|
||||
while (getkey() < 0) {
|
||||
draw_begin();
|
||||
|
||||
draw_image(img, 5, 10);
|
||||
draw_text(" Yaka Launcher ", 160, 50, RED, 0);
|
||||
draw_text("powered by Chiche", 160, 60, ORANGE, 0);
|
||||
if (blink >= 4)
|
||||
draw_text("Any key to start", 160, 90, WHITE, 0);
|
||||
draw_text("Kernel option - LSE - 2007-2008", 5, 190, BLUE, 0);
|
||||
draw_end();
|
||||
|
||||
/*
|
||||
* 66 ms frame sync
|
||||
*/
|
||||
|
||||
blink = (blink + 1) % 8;
|
||||
t = gettick();
|
||||
while (gettick() - t < 250) ;
|
||||
}
|
||||
|
||||
playsound(NULL, -1);
|
||||
|
||||
clear_sound(intro);
|
||||
clear_image(img);
|
||||
}
|
||||
|
||||
/*
|
||||
* game loop.
|
||||
*/
|
||||
|
||||
static void game_loop(void)
|
||||
{
|
||||
unsigned long t;
|
||||
struct image *nuage = load_image(RES_PATH "/res/nuage.bmp");
|
||||
struct image *sol = load_image(RES_PATH "/res/sol.bmp");
|
||||
int angle = 45;
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int dx = 0;
|
||||
int dy = 0;
|
||||
int k;
|
||||
struct melody *sound = load_sound(RES_PATH "/res/ball.csf");
|
||||
struct image *pic[8];
|
||||
int fire = 0;
|
||||
int power = 0;
|
||||
int fx = 0;
|
||||
int fy = 0;
|
||||
unsigned int gravity = 45;
|
||||
int score = 0;
|
||||
char buf[12] = { 0 };
|
||||
|
||||
pic[0] = load_image(RES_PATH "/res/1.bmp");
|
||||
pic[1] = load_image(RES_PATH "/res/2.bmp");
|
||||
pic[2] = load_image(RES_PATH "/res/3.bmp");
|
||||
pic[3] = load_image(RES_PATH "/res/4.bmp");
|
||||
pic[4] = load_image(RES_PATH "/res/5.bmp");
|
||||
pic[5] = load_image(RES_PATH "/res/6.bmp");
|
||||
pic[6] = load_image(RES_PATH "/res/7.bmp");
|
||||
pic[7] = load_image(RES_PATH "/res/8.bmp");
|
||||
int p;
|
||||
for (p = 0; p < 8; p++)
|
||||
if (pic[p] == NULL)
|
||||
blue_screen("Unable to load gif");
|
||||
|
||||
if (!nuage)
|
||||
blue_screen("Unable to load nuage.bmp");
|
||||
if (!sol)
|
||||
blue_screen("Unable to load sol.bmp");
|
||||
|
||||
while (1) {
|
||||
p = p % 16;
|
||||
t = gettick();
|
||||
|
||||
draw_begin();
|
||||
|
||||
/*
|
||||
* player actions.
|
||||
*/
|
||||
|
||||
k = getkey();
|
||||
if (k > 0) {
|
||||
if (k == KEY_RIGHT)
|
||||
angle += 2;
|
||||
if (k == KEY_LEFT)
|
||||
angle -= 2;
|
||||
if (k == KEY_UP)
|
||||
gravity += 1;
|
||||
if (k == KEY_DOWN)
|
||||
gravity -= 1;
|
||||
if (k == KEY_ESC)
|
||||
break;
|
||||
if ((k == KEY_SPACE) && (fire < 3))
|
||||
fire = (fire + 1) % 4;
|
||||
}
|
||||
|
||||
if (angle >= 90)
|
||||
angle = 90;
|
||||
if (angle < 0)
|
||||
angle = 0;
|
||||
if (power >= 90)
|
||||
power = 0;
|
||||
|
||||
/*
|
||||
* ball movement.
|
||||
*/
|
||||
|
||||
if (fire == 0) {
|
||||
power = 0;
|
||||
fx = 0;
|
||||
fy = 0;
|
||||
x = 20 + angle / 2 - fx - 10;
|
||||
y = -angle / 2 + fy + 50;
|
||||
}
|
||||
if (fire == 1)
|
||||
power += 2;
|
||||
if (fire == 2) {
|
||||
fire++;
|
||||
dx = power * (angle);
|
||||
dy = power * (90 - angle);
|
||||
}
|
||||
if (fire == 3) {
|
||||
dy -= gravity * 10;
|
||||
dx -= gravity;
|
||||
if (dx < 0)
|
||||
dx = 0;
|
||||
|
||||
y += dy / 150;
|
||||
if (y < 0)
|
||||
y = 0;
|
||||
x += dx / 200;
|
||||
|
||||
if (y <= 10) {
|
||||
dx -= gravity * 4;
|
||||
if (dx < 0) {
|
||||
fire = 0;
|
||||
score = x;
|
||||
}
|
||||
playsound(sound, 1);
|
||||
dy = -dy;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* computer player bar.
|
||||
*/
|
||||
|
||||
/*
|
||||
* draw players.
|
||||
*/
|
||||
if ((x - 8 - fx) > 200)
|
||||
fx += (x - 8 - fx) - 200;
|
||||
|
||||
while ((190 - y + fy) < 8)
|
||||
fy += 1;
|
||||
while (((190 - y + fy) > 100) && (fy > -10))
|
||||
fy--;
|
||||
|
||||
draw_image(nuage, -(fx % nuage->width),
|
||||
(fy % nuage->height) - nuage->height - 40);
|
||||
draw_image(nuage, -(fx % nuage->width) + nuage->width,
|
||||
(fy % nuage->height) - nuage->height - 40);
|
||||
draw_image(nuage, -(fx % nuage->width) + nuage->width * 2,
|
||||
(fy % nuage->height) - nuage->height - 40);
|
||||
|
||||
draw_image(nuage, -(fx % nuage->width),
|
||||
(fy % nuage->height) - 40);
|
||||
draw_image(nuage, -(fx % nuage->width) + nuage->width,
|
||||
(fy % nuage->height) - 40);
|
||||
draw_image(nuage, -(fx % nuage->width) + nuage->width * 2,
|
||||
(fy % nuage->height) - 40);
|
||||
|
||||
if (fy < 100) {
|
||||
draw_image(sol, -(fx % nuage->width), fy - 40);
|
||||
draw_image(sol, -(fx % nuage->width) + sol->width,
|
||||
fy - 40);
|
||||
draw_image(sol, -(fx % nuage->width) + sol->width * 2,
|
||||
fy - 40);
|
||||
} else {
|
||||
draw_image(nuage, -(fx % nuage->width),
|
||||
(fy % nuage->height) - 40);
|
||||
draw_image(nuage, -(fx % nuage->width) + nuage->width,
|
||||
(fy % nuage->height) - 40);
|
||||
draw_image(nuage,
|
||||
-(fx % nuage->width) + nuage->width * 2,
|
||||
(fy % nuage->height) - 40);
|
||||
}
|
||||
|
||||
//draw_line (0, 199 + fy, 319, 199 + fy, 64);
|
||||
//draw_line (0, 198 + fy, 319, 198 + fy, 192);
|
||||
|
||||
draw_rect(0 - fx, 50 + fy, 10 - fx, 145 + fy, 70);
|
||||
draw_fillrect(0 - fx, 140 - power + fy, 10 - fx, 145 + fy, 60,
|
||||
70);
|
||||
|
||||
draw_rect(15 + angle / 2 - fx, 145 + angle / 2 + fy,
|
||||
20 + angle / 2 - fx, 150 + angle / 2 + fy, 60);
|
||||
draw_line(0 - fx, 200 + fy, 20 + angle / 2 - fx - 2,
|
||||
150 + angle / 2 + fy - 2, 60);
|
||||
|
||||
draw_image_alpha(pic[p / 2], x - 8 - fx, 170 - y + fy, 250);
|
||||
|
||||
draw_text("Gravity: ", 0, 0, 162, -1);
|
||||
sprintf(buf, "%d", gravity);
|
||||
draw_text(buf, 70, 0, 162, -1);
|
||||
|
||||
if ((fire == 0) && (score != 0)) {
|
||||
draw_text("Score: ", 100, 60, 12, -1);
|
||||
sprintf(buf, "%d", score);
|
||||
draw_text(buf, 170, 60, 12, -1);
|
||||
}
|
||||
|
||||
draw_end();
|
||||
|
||||
/*
|
||||
* 33 ms sync between each frame.
|
||||
*/
|
||||
|
||||
while (gettick() - t <= 66) ;
|
||||
p += 1;
|
||||
}
|
||||
|
||||
clear_sound(sound);
|
||||
clear_image(nuage);
|
||||
clear_image(sol);
|
||||
int l = 0;
|
||||
for (l = 0; l < 8; l++)
|
||||
clear_image(pic[l]);
|
||||
}
|
||||
|
||||
/*
|
||||
* game entry point.
|
||||
*/
|
||||
|
||||
void entry(void)
|
||||
{
|
||||
#if 0
|
||||
unsigned long t;
|
||||
|
||||
printf
|
||||
("\n\n\n\t== La demonstration qui suit a ete realisee sans trucages ==\n\n\n\n\n");
|
||||
|
||||
t = gettick();
|
||||
while (gettick() - t < 7000) ;
|
||||
#endif
|
||||
switch_graphic();
|
||||
|
||||
while (1) {
|
||||
splash_screen();
|
||||
game_loop();
|
||||
}
|
||||
|
||||
/*
|
||||
* we should never arrive here...
|
||||
*/
|
||||
|
||||
switch_text();
|
||||
}
|
||||
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 63 KiB |
|
After Width: | Height: | Size: 63 KiB |
|
After Width: | Height: | Size: 24 KiB |
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
OUTPUT_FORMAT("elf32-i386")
|
||||
OUTPUT_ARCH("i386")
|
||||
ENTRY(entry)
|
||||
|
||||
PHDRS
|
||||
{
|
||||
code PT_LOAD;
|
||||
data PT_LOAD;
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
. = 0x4000 + SIZEOF_HEADERS;
|
||||
|
||||
.text :
|
||||
{
|
||||
*(.text) *(.text.*)
|
||||
} : code
|
||||
|
||||
.rodata :
|
||||
{
|
||||
*(.rodata) *(.rodata.*)
|
||||
} : data
|
||||
|
||||
.data :
|
||||
{
|
||||
*(.data) *(.data.*)
|
||||
} : data
|
||||
|
||||
.bss :
|
||||
{
|
||||
*(.bss) *(.bss.*) *(COMMON)
|
||||
} : data
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
include ../../config.mk
|
||||
|
||||
DEPS = $(OBJS:.o=.d)
|
||||
|
||||
MKKFS = ../../tools/mkkfs/mkkfs
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
$(TARGET): CPPFLAGS += -MMD -I ../../k/include -I ../../libs/libc/include -I ../../libs/libk/include -DRES_PATH='"/usr/$(TARGET)/"'
|
||||
$(TARGET): LDFLAGS += -Wl,-T../roms.lds
|
||||
$(TARGET): LDLIBS = -L ../../libs/libk -L ../../libs/libc -lk -lc
|
||||
$(TARGET): $(OBJS)
|
||||
|
||||
install: $(TARGET)
|
||||
$(INSTALL) $(TARGET) $(INSTALL_ROOT)/bin/$(TARGET)
|
||||
for i in $(ROM_FILES); do \
|
||||
$(INSTALL) -m0644 $$i $(INSTALL_ROOT)/usr/$(TARGET)/$$i || exit 1; \
|
||||
done
|
||||
|
||||
clean:
|
||||
$(RM) $(OBJS) $(DEPS) $(TARGET) $(TARGET).rom
|
||||
|
||||
-include $(DEPS)
|
||||
|
||||
.PHONY: install clean all
|
||||
@@ -0,0 +1,2 @@
|
||||
* bucchi_m (Matthieu Bucchianeri)
|
||||
* voltz_r (Renaud Voltz)
|
||||
@@ -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
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
@@ -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();
|
||||
}
|
||||
@@ -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_ */
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
* bucchi_m (Matthieu Bucchianeri)
|
||||
* voltz_r (Renaud Voltz)
|
||||
@@ -0,0 +1,38 @@
|
||||
#
|
||||
# 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 = yakanoid
|
||||
OBJS = yakanoid.o
|
||||
ROM_TITLE = "yakanoid"
|
||||
ROM_FILES = \
|
||||
res/ball.bmp \
|
||||
res/bar.bmp \
|
||||
res/blue.bmp \
|
||||
res/green.bmp \
|
||||
res/red.bmp \
|
||||
res/yaka2008.bmp \
|
||||
res/yaka2009.bmp \
|
||||
res/yaka.bmp \
|
||||
|
||||
include ../roms.mk
|
||||
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 28 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 28 KiB |
@@ -0,0 +1,186 @@
|
||||
/*
|
||||
* 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 <graphic.h>
|
||||
#include <sound.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static void splash_screen(void)
|
||||
{
|
||||
struct image *yaka = load_image(RES_PATH "/res/yaka.bmp");
|
||||
int blink = 0;
|
||||
unsigned long t;
|
||||
|
||||
while (getkey() < 0) {
|
||||
t = gettick();
|
||||
draw_begin();
|
||||
draw_text("YAKANOID", 160 - 4 * 8, 10, 23, 0);
|
||||
//draw_image (yaka, 105, 30); // For YAKA2008
|
||||
draw_image(yaka, 60, 20); // For YAKA2009
|
||||
if (blink > 5)
|
||||
draw_text("Any key to start", 160 - 8 * 8, 170, 184, 0);
|
||||
draw_text("Kernel option - LSE - 2007-2008", 5, 190, 208, 0);
|
||||
draw_end();
|
||||
blink = (blink + 1) % 10;
|
||||
while (gettick() - t < 66) ;
|
||||
}
|
||||
}
|
||||
|
||||
static void game_loop(void)
|
||||
{
|
||||
struct image *brick_blue = load_image(RES_PATH "/res/blue.bmp");
|
||||
struct image *brick_red = load_image(RES_PATH "/res/red.bmp");
|
||||
struct image *brick_green = load_image(RES_PATH "/res/green.bmp");
|
||||
struct image *ball = load_image(RES_PATH "/res/ball.bmp");
|
||||
struct image *bar = load_image(RES_PATH "/res/bar.bmp");
|
||||
struct image *current = brick_blue;
|
||||
int i, line, pos, k;
|
||||
int mtrx[5][10];
|
||||
int x, y, dx, dy;
|
||||
int bx, bx2, by;
|
||||
int score = 0;
|
||||
int lives = 3;
|
||||
unsigned long t;
|
||||
char buf[12] = { 0 };
|
||||
|
||||
for (line = 0; line < 5; line++)
|
||||
for (i = 0; i < 10; i++)
|
||||
mtrx[line][i] = 1;
|
||||
pos = 105;
|
||||
x = 105;
|
||||
y = 180;
|
||||
dx = 1;
|
||||
dy = -1;
|
||||
while (1) {
|
||||
t = gettick();
|
||||
draw_begin();
|
||||
|
||||
draw_line(10, 0, 10, 199, 18);
|
||||
draw_line(210, 0, 210, 199, 18);
|
||||
|
||||
for (line = 0; line < 5; line++) {
|
||||
if (line == 0 || line == 3)
|
||||
current = brick_red;
|
||||
if (line == 1 || line == 4)
|
||||
current = brick_green;
|
||||
if (line == 2)
|
||||
current = brick_blue;
|
||||
for (i = 0; i < 10; i++) {
|
||||
if (mtrx[line][i])
|
||||
draw_image(current, 10 + i * 20, line * 12);
|
||||
}
|
||||
}
|
||||
|
||||
k = getkey();
|
||||
if (k > 0) {
|
||||
if (k == 77)
|
||||
pos += 10;
|
||||
if (k == 75)
|
||||
pos -= 10;
|
||||
if (k == 1)
|
||||
return;
|
||||
if (pos - 25 < 10)
|
||||
pos = 35;
|
||||
if (pos + 25 >= 210)
|
||||
pos = 185;
|
||||
}
|
||||
|
||||
x += dx;
|
||||
y += dy;
|
||||
|
||||
if (x + 5 >= 210)
|
||||
dx = -dx;
|
||||
if (x - 5 < 10)
|
||||
dx = -dx;
|
||||
|
||||
//draw_fillrect (x - 5, y - 5, x + 5, y + 5, 21, 21);
|
||||
draw_image(ball, x - 5, y - 5);
|
||||
//draw_fillrect (pos - 25, 190, pos + 25, 199, 20, 20);
|
||||
draw_image(bar, pos - 25, 190);
|
||||
|
||||
draw_text("score:", 240, 40, 20, 0);
|
||||
sprintf(buf, "%d", score);
|
||||
draw_text(buf, 240, 50, 20, 0);
|
||||
|
||||
draw_text("lives:", 240, 150, 20, 0);
|
||||
sprintf(buf, "%d", lives);
|
||||
draw_text(buf, 240, 160, 20, 0);
|
||||
|
||||
if (y + 5 < 6 * 12) {
|
||||
bx = (x - 5 - 10) / 20;
|
||||
bx2 = (x + 5 - 10) / 20;
|
||||
by = (y - 12) / 12;
|
||||
if (mtrx[by][bx] || mtrx[by][bx2]) {
|
||||
dy = -dy;
|
||||
if (mtrx[by][bx] && mtrx[by][bx2])
|
||||
score += 25;
|
||||
else
|
||||
score += 10;
|
||||
mtrx[by][bx] = mtrx[by][bx2] = 0;
|
||||
}
|
||||
}
|
||||
if (y + 5 >= 190) {
|
||||
if (x + 5 >= pos - 25 && x - 5 <= pos + 25)
|
||||
dy = -dy;
|
||||
else {
|
||||
lives--;
|
||||
if (!lives) {
|
||||
draw_text("GAME OVER", 90, 90, 20, 0);
|
||||
draw_end();
|
||||
for (i = 0; i < 10; i++) {
|
||||
t = gettick();
|
||||
while (gettick() - t < 100)
|
||||
continue;
|
||||
}
|
||||
return;
|
||||
}
|
||||
draw_text("try again !", 90, 90, 20, 0);
|
||||
draw_end();
|
||||
for (i = 0; i < 10; i++) {
|
||||
t = gettick();
|
||||
while (gettick() - t < 100)
|
||||
continue;
|
||||
}
|
||||
pos = 105;
|
||||
x = 105;
|
||||
y = 180;
|
||||
dx = 1;
|
||||
dy = -1;
|
||||
}
|
||||
}
|
||||
|
||||
while (gettick() - t < 8)
|
||||
continue;
|
||||
draw_end();
|
||||
}
|
||||
}
|
||||
|
||||
void entry(void)
|
||||
{
|
||||
switch_graphic();
|
||||
|
||||
while (1) {
|
||||
splash_screen();
|
||||
game_loop();
|
||||
}
|
||||
}
|
||||