2017-09-11 09:54:07 +03:00
|
|
|
|
/*
|
|
|
|
|
THE BUS
|
|
|
|
|
Copyright (C) 2008, 2012, 2017 Leency
|
|
|
|
|
Menu image from Freepik.com
|
|
|
|
|
D O N K E Y
|
|
|
|
|
Copyright (C) 2008 O.Bogomaz
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-17 13:38:19 +03:00
|
|
|
|
#ifndef AUTOBUILD
|
|
|
|
|
#include "lang.h--"
|
|
|
|
|
#endif
|
|
|
|
|
|
2017-09-11 09:54:07 +03:00
|
|
|
|
#define MEMSIZE 1024 * 60;
|
|
|
|
|
|
|
|
|
|
#include "..\lib\kolibri.h"
|
|
|
|
|
#include "..\lib\random.h"
|
|
|
|
|
|
2017-10-05 01:59:57 +03:00
|
|
|
|
#include "..\lib\obj\libio.h"
|
|
|
|
|
#include "..\lib\obj\libimg.h"
|
2017-09-11 09:54:07 +03:00
|
|
|
|
|
|
|
|
|
libimg_image menu;
|
|
|
|
|
libimg_image road;
|
2017-09-14 23:22:54 +03:00
|
|
|
|
libimg_image objects;
|
2017-09-11 09:54:07 +03:00
|
|
|
|
|
2017-09-19 15:21:07 +03:00
|
|
|
|
int frame_timeout = 1;
|
|
|
|
|
|
2017-09-19 17:19:56 +03:00
|
|
|
|
int lifes=0, level=0, score=0;
|
2017-09-17 13:38:19 +03:00
|
|
|
|
int don_x, don_y, don_h, don_w=68, don_type, don_image_y, don_step_y, don_step_y_default=3;
|
|
|
|
|
int don_h_mas[8] = { 36,72,36,74,24,64,48,74 };
|
|
|
|
|
int bus_x, bus_w=42, bus_y, bus_h=88, bus_y_default=290;
|
2017-09-11 09:54:07 +03:00
|
|
|
|
|
|
|
|
|
#define SCR_MENU_MAIN 1
|
|
|
|
|
#define SCR_GAME 2
|
|
|
|
|
#define SCR_PAUSE 3
|
|
|
|
|
|
2017-09-14 23:22:54 +03:00
|
|
|
|
#define RAND -1
|
2017-09-11 09:54:07 +03:00
|
|
|
|
|
2017-09-17 13:38:19 +03:00
|
|
|
|
#define WIN_X 516
|
|
|
|
|
#define WIN_Y 382
|
2017-09-11 09:54:07 +03:00
|
|
|
|
|
|
|
|
|
int screen_type=SCR_MENU_MAIN;
|
|
|
|
|
|
|
|
|
|
#define COLOR_ROAD 0x6D879B;
|
|
|
|
|
|
|
|
|
|
int active_menu_item=0;
|
|
|
|
|
|
2017-09-19 15:21:07 +03:00
|
|
|
|
#ifdef LANG_RUS
|
|
|
|
|
#define THE_BUS_TEXT "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>⪠"
|
|
|
|
|
#define CONTROLS_TEXT "'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>⪠
|
|
|
|
|
<EFBFBD><EFBFBD>ࠢ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<EFBFBD><EFBFBD>ࠢ<EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> P <EFBFBD>⠢<EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'tI"
|
|
|
|
|
#define ABOUT_TEXT "'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>⪠
|
2017-09-19 17:02:04 +03:00
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> v1.01
|
2017-09-19 15:21:07 +03:00
|
|
|
|
|
2017-09-19 17:19:56 +03:00
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD>ࠩ<EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>৪<EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>稪<EFBFBD>,
|
2017-09-19 15:21:07 +03:00
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ᬥ<EFBFBD><EFBFBD>.
|
2019-01-25 00:19:08 +03:00
|
|
|
|
<EFBFBD><EFBFBD> 㦥 <EFBFBD><EFBFBD><EFBFBD><EFBFBD>⨫ <EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD>㦨<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2017-09-19 15:21:07 +03:00
|
|
|
|
<EFBFBD> ⥯<EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>⠭<EFBFBD><EFBFBD><EFBFBD><EFBFBD>!
|
|
|
|
|
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Leency
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD>⨭<EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> Freepik.com'tI"
|
|
|
|
|
#define PAUSE_TEXT "<22><><EFBFBD><EFBFBD><EFBFBD>"
|
|
|
|
|
#define GAME_OVER_TEXT "<22><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>祭<EFBFBD>"
|
|
|
|
|
#define FINAL_SCORE_TEXT "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>"
|
2017-09-19 17:19:56 +03:00
|
|
|
|
#define LIFES_TEXT "<22><><EFBFBD><EFBFBD><EFBFBD>"
|
2017-09-19 15:21:07 +03:00
|
|
|
|
#define LEVEL_TEXT "<22><EFBFBD><E0AEA2><EFBFBD>"
|
|
|
|
|
#define SCORE_TEXT "<22><><EFBFBD><EFBFBD>"
|
|
|
|
|
char *MENU_LIST[]={
|
|
|
|
|
"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>",
|
|
|
|
|
"<EFBFBD><EFBFBD>ࠢ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
|
|
|
|
|
"<EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>",
|
|
|
|
|
"<EFBFBD><EFBFBD>室",
|
|
|
|
|
0};
|
|
|
|
|
#else
|
|
|
|
|
#define THE_BUS_TEXT "THE BUS"
|
|
|
|
|
#define CONTROLS_TEXT "'The Bus
|
|
|
|
|
Control keys:
|
|
|
|
|
Left, Right, Space
|
|
|
|
|
Press P key for pause'tI"
|
|
|
|
|
#define ABOUT_TEXT "'The Bus
|
2017-09-19 17:02:04 +03:00
|
|
|
|
Version v1.01
|
2017-09-19 15:21:07 +03:00
|
|
|
|
Author: Leency
|
|
|
|
|
Menu image from Freepik.com'tI"
|
|
|
|
|
#define PAUSE_TEXT "PAUSE"
|
|
|
|
|
#define GAME_OVER_TEXT "GAME OVER"
|
|
|
|
|
#define FINAL_SCORE_TEXT "Final Score"
|
2017-09-19 17:19:56 +03:00
|
|
|
|
#define LIFES_TEXT "Lifes"
|
2017-09-19 15:21:07 +03:00
|
|
|
|
#define LEVEL_TEXT "Level"
|
|
|
|
|
#define SCORE_TEXT "Score"
|
2017-09-17 13:38:19 +03:00
|
|
|
|
char *MENU_LIST[]={
|
2017-09-11 09:54:07 +03:00
|
|
|
|
"New game",
|
|
|
|
|
"Control keys",
|
|
|
|
|
"About",
|
|
|
|
|
"Exit",
|
|
|
|
|
0};
|
2017-09-19 15:21:07 +03:00
|
|
|
|
#endif
|
2017-09-11 09:54:07 +03:00
|
|
|
|
|
|
|
|
|
|
2017-09-14 23:22:54 +03:00
|
|
|
|
void DrawObstacle(signed int x, y) {
|
2017-09-11 09:54:07 +03:00
|
|
|
|
int don_offset_y;
|
|
|
|
|
int image_h;
|
|
|
|
|
|
2017-09-14 23:22:54 +03:00
|
|
|
|
if (y >= 0) {
|
|
|
|
|
image_h = don_h;
|
|
|
|
|
don_offset_y = don_image_y;
|
2017-09-11 09:54:07 +03:00
|
|
|
|
}
|
|
|
|
|
else {
|
2017-09-14 23:22:54 +03:00
|
|
|
|
image_h = don_h + y;
|
|
|
|
|
don_offset_y = don_image_y - y;
|
2017-09-11 09:54:07 +03:00
|
|
|
|
y = 0;
|
|
|
|
|
}
|
2017-09-19 15:21:07 +03:00
|
|
|
|
DrawBar(x, y-don_step_y, don_w, don_step_y, COLOR_ROAD);
|
|
|
|
|
if (y>0) && (y<don_step_y) DrawBar(x, 0, don_w, y, COLOR_ROAD);
|
2017-09-17 13:38:19 +03:00
|
|
|
|
if (image_h>0) DrawLibImage(objects.image, x, y, don_w, image_h, 0, don_offset_y);
|
2017-09-11 09:54:07 +03:00
|
|
|
|
}
|
2017-09-17 13:38:19 +03:00
|
|
|
|
void DrawBus(dword x, y) { DrawLibImage(objects.image, x, y, bus_w, bus_h, 0, 444); }
|
|
|
|
|
void DrawBoom(dword x, y) { DrawLibImage(objects.image, x, y, 78, 66, 0, 536); }
|
|
|
|
|
void DrawHighway() { DrawLibImage(road.image, 0,0, WIN_X, WIN_Y, 0, 0); }
|
|
|
|
|
void DrawMenuBackground() { DrawLibImage(menu.image, 0, 0, WIN_X, WIN_Y, 0, 0); }
|
2017-09-11 09:54:07 +03:00
|
|
|
|
|
|
|
|
|
void main()
|
|
|
|
|
{
|
|
|
|
|
randomize();
|
2017-09-17 13:38:19 +03:00
|
|
|
|
StartNewGame();
|
2017-09-11 09:54:07 +03:00
|
|
|
|
|
|
|
|
|
load_dll(libio, #libio_init,1);
|
|
|
|
|
load_dll(libimg, #libimg_init,1);
|
2020-05-24 19:46:26 +03:00
|
|
|
|
menu.load(abspath("menu.png"));
|
|
|
|
|
road.load(abspath("road.png"));
|
|
|
|
|
objects.load(abspath("objects.png"));
|
2017-09-11 09:54:07 +03:00
|
|
|
|
|
|
|
|
|
loop()
|
|
|
|
|
{
|
2017-09-19 15:21:07 +03:00
|
|
|
|
WaitEventTimeout(frame_timeout);
|
2017-09-11 09:54:07 +03:00
|
|
|
|
|
|
|
|
|
switch(EAX & 0xFF)
|
|
|
|
|
{
|
|
|
|
|
case evKey:
|
|
|
|
|
GetKeys();
|
|
|
|
|
if (key_scancode == SCAN_CODE_ESC)
|
|
|
|
|
{
|
|
|
|
|
if (screen_type==SCR_GAME) SetScreen(SCR_MENU_MAIN);
|
|
|
|
|
else if (screen_type==SCR_MENU_MAIN) ExitProcess();
|
|
|
|
|
}
|
|
|
|
|
if (key_scancode == SCAN_CODE_DOWN) && (screen_type==SCR_MENU_MAIN)
|
|
|
|
|
{
|
|
|
|
|
if (active_menu_item<>3) active_menu_item++; ELSE active_menu_item=0;
|
|
|
|
|
DrawMenuList();
|
|
|
|
|
}
|
|
|
|
|
if (key_scancode == SCAN_CODE_UP) && (screen_type==SCR_MENU_MAIN)
|
|
|
|
|
{
|
|
|
|
|
if (active_menu_item<>0) active_menu_item--; ELSE active_menu_item=3;
|
|
|
|
|
DrawMenuList();
|
|
|
|
|
}
|
|
|
|
|
if (key_scancode == SCAN_CODE_ENTER) && (screen_type==SCR_MENU_MAIN)
|
|
|
|
|
{
|
|
|
|
|
if (active_menu_item==0)
|
|
|
|
|
{
|
2017-09-17 13:38:19 +03:00
|
|
|
|
StartNewGame();
|
2017-09-11 09:54:07 +03:00
|
|
|
|
SetScreen(SCR_GAME);
|
|
|
|
|
}
|
2017-09-19 15:21:07 +03:00
|
|
|
|
if (active_menu_item==1) notify(CONTROLS_TEXT);
|
|
|
|
|
if (active_menu_item==2) notify(ABOUT_TEXT);
|
2017-09-11 09:54:07 +03:00
|
|
|
|
if (active_menu_item==3) ExitProcess();
|
|
|
|
|
}
|
|
|
|
|
if (key_scancode == SCAN_CODE_SPACE) && (screen_type==SCR_GAME)
|
|
|
|
|
{
|
2017-09-17 13:38:19 +03:00
|
|
|
|
DrawBar(bus_x*80+200, bus_y, bus_w, bus_h+1, COLOR_ROAD);
|
2017-09-11 09:54:07 +03:00
|
|
|
|
if (bus_x==1) bus_x=0; else bus_x=1;
|
|
|
|
|
}
|
|
|
|
|
if (key_scancode == SCAN_CODE_LEFT) && (screen_type==SCR_GAME)
|
|
|
|
|
{
|
|
|
|
|
if (bus_x==0) break;
|
2017-09-17 13:38:19 +03:00
|
|
|
|
DrawBar(bus_x*80+200, bus_y, bus_w, bus_h+1, COLOR_ROAD);
|
2017-09-11 09:54:07 +03:00
|
|
|
|
bus_x=0;
|
|
|
|
|
}
|
|
|
|
|
if (key_scancode == SCAN_CODE_RIGHT) && (screen_type==SCR_GAME)
|
|
|
|
|
{
|
|
|
|
|
if (bus_x==1) break;
|
2017-09-17 13:38:19 +03:00
|
|
|
|
DrawBar(bus_x*80+200, bus_y, bus_w, bus_h+1, COLOR_ROAD);
|
2017-09-11 09:54:07 +03:00
|
|
|
|
bus_x=1;
|
|
|
|
|
}
|
|
|
|
|
if (key_scancode == SCAN_CODE_KEY_P)
|
|
|
|
|
{
|
|
|
|
|
if (screen_type==SCR_MENU_MAIN) break;
|
|
|
|
|
else if (screen_type==SCR_GAME) SetScreen(SCR_PAUSE);
|
|
|
|
|
else if (screen_type==SCR_PAUSE) SetScreen(SCR_GAME);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case evReDraw:
|
2017-09-19 15:21:07 +03:00
|
|
|
|
DefineAndDrawWindow(250,150,WIN_X-1,WIN_Y-1,0x01,0,THE_BUS_TEXT,0); //0x74 is also possible if you fix bottom border
|
2017-09-11 09:54:07 +03:00
|
|
|
|
DrawScreen();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case evButton:
|
|
|
|
|
ExitProcess();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
2017-09-17 13:38:19 +03:00
|
|
|
|
if (screen_type==SCR_GAME)
|
|
|
|
|
{
|
2017-09-19 17:02:04 +03:00
|
|
|
|
if ((don_x == bus_x)&&(don_y + don_h > bus_y )&&(don_y < bus_y + don_h )) {
|
2017-09-19 17:19:56 +03:00
|
|
|
|
lifes--;
|
2017-09-17 13:38:19 +03:00
|
|
|
|
DrawBus(bus_x*80+200,bus_y);
|
2017-09-19 17:02:04 +03:00
|
|
|
|
DrawBoom(bus_x*80+180,bus_y+10);
|
2017-09-17 13:38:19 +03:00
|
|
|
|
pause(150);
|
|
|
|
|
GetNewObstacle(RAND);
|
|
|
|
|
DrawScreen();
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-19 17:19:56 +03:00
|
|
|
|
if (lifes==0) {
|
2017-09-17 13:38:19 +03:00
|
|
|
|
DrawGameOverMessage();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
don_y += don_step_y;
|
|
|
|
|
|
|
|
|
|
if (don_y - don_step_y >= WIN_Y)
|
|
|
|
|
{
|
|
|
|
|
GetNewObstacle(RAND);
|
|
|
|
|
score++;
|
|
|
|
|
bus_y -= don_step_y+1;
|
2017-09-19 15:21:07 +03:00
|
|
|
|
DrawBar(bus_x*80+200, bus_y+bus_h, bus_w, don_step_y+1, COLOR_ROAD);
|
2017-09-17 13:38:19 +03:00
|
|
|
|
WriteScore();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (score) && (score % 15 == 0)
|
|
|
|
|
{
|
|
|
|
|
score++;
|
|
|
|
|
NewLevel();
|
|
|
|
|
DrawScreen();
|
|
|
|
|
don_step_y++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DrawRoad();
|
|
|
|
|
}
|
2017-09-11 09:54:07 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-17 13:38:19 +03:00
|
|
|
|
void NewLevel()
|
|
|
|
|
{
|
|
|
|
|
level++;
|
|
|
|
|
bus_y = bus_y_default;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void StartNewGame()
|
|
|
|
|
{
|
2017-09-19 17:19:56 +03:00
|
|
|
|
lifes=3;
|
2017-09-17 13:38:19 +03:00
|
|
|
|
level=0;
|
|
|
|
|
score=0;
|
|
|
|
|
bus_y = bus_y_default;
|
|
|
|
|
don_step_y = don_step_y_default;
|
|
|
|
|
GetNewObstacle(RAND);
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-11 09:54:07 +03:00
|
|
|
|
void WriteScore() {
|
2017-09-17 13:38:19 +03:00
|
|
|
|
DrawLibImage(road.image, 20, 166, 120, 24, 20, 164);
|
2017-09-19 15:21:07 +03:00
|
|
|
|
WriteText(20, 140, 0x81, 0xFFFFFF, SCORE_TEXT);
|
2017-09-17 13:38:19 +03:00
|
|
|
|
WriteText(20, 166, 0x81, 0xFFFFFF, itoa(score));
|
2017-09-11 09:54:07 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SetScreen(dword _screen_type) {
|
|
|
|
|
screen_type = _screen_type;
|
|
|
|
|
DrawScreen();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DrawScreen()
|
|
|
|
|
{
|
2017-09-14 23:22:54 +03:00
|
|
|
|
int i;
|
2017-09-11 09:54:07 +03:00
|
|
|
|
if (screen_type==SCR_MENU_MAIN)
|
|
|
|
|
{
|
|
|
|
|
DrawMenuBackground();
|
2017-09-19 15:21:07 +03:00
|
|
|
|
WriteTextB(20, 20, 0x83, 0xE8783F, THE_BUS_TEXT);
|
2017-09-11 09:54:07 +03:00
|
|
|
|
DrawMenuList();
|
|
|
|
|
}
|
|
|
|
|
if (screen_type==SCR_GAME) || (screen_type==SCR_PAUSE)
|
|
|
|
|
{
|
|
|
|
|
DrawHighway();
|
2017-09-19 17:19:56 +03:00
|
|
|
|
WriteText(20, 20, 0x81, 0xFFFFFF, LIFES_TEXT);
|
|
|
|
|
WriteText(20, 46, 0x81, 0xFFFFFF, itoa(lifes));
|
2017-09-19 15:21:07 +03:00
|
|
|
|
WriteText(20, 80, 0x81, 0xFFFFFF, LEVEL_TEXT);
|
2017-09-17 13:38:19 +03:00
|
|
|
|
WriteText(20, 106, 0x81, 0xFFFFFF, itoa(level));
|
2017-09-11 09:54:07 +03:00
|
|
|
|
WriteScore();
|
|
|
|
|
DrawRoad();
|
|
|
|
|
if (screen_type==SCR_PAUSE) {
|
2017-09-17 13:38:19 +03:00
|
|
|
|
DrawBar(0,0,140,60,0xFF0000);
|
2017-09-19 15:21:07 +03:00
|
|
|
|
WriteText(10,14,0x83,0xFFFfff,PAUSE_TEXT);
|
2017-09-14 23:22:54 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-09-11 09:54:07 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void DrawMenuList()
|
|
|
|
|
{
|
|
|
|
|
int j;
|
|
|
|
|
for (j=0; j<4; j++) DrawMenuItem(j, j);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DrawMenuItem(int item_n, text_n)
|
|
|
|
|
{
|
|
|
|
|
dword color;
|
|
|
|
|
if (active_menu_item==item_n) color = 0xFF0000; else color = 0xFFffff;
|
2017-09-17 13:38:19 +03:00
|
|
|
|
WriteText(20+2, item_n*56+116+2, 0x81, 0xAAAaaa, MENU_LIST[text_n]);
|
|
|
|
|
WriteText(20, item_n*56+116, 0x81, color, MENU_LIST[text_n]);
|
2017-09-11 09:54:07 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DrawGameOverMessage()
|
|
|
|
|
{
|
2017-09-17 13:38:19 +03:00
|
|
|
|
DrawBar(0, 0, WIN_X, WIN_Y, 0xF3E1BD);
|
2017-09-19 15:21:07 +03:00
|
|
|
|
WriteText(40, 40, 0x81, 0xA48C74, GAME_OVER_TEXT);
|
|
|
|
|
WriteText(40, 75, 0x81, 0xA48C74, FINAL_SCORE_TEXT);
|
2017-09-17 13:38:19 +03:00
|
|
|
|
WriteTextB(40, 140, 0x85, 0xA48C74, itoa(score));
|
2017-09-11 09:54:07 +03:00
|
|
|
|
pause(350);
|
|
|
|
|
active_menu_item=0;
|
2017-09-14 23:22:54 +03:00
|
|
|
|
SetScreen(SCR_MENU_MAIN);
|
2017-09-11 09:54:07 +03:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-14 23:22:54 +03:00
|
|
|
|
void GetNewObstacle(int N)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
don_x = random(2);
|
2017-09-17 13:38:19 +03:00
|
|
|
|
if (N==RAND) don_type = random(7); else don_type = N;
|
2017-09-14 23:22:54 +03:00
|
|
|
|
don_h = don_h_mas[don_type];
|
2017-09-17 13:38:19 +03:00
|
|
|
|
don_y = -don_h;
|
2017-09-14 23:22:54 +03:00
|
|
|
|
don_image_y = 0;
|
2017-09-17 13:38:19 +03:00
|
|
|
|
for (i = 0; i < don_type; i++) don_image_y += don_h_mas[i]+2; //calculate image y offset for current obstacle
|
2017-09-14 23:22:54 +03:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-11 09:54:07 +03:00
|
|
|
|
#define LINE_LENGTH 10
|
2017-09-17 13:38:19 +03:00
|
|
|
|
int line_y=0;
|
|
|
|
|
void DrawLineSeparator()
|
2017-09-11 09:54:07 +03:00
|
|
|
|
{
|
2017-09-17 13:38:19 +03:00
|
|
|
|
int y;
|
|
|
|
|
if (screen_type == SCR_GAME) line_y += don_step_y;
|
2017-09-11 09:54:07 +03:00
|
|
|
|
//the beginning of the white dashed line between two roadways
|
|
|
|
|
if (line_y>=20) {
|
|
|
|
|
line_y=0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2017-09-17 13:38:19 +03:00
|
|
|
|
DrawBar(258, 0, 2, line_y, COLOR_ROAD);
|
|
|
|
|
DrawBar(258, 0, 2, line_y-LINE_LENGTH, 0xDDE9F2);
|
2017-09-11 09:54:07 +03:00
|
|
|
|
}
|
2017-09-14 23:22:54 +03:00
|
|
|
|
for (y=0; y<WIN_Y-20; y+=20) //white dashed line between two roadways
|
2017-09-11 09:54:07 +03:00
|
|
|
|
{
|
2017-09-17 13:38:19 +03:00
|
|
|
|
DrawBar(258, line_y+y, 2, LINE_LENGTH, 0xDDE9F2);
|
|
|
|
|
DrawBar(258, line_y+y+LINE_LENGTH, 2, LINE_LENGTH, COLOR_ROAD);
|
2017-09-11 09:54:07 +03:00
|
|
|
|
}
|
2017-09-17 13:38:19 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DrawRoad()
|
|
|
|
|
{
|
|
|
|
|
DrawLineSeparator();
|
|
|
|
|
DrawObstacle(don_w+10*don_x+186,don_y);
|
|
|
|
|
DrawBus(bus_x*80+200,bus_y);
|
2017-09-11 09:54:07 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
stop:
|