2006-01-23 16:00:06 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
2006-03-03 07:24:34 +00:00
|
|
|
* Copyright (C) 2005, 2006 Ben Basha (Paprica)
|
2009-10-03 08:26:19 +00:00
|
|
|
* Copyright (C) 2009 Karl Kurbjun
|
|
|
|
* check_lines is based off an explanation and expanded math presented by Paul
|
|
|
|
* Bourke: http://local.wasp.uwa.edu.au/~pbourke/geometry/lineline2d/
|
2006-01-23 16:00:06 +00:00
|
|
|
*
|
2008-06-28 18:10:04 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2006-01-23 16:00:06 +00:00
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include "plugin.h"
|
2009-07-18 23:26:50 +00:00
|
|
|
#include "lib/configfile.h"
|
2009-07-14 13:03:17 +00:00
|
|
|
#include "lib/display_text.h"
|
2009-07-18 23:26:50 +00:00
|
|
|
#include "lib/helper.h"
|
|
|
|
#include "lib/highscore.h"
|
|
|
|
#include "lib/playback_control.h"
|
2006-01-23 16:00:06 +00:00
|
|
|
|
2010-02-26 14:36:37 +00:00
|
|
|
#include "pluginbitmaps/brickmania_pads.h"
|
|
|
|
#include "pluginbitmaps/brickmania_short_pads.h"
|
|
|
|
#include "pluginbitmaps/brickmania_long_pads.h"
|
|
|
|
#include "pluginbitmaps/brickmania_bricks.h"
|
|
|
|
#include "pluginbitmaps/brickmania_powerups.h"
|
|
|
|
#include "pluginbitmaps/brickmania_ball.h"
|
|
|
|
#include "pluginbitmaps/brickmania_gameover.h"
|
|
|
|
|
|
|
|
#ifdef HAVE_LCD_COLOR /* currently no transparency for non-colour */
|
|
|
|
#include "pluginbitmaps/brickmania_break.h"
|
|
|
|
#endif
|
|
|
|
|
2010-08-24 14:30:46 +00:00
|
|
|
|
2006-01-23 16:00:06 +00:00
|
|
|
|
2010-02-26 14:36:37 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Keymaps
|
|
|
|
*
|
2009-10-03 08:26:19 +00:00
|
|
|
*/
|
|
|
|
|
2009-07-18 23:26:50 +00:00
|
|
|
#if (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
|
|
|
|
(CONFIG_KEYPAD == IRIVER_H300_PAD)
|
2009-10-04 22:27:42 +00:00
|
|
|
#define CONTINUE_TEXT "Press NAVI To Continue"
|
2006-01-23 16:00:06 +00:00
|
|
|
#define QUIT BUTTON_OFF
|
|
|
|
#define LEFT BUTTON_LEFT
|
|
|
|
#define RIGHT BUTTON_RIGHT
|
|
|
|
#define SELECT BUTTON_SELECT
|
|
|
|
#define UP BUTTON_UP
|
|
|
|
#define DOWN BUTTON_DOWN
|
2006-06-30 16:43:47 +00:00
|
|
|
#define RC_QUIT BUTTON_RC_STOP
|
|
|
|
|
2006-02-22 10:34:36 +00:00
|
|
|
#elif CONFIG_KEYPAD == ONDIO_PAD
|
2009-10-04 22:27:42 +00:00
|
|
|
#define CONTINUE_TEXT "MENU To Continue"
|
2006-02-22 10:34:36 +00:00
|
|
|
#define QUIT BUTTON_OFF
|
|
|
|
#define LEFT BUTTON_LEFT
|
|
|
|
#define RIGHT BUTTON_RIGHT
|
|
|
|
#define SELECT BUTTON_MENU
|
|
|
|
#define UP BUTTON_UP
|
|
|
|
#define DOWN BUTTON_DOWN
|
|
|
|
|
|
|
|
#elif CONFIG_KEYPAD == RECORDER_PAD
|
|
|
|
#define QUIT BUTTON_OFF
|
|
|
|
#define LEFT BUTTON_LEFT
|
|
|
|
#define RIGHT BUTTON_RIGHT
|
|
|
|
#define SELECT BUTTON_PLAY
|
|
|
|
#define UP BUTTON_UP
|
|
|
|
#define DOWN BUTTON_DOWN
|
|
|
|
|
2007-01-14 13:48:09 +00:00
|
|
|
#elif CONFIG_KEYPAD == ARCHOS_AV300_PAD
|
|
|
|
#define QUIT BUTTON_OFF
|
|
|
|
#define LEFT BUTTON_LEFT
|
|
|
|
#define RIGHT BUTTON_RIGHT
|
|
|
|
#define SELECT BUTTON_SELECT
|
|
|
|
#define UP BUTTON_UP
|
|
|
|
#define DOWN BUTTON_DOWN
|
|
|
|
|
2007-07-27 09:57:27 +00:00
|
|
|
#elif (CONFIG_KEYPAD == IPOD_4G_PAD) || \
|
|
|
|
(CONFIG_KEYPAD == IPOD_3G_PAD) || \
|
|
|
|
(CONFIG_KEYPAD == IPOD_1G2G_PAD)
|
2006-01-23 16:00:06 +00:00
|
|
|
#define QUIT BUTTON_MENU
|
|
|
|
#define LEFT BUTTON_LEFT
|
|
|
|
#define RIGHT BUTTON_RIGHT
|
|
|
|
#define SELECT BUTTON_SELECT
|
|
|
|
#define UP BUTTON_SCROLL_BACK
|
|
|
|
#define DOWN BUTTON_SCROLL_FWD
|
2006-01-27 10:02:13 +00:00
|
|
|
#define SCROLL_FWD(x) ((x) & BUTTON_SCROLL_FWD)
|
|
|
|
#define SCROLL_BACK(x) ((x) & BUTTON_SCROLL_BACK)
|
|
|
|
|
2006-02-24 15:42:52 +00:00
|
|
|
#elif (CONFIG_KEYPAD == GIGABEAT_PAD)
|
2007-05-19 23:38:09 +00:00
|
|
|
#define QUIT BUTTON_POWER
|
2006-02-24 15:42:52 +00:00
|
|
|
#define LEFT BUTTON_LEFT
|
|
|
|
#define RIGHT BUTTON_RIGHT
|
|
|
|
#define SELECT BUTTON_SELECT
|
|
|
|
#define UP BUTTON_UP
|
|
|
|
#define DOWN BUTTON_DOWN
|
|
|
|
|
2007-12-30 14:56:51 +00:00
|
|
|
#elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD
|
2006-02-22 10:34:36 +00:00
|
|
|
#define QUIT BUTTON_POWER
|
|
|
|
#define LEFT BUTTON_LEFT
|
|
|
|
#define RIGHT BUTTON_RIGHT
|
|
|
|
#define SELECT BUTTON_PLAY
|
|
|
|
#define UP BUTTON_UP
|
|
|
|
#define DOWN BUTTON_DOWN
|
|
|
|
|
2009-04-10 17:28:26 +00:00
|
|
|
#elif (CONFIG_KEYPAD == SANSA_E200_PAD)
|
2009-07-18 23:26:50 +00:00
|
|
|
#define QUIT BUTTON_POWER
|
|
|
|
#define LEFT BUTTON_LEFT
|
|
|
|
#define RIGHT BUTTON_RIGHT
|
|
|
|
#define SELECT BUTTON_SELECT
|
|
|
|
#define UP BUTTON_UP
|
|
|
|
#define DOWN BUTTON_DOWN
|
2008-01-10 08:08:31 +00:00
|
|
|
#define SCROLL_FWD(x) ((x) & BUTTON_SCROLL_FWD)
|
2009-04-10 17:28:26 +00:00
|
|
|
#define SCROLL_BACK(x) ((x) & BUTTON_SCROLL_BACK)
|
|
|
|
|
|
|
|
|
|
|
|
#elif (CONFIG_KEYPAD == SANSA_FUZE_PAD)
|
|
|
|
#define QUIT (BUTTON_HOME|BUTTON_REPEAT)
|
|
|
|
#define LEFT BUTTON_LEFT
|
|
|
|
#define RIGHT BUTTON_RIGHT
|
|
|
|
#define SELECT BUTTON_SELECT
|
2009-07-18 23:26:50 +00:00
|
|
|
#define UP BUTTON_UP
|
|
|
|
#define DOWN BUTTON_DOWN
|
2009-04-10 17:28:26 +00:00
|
|
|
|
|
|
|
#define SCROLL_FWD(x) ((x) & BUTTON_SCROLL_FWD)
|
2008-01-10 08:08:31 +00:00
|
|
|
#define SCROLL_BACK(x) ((x) & BUTTON_SCROLL_BACK)
|
2008-01-09 21:06:42 +00:00
|
|
|
|
2006-10-26 13:38:09 +00:00
|
|
|
|
2008-12-12 19:50:49 +00:00
|
|
|
#elif CONFIG_KEYPAD == SANSA_C200_PAD || \
|
|
|
|
CONFIG_KEYPAD == SANSA_CLIP_PAD || \
|
|
|
|
CONFIG_KEYPAD == SANSA_M200_PAD
|
2007-12-30 14:56:51 +00:00
|
|
|
#define QUIT BUTTON_POWER
|
|
|
|
#define LEFT BUTTON_LEFT
|
|
|
|
#define RIGHT BUTTON_RIGHT
|
|
|
|
#define ALTLEFT BUTTON_VOL_DOWN
|
|
|
|
#define ALTRIGHT BUTTON_VOL_UP
|
|
|
|
#define SELECT BUTTON_SELECT
|
|
|
|
#define UP BUTTON_UP
|
|
|
|
#define DOWN BUTTON_DOWN
|
|
|
|
|
|
|
|
#elif CONFIG_KEYPAD == IRIVER_H10_PAD
|
2006-08-03 20:17:25 +00:00
|
|
|
#define QUIT BUTTON_POWER
|
|
|
|
#define LEFT BUTTON_LEFT
|
|
|
|
#define RIGHT BUTTON_RIGHT
|
|
|
|
#define SELECT BUTTON_PLAY
|
|
|
|
#define UP BUTTON_SCROLL_UP
|
|
|
|
#define DOWN BUTTON_SCROLL_DOWN
|
|
|
|
|
2008-02-17 12:23:02 +00:00
|
|
|
#elif CONFIG_KEYPAD == GIGABEAT_S_PAD
|
|
|
|
#define QUIT BUTTON_BACK
|
|
|
|
#define LEFT BUTTON_LEFT
|
|
|
|
#define RIGHT BUTTON_RIGHT
|
|
|
|
#define SELECT BUTTON_SELECT
|
|
|
|
#define UP BUTTON_UP
|
|
|
|
#define DOWN BUTTON_DOWN
|
2006-02-22 10:34:36 +00:00
|
|
|
|
2008-03-01 22:55:09 +00:00
|
|
|
#elif (CONFIG_KEYPAD == MROBE100_PAD)
|
|
|
|
#define QUIT BUTTON_POWER
|
|
|
|
#define LEFT BUTTON_LEFT
|
|
|
|
#define RIGHT BUTTON_RIGHT
|
|
|
|
#define SELECT BUTTON_SELECT
|
|
|
|
#define UP BUTTON_UP
|
|
|
|
#define DOWN BUTTON_DOWN
|
|
|
|
|
2008-03-22 10:24:28 +00:00
|
|
|
#elif CONFIG_KEYPAD == IAUDIO_M3_PAD
|
2009-10-04 22:27:42 +00:00
|
|
|
#define CONTINUE_TEXT "PLAY To Continue"
|
2008-03-22 10:24:28 +00:00
|
|
|
#define QUIT BUTTON_RC_REC
|
|
|
|
#define LEFT BUTTON_RC_REW
|
|
|
|
#define RIGHT BUTTON_RC_FF
|
|
|
|
#define SELECT BUTTON_RC_PLAY
|
|
|
|
#define UP BUTTON_RC_VOL_UP
|
|
|
|
#define DOWN BUTTON_RC_VOL_DOWN
|
|
|
|
#define RC_QUIT BUTTON_REC
|
|
|
|
|
2008-12-04 21:28:56 +00:00
|
|
|
#elif CONFIG_KEYPAD == CREATIVEZVM_PAD
|
|
|
|
#define QUIT BUTTON_BACK
|
|
|
|
#define LEFT BUTTON_LEFT
|
|
|
|
#define RIGHT BUTTON_RIGHT
|
|
|
|
#define SELECT BUTTON_SELECT
|
|
|
|
#define UP BUTTON_UP
|
|
|
|
#define DOWN BUTTON_DOWN
|
|
|
|
|
2009-01-24 22:41:55 +00:00
|
|
|
#elif CONFIG_KEYPAD == PHILIPS_HDD1630_PAD
|
|
|
|
#define QUIT BUTTON_POWER
|
|
|
|
#define LEFT BUTTON_LEFT
|
|
|
|
#define RIGHT BUTTON_RIGHT
|
|
|
|
#define SELECT BUTTON_SELECT
|
|
|
|
#define UP BUTTON_UP
|
|
|
|
#define DOWN BUTTON_DOWN
|
|
|
|
|
2010-11-02 23:18:41 +00:00
|
|
|
#elif CONFIG_KEYPAD == PHILIPS_HDD6330_PAD
|
|
|
|
#define QUIT BUTTON_POWER
|
|
|
|
#define LEFT BUTTON_LEFT
|
|
|
|
#define RIGHT BUTTON_RIGHT
|
|
|
|
#define SELECT BUTTON_PLAY
|
|
|
|
#define UP BUTTON_UP
|
|
|
|
#define DOWN BUTTON_DOWN
|
|
|
|
|
2009-12-02 03:19:10 +00:00
|
|
|
#elif CONFIG_KEYPAD == PHILIPS_SA9200_PAD
|
2009-12-02 01:56:39 +00:00
|
|
|
#define QUIT BUTTON_POWER
|
|
|
|
#define LEFT BUTTON_PREV
|
|
|
|
#define RIGHT BUTTON_NEXT
|
|
|
|
#define SELECT BUTTON_PLAY
|
|
|
|
#define UP BUTTON_UP
|
|
|
|
#define DOWN BUTTON_DOWN
|
|
|
|
|
2009-12-15 20:51:41 +00:00
|
|
|
#elif CONFIG_KEYPAD == COWON_D2_PAD
|
2010-02-15 19:52:29 +00:00
|
|
|
#define CONTINUE_TEXT "MENU To Continue"
|
2009-07-18 23:26:50 +00:00
|
|
|
#define QUIT BUTTON_POWER
|
2010-02-07 19:16:21 +00:00
|
|
|
#define LEFT BUTTON_MINUS
|
|
|
|
#define RIGHT BUTTON_PLUS
|
|
|
|
#define SELECT BUTTON_MENU
|
2009-07-18 23:26:50 +00:00
|
|
|
|
2009-04-07 23:41:44 +00:00
|
|
|
#elif CONFIG_KEYPAD == ONDAVX747_PAD
|
|
|
|
#define QUIT BUTTON_POWER
|
|
|
|
#define LEFT BUTTON_VOL_DOWN
|
|
|
|
#define RIGHT BUTTON_VOL_UP
|
|
|
|
#define SELECT BUTTON_MENU
|
2009-08-31 21:11:32 +00:00
|
|
|
#elif CONFIG_KEYPAD == ONDAVX777_PAD
|
|
|
|
#define QUIT BUTTON_POWER
|
2009-04-07 23:41:44 +00:00
|
|
|
|
2009-04-21 04:24:16 +00:00
|
|
|
#elif CONFIG_KEYPAD == MROBE500_PAD
|
|
|
|
#define QUIT BUTTON_POWER
|
|
|
|
|
2009-08-04 03:08:32 +00:00
|
|
|
#elif CONFIG_KEYPAD == SAMSUNG_YH_PAD
|
|
|
|
#define QUIT BUTTON_FFWD
|
|
|
|
#define SELECT BUTTON_PLAY
|
|
|
|
#define LEFT BUTTON_LEFT
|
|
|
|
#define RIGHT BUTTON_RIGHT
|
|
|
|
#define UP BUTTON_UP
|
|
|
|
#define DOWN BUTTON_DOWN
|
|
|
|
|
2010-02-13 15:46:34 +00:00
|
|
|
#elif CONFIG_KEYPAD == PBELL_VIBE500_PAD
|
|
|
|
#define QUIT BUTTON_REC
|
|
|
|
#define LEFT BUTTON_PREV
|
|
|
|
#define RIGHT BUTTON_NEXT
|
|
|
|
#define ALTLEFT BUTTON_MENU
|
|
|
|
#define ALTRIGHT BUTTON_PLAY
|
|
|
|
#define SELECT BUTTON_OK
|
|
|
|
#define UP BUTTON_UP
|
|
|
|
#define DOWN BUTTON_DOWN
|
2009-08-04 03:08:32 +00:00
|
|
|
|
2010-04-26 21:40:00 +00:00
|
|
|
#elif CONFIG_KEYPAD == MPIO_HD200_PAD
|
|
|
|
#define QUIT (BUTTON_REC|BUTTON_PLAY)
|
|
|
|
#define LEFT BUTTON_VOL_DOWN
|
|
|
|
#define RIGHT BUTTON_VOL_UP
|
2010-11-02 10:44:34 +00:00
|
|
|
#define SELECT BUTTON_FUNC
|
|
|
|
#define UP BUTTON_REW
|
|
|
|
#define DOWN BUTTON_FF
|
2010-04-26 21:40:00 +00:00
|
|
|
|
2010-11-30 10:52:14 +00:00
|
|
|
#elif CONFIG_KEYPAD == MPIO_HD300_PAD
|
|
|
|
#define QUIT (BUTTON_REC|BUTTON_REPEAT)
|
|
|
|
#define LEFT BUTTON_REW
|
|
|
|
#define RIGHT BUTTON_FF
|
|
|
|
#define SELECT BUTTON_ENTER
|
|
|
|
#define UP BUTTON_UP
|
|
|
|
#define DOWN BUTTON_DOWN
|
|
|
|
|
2006-01-23 16:00:06 +00:00
|
|
|
#else
|
2008-03-01 22:55:09 +00:00
|
|
|
#error No keymap defined!
|
2006-01-23 16:00:06 +00:00
|
|
|
#endif
|
|
|
|
|
2008-08-23 09:46:38 +00:00
|
|
|
#ifdef HAVE_TOUCHSCREEN
|
2010-02-07 20:19:34 +00:00
|
|
|
#ifdef LEFT
|
|
|
|
#define ALTLEFT BUTTON_BOTTOMLEFT
|
|
|
|
#else
|
|
|
|
#define LEFT BUTTON_BOTTOMLEFT
|
2008-04-27 15:30:19 +00:00
|
|
|
#endif
|
2010-02-07 20:19:34 +00:00
|
|
|
#ifdef RIGHT
|
|
|
|
#define ALTRIGHT BUTTON_BOTTOMRIGHT
|
|
|
|
#else
|
|
|
|
#define RIGHT BUTTON_BOTTOMRIGHT
|
2008-04-27 15:30:19 +00:00
|
|
|
#endif
|
2010-02-07 20:19:34 +00:00
|
|
|
#ifdef SELECT
|
|
|
|
#define ALTSELECT BUTTON_CENTER
|
|
|
|
#else
|
|
|
|
#define SELECT BUTTON_CENTER
|
2008-04-27 15:30:19 +00:00
|
|
|
#endif
|
|
|
|
#ifndef UP
|
2010-02-07 20:19:34 +00:00
|
|
|
#define UP BUTTON_TOPMIDDLE
|
2008-04-27 15:30:19 +00:00
|
|
|
#endif
|
|
|
|
#ifndef DOWN
|
2010-02-07 20:19:34 +00:00
|
|
|
#define DOWN BUTTON_BOTTOMMIDDLE
|
2008-04-27 15:30:19 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2009-10-04 22:27:42 +00:00
|
|
|
/* Continue text is used as a string later when the game is paused. This allows
|
|
|
|
* targets to specify their own text if needed.
|
|
|
|
*/
|
|
|
|
#if !defined(CONTINUE_TEXT)
|
|
|
|
#define CONTINUE_TEXT "Press SELECT To Continue"
|
|
|
|
#endif
|
|
|
|
|
2008-01-09 21:06:42 +00:00
|
|
|
#ifndef SCROLL_FWD /* targets without scroll wheel*/
|
2007-12-30 14:56:51 +00:00
|
|
|
#define SCROLL_FWD(x) (0)
|
|
|
|
#define SCROLL_BACK(x) (0)
|
|
|
|
#endif
|
|
|
|
|
2010-02-26 14:36:37 +00:00
|
|
|
|
2010-04-20 08:46:44 +00:00
|
|
|
#define NUM_BRICKS_ROWS 8
|
|
|
|
#define NUM_BRICKS_COLS 10
|
|
|
|
|
2010-02-26 14:36:37 +00:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Geometric dimensions
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* If there are three fractional bits, the smallest screen size that will scale
|
|
|
|
* properly is 28x22. If you have a smaller screen increase the fractional
|
|
|
|
* precision. If you have a precision of 4 the smallest screen size would be
|
|
|
|
* 14x11. Note though that this will decrease the maximum resolution due to
|
|
|
|
* the line intersection tests. These defines are used for all of the fixed
|
|
|
|
* point calculations/conversions.
|
|
|
|
*/
|
|
|
|
#define FIXED3(x) ((x)<<3)
|
|
|
|
#define FIXED3_MUL(x, y) ((long long)((x)*(y))>>3)
|
|
|
|
#define FIXED3_DIV(x, y) (((x)<<3)/(y))
|
|
|
|
#define INT3(x) ((x)>>3)
|
2007-12-30 14:56:51 +00:00
|
|
|
|
2009-10-03 08:26:19 +00:00
|
|
|
#define GAMESCREEN_WIDTH FIXED3(LCD_WIDTH)
|
|
|
|
#define GAMESCREEN_HEIGHT FIXED3(LCD_HEIGHT)
|
|
|
|
|
|
|
|
#define PAD_WIDTH FIXED3(BMPWIDTH_brickmania_pads)
|
|
|
|
#define PAD_HEIGHT FIXED3(BMPHEIGHT_brickmania_pads/3)
|
|
|
|
#define SHORT_PAD_WIDTH FIXED3(BMPWIDTH_brickmania_short_pads)
|
|
|
|
#define LONG_PAD_WIDTH FIXED3(BMPWIDTH_brickmania_long_pads)
|
|
|
|
#define BRICK_HEIGHT FIXED3(BMPHEIGHT_brickmania_bricks/7)
|
|
|
|
#define BRICK_WIDTH FIXED3(BMPWIDTH_brickmania_bricks)
|
2010-04-20 08:46:44 +00:00
|
|
|
#define LEFTMARGIN ((GAMESCREEN_WIDTH-NUM_BRICKS_COLS*BRICK_WIDTH)/2)
|
2009-10-03 08:26:19 +00:00
|
|
|
#define POWERUP_WIDTH FIXED3(BMPWIDTH_brickmania_powerups)
|
|
|
|
#define BALL FIXED3(BMPHEIGHT_brickmania_ball)
|
|
|
|
#define HALFBALL (BALL / 2)
|
2010-02-26 14:36:37 +00:00
|
|
|
#define PAD_POS_Y (GAMESCREEN_HEIGHT - PAD_HEIGHT - 1)
|
2010-02-16 20:58:59 +00:00
|
|
|
#define ON_PAD_POS_Y (PAD_POS_Y - HALFBALL)
|
2009-10-03 08:26:19 +00:00
|
|
|
|
|
|
|
#define GAMEOVER_WIDTH FIXED3(BMPWIDTH_brickmania_gameover)
|
|
|
|
#define GAMEOVER_HEIGHT FIXED3(BMPHEIGHT_brickmania_gameover)
|
2007-12-30 14:56:51 +00:00
|
|
|
|
2009-10-03 08:26:19 +00:00
|
|
|
#define TOPMARGIN MAX(BRICK_HEIGHT, FIXED3(8))
|
2007-12-30 14:56:51 +00:00
|
|
|
|
2009-08-02 13:45:39 +00:00
|
|
|
#define STRINGPOS_FINISH (GAMESCREEN_HEIGHT - (GAMESCREEN_HEIGHT / 6))
|
|
|
|
#define STRINGPOS_NAVI (STRINGPOS_FINISH - 10)
|
|
|
|
#define STRINGPOS_FLIP (STRINGPOS_FINISH - 10)
|
2007-12-30 14:56:51 +00:00
|
|
|
|
2010-02-26 14:36:37 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Speeds
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2009-09-01 02:07:35 +00:00
|
|
|
/* Brickmania was originally designed for the H300, other targets should scale
|
2009-10-03 08:26:19 +00:00
|
|
|
* the speed up/down as needed based on the screen height.
|
2009-09-01 02:07:35 +00:00
|
|
|
*/
|
2009-10-04 05:29:40 +00:00
|
|
|
#define SPEED_SCALE_H(y) FIXED3_DIV(GAMESCREEN_HEIGHT, FIXED3(176)/(y) )
|
|
|
|
#define SPEED_SCALE_W(x) FIXED3_DIV(GAMESCREEN_WIDTH, FIXED3(220)/(x) )
|
2009-09-01 02:07:35 +00:00
|
|
|
|
|
|
|
/* These are all used as ball speeds depending on where the ball hit the
|
2010-02-19 07:36:56 +00:00
|
|
|
* paddle.
|
2009-10-03 08:26:19 +00:00
|
|
|
*
|
|
|
|
* Note that all of these speeds (including pad, power, and fire)
|
2010-02-19 07:36:56 +00:00
|
|
|
* could be made variable and could be raised to be much higher to add
|
|
|
|
* additional difficulty to the game. The line intersection tests allow this
|
|
|
|
* to be drastically increased without the collision detection failing
|
2009-10-03 08:26:19 +00:00
|
|
|
* (ideally).
|
2009-09-01 02:07:35 +00:00
|
|
|
*/
|
2009-10-03 08:26:19 +00:00
|
|
|
#define SPEED_1Q_X SPEED_SCALE_W( 6)
|
|
|
|
#define SPEED_1Q_Y SPEED_SCALE_H(-2)
|
|
|
|
|
|
|
|
#define SPEED_2Q_X SPEED_SCALE_W( 4)
|
|
|
|
#define SPEED_2Q_Y SPEED_SCALE_H(-3)
|
|
|
|
|
|
|
|
#define SPEED_3Q_X SPEED_SCALE_W( 3)
|
|
|
|
#define SPEED_3Q_Y SPEED_SCALE_H(-4)
|
|
|
|
|
|
|
|
#define SPEED_4Q_X SPEED_SCALE_W( 2)
|
|
|
|
#define SPEED_4Q_Y SPEED_SCALE_H(-4)
|
2009-09-01 02:07:35 +00:00
|
|
|
|
|
|
|
/* This is used to determine the speed of the paddle */
|
2009-10-03 08:26:19 +00:00
|
|
|
#define SPEED_PAD SPEED_SCALE_W( 8)
|
2009-09-01 02:07:35 +00:00
|
|
|
|
2009-09-01 02:40:18 +00:00
|
|
|
/* This defines the speed that the powerups drop */
|
2009-10-03 08:26:19 +00:00
|
|
|
#define SPEED_POWER SPEED_SCALE_H( 2)
|
2009-09-01 02:07:35 +00:00
|
|
|
|
2009-09-01 02:40:18 +00:00
|
|
|
/* This defines the speed that the shot moves */
|
2009-10-03 08:26:19 +00:00
|
|
|
#define SPEED_FIRE SPEED_SCALE_H( 4)
|
|
|
|
#define FIRE_LENGTH SPEED_SCALE_H( 7)
|
2009-09-01 02:07:35 +00:00
|
|
|
|
2007-12-30 14:56:51 +00:00
|
|
|
|
2010-02-26 14:36:37 +00:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Timings
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* The time ms for one iteration through the game loop - decrease this to speed
|
|
|
|
* up the game - note that current_tick is (currently) only accurate to 10ms.
|
|
|
|
*/
|
|
|
|
#define CYCLETIME 30 /* ms */
|
|
|
|
|
|
|
|
#define FLIP_SIDES_DELAY 10 /* seconds */
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Scores
|
|
|
|
*
|
|
|
|
*/
|
2010-02-19 07:32:27 +00:00
|
|
|
|
2010-02-19 12:52:31 +00:00
|
|
|
#define SCORE_BALL_HIT_BRICK 2
|
|
|
|
#define SCORE_BALL_DEMOLISHED_BRICK 8
|
|
|
|
#define SCORE_FIRE_HIT_BRICK 13
|
|
|
|
#define SCORE_LEVEL_COMPLETED 100
|
2010-02-26 14:06:34 +00:00
|
|
|
#define SCORE_POWER_LIFE_GAIN 50
|
|
|
|
#define SCORE_POWER_PADDLE_STICKY 34
|
|
|
|
#define SCORE_POWER_PADDLE_SHOOTER 47
|
|
|
|
#define SCORE_POWER_PADDLE_NORMAL 23
|
2010-02-19 12:52:31 +00:00
|
|
|
#define SCORE_POWER_FLIP 23
|
|
|
|
#define SCORE_POWER_EXTRA_BALL 23
|
|
|
|
#define SCORE_POWER_LONG_PADDLE 23
|
|
|
|
|
2010-02-26 14:36:37 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Limits
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define MAX_BALLS 10
|
|
|
|
#define MAX_FIRES 30
|
|
|
|
#define MAX_POWERS 10
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Files
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define CONFIG_FILE_NAME "brickmania.cfg"
|
2011-03-02 23:43:54 +00:00
|
|
|
#define SAVE_FILE PLUGIN_GAMES_DATA_DIR "/brickmania.save"
|
|
|
|
#define SCORE_FILE PLUGIN_GAMES_DATA_DIR "/brickmania.score"
|
2010-02-27 14:45:37 +00:00
|
|
|
#define NUM_SCORES 5
|
2010-02-26 14:36:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Game levels
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* change to however many levels there are, i.e. how many arrays there are total */
|
|
|
|
#define NUM_LEVELS 40
|
|
|
|
|
2010-02-19 07:28:49 +00:00
|
|
|
/* change the first number in [ ] to however many levels there are */
|
|
|
|
static unsigned char levels[NUM_LEVELS][NUM_BRICKS_ROWS][NUM_BRICKS_COLS] =
|
2009-10-08 19:26:07 +00:00
|
|
|
/* You can set up new levels with the level editor
|
2009-10-09 03:01:16 +00:00
|
|
|
( http://plugbox.rockbox-lounge.com/brickmania.htm ).
|
2009-10-08 19:26:07 +00:00
|
|
|
With 0x1, it refers to the first brick in the bitmap, 0x2 would refer to the
|
|
|
|
second, ect., 0x0 leaves a empty space. If you add a 2 before the 2nd number,
|
|
|
|
it will take two hits to break, and 3 hits if you add a 3. That is 0x24, will
|
|
|
|
result with the fourth brick being displayed and having take 2 hits to break.
|
|
|
|
You could do the same with the 3, just replace the 2 with a 3 for it to take
|
|
|
|
three hits to break it apart. */
|
2009-10-03 08:26:19 +00:00
|
|
|
{
|
2010-02-27 08:02:12 +00:00
|
|
|
{ /* level 1 */
|
2006-01-23 16:00:06 +00:00
|
|
|
{0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1},
|
|
|
|
{0x2,0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0x2},
|
|
|
|
{0x0,0x2,0x1,0x0,0x0,0x0,0x0,0x1,0x2,0x0},
|
|
|
|
{0x0,0x0,0x2,0x1,0x0,0x0,0x1,0x2,0x0,0x0},
|
|
|
|
{0x0,0x0,0x0,0x2,0x1,0x1,0x2,0x0,0x0,0x0},
|
|
|
|
{0x7,0x0,0x0,0x7,0x2,0x2,0x7,0x0,0x0,0x7},
|
|
|
|
{0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0},
|
|
|
|
{0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0}
|
|
|
|
},
|
2010-02-27 08:02:12 +00:00
|
|
|
{ /* level 2 */
|
2006-01-23 16:00:06 +00:00
|
|
|
{0x0,0x0,0x7,0x7,0x1,0x1,0x7,0x7,0x0,0x0},
|
|
|
|
{0x0,0x1,0x0,0x0,0x1,0x1,0x0,0x0,0x1,0x0},
|
|
|
|
{0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1},
|
|
|
|
{0x1,0x1,0x1,0x1,0x0,0x0,0x1,0x1,0x1,0x1},
|
|
|
|
{0x1,0x1,0x2,0x1,0x0,0x0,0x1,0x2,0x1,0x1},
|
|
|
|
{0x1,0x2,0x0,0x2,0x2,0x2,0x2,0x0,0x2,0x1},
|
|
|
|
{0x0,0x1,0x2,0x0,0x0,0x0,0x0,0x2,0x1,0x0},
|
|
|
|
{0x0,0x0,0x1,0x2,0x2,0x2,0x2,0x1,0x0,0x0}
|
|
|
|
},
|
2010-02-27 08:02:12 +00:00
|
|
|
{ /* level 3 */
|
2006-01-23 16:00:06 +00:00
|
|
|
{0x3,0x3,0x3,0x3,0x0,0x0,0x2,0x2,0x2,0x2},
|
2006-01-26 23:31:00 +00:00
|
|
|
{0x3,0x23,0x23,0x3,0x0,0x0,0x2,0x22,0x22,0x2},
|
2006-01-23 16:00:06 +00:00
|
|
|
{0x3,0x3,0x3,0x3,0x0,0x0,0x2,0x2,0x2,0x2},
|
2006-01-26 23:31:00 +00:00
|
|
|
{0x0,0x0,0x0,0x0,0x37,0x37,0x0,0x0,0x0,0x0},
|
|
|
|
{0x0,0x0,0x0,0x0,0x37,0x37,0x0,0x0,0x0,0x0},
|
2006-01-23 16:00:06 +00:00
|
|
|
{0x5,0x5,0x5,0x5,0x0,0x0,0x6,0x6,0x6,0x6},
|
2006-01-26 23:31:00 +00:00
|
|
|
{0x5,0x25,0x25,0x5,0x0,0x0,0x6,0x26,0x26,0x6},
|
2006-01-23 16:00:06 +00:00
|
|
|
{0x5,0x5,0x5,0x5,0x0,0x0,0x6,0x6,0x6,0x6}
|
|
|
|
},
|
2010-02-27 08:02:12 +00:00
|
|
|
{ /* level 4 */
|
2006-01-26 23:31:00 +00:00
|
|
|
{0x0,0x0,0x0,0x27,0x27,0x27,0x27,0x0,0x0,0x0},
|
|
|
|
{0x0,0x0,0x0,0x27,0x7,0x7,0x27,0x0,0x0,0x0},
|
|
|
|
{0x22,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x22},
|
|
|
|
{0x22,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x22},
|
|
|
|
{0x26,0x6,0x0,0x2,0x2,0x2,0x2,0x0,0x6,0x26},
|
2006-01-23 16:00:06 +00:00
|
|
|
{0x0,0x0,0x1,0x1,0x1,0x1,0x1,0x1,0x0,0x0},
|
|
|
|
{0x0,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x0},
|
|
|
|
{0x1,0x1,0x1,0x1,0x0,0x0,0x1,0x1,0x1,0x1}
|
|
|
|
},
|
2010-02-27 08:02:12 +00:00
|
|
|
{ /* level 5 */
|
2006-01-23 16:00:06 +00:00
|
|
|
{0x1,0x0,0x2,0x2,0x0,0x3,0x3,0x0,0x4,0x4},
|
|
|
|
{0x0,0x2,0x2,0x0,0x3,0x3,0x0,0x4,0x4,0x0},
|
|
|
|
{0x2,0x2,0x0,0x3,0x3,0x0,0x4,0x4,0x0,0x5},
|
|
|
|
{0x2,0x0,0x3,0x3,0x0,0x4,0x4,0x0,0x5,0x5},
|
2006-01-26 23:31:00 +00:00
|
|
|
{0x0,0x33,0x3,0x0,0x4,0x4,0x0,0x5,0x5,0x0},
|
|
|
|
{0x3,0x33,0x0,0x4,0x4,0x0,0x5,0x5,0x0,0x36},
|
|
|
|
{0x3,0x0,0x4,0x4,0x0,0x5,0x5,0x0,0x6,0x36},
|
|
|
|
{0x0,0x24,0x24,0x0,0x25,0x25,0x0,0x26,0x26,0x0}
|
2006-01-23 16:00:06 +00:00
|
|
|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7,0x7,0x0},
|
|
|
|
{0x0,0x0,0x0,0x4,0x0,0x0,0x4,0x0,0x0,0x0},
|
2006-01-26 23:31:00 +00:00
|
|
|
{0x6,0x6,0x0,0x2,0x32,0x32,0x2,0x0,0x6,0x6},
|
2006-01-23 16:00:06 +00:00
|
|
|
{0x0,0x0,0x2,0x2,0x2,0x2,0x2,0x2,0x0,0x0},
|
|
|
|
{0x0,0x6,0x6,0x0,0x0,0x0,0x0,0x6,0x6,0x0},
|
2006-01-26 23:31:00 +00:00
|
|
|
{0x0,0x0,0x0,0x5,0x25,0x25,0x5,0x0,0x0,0x0},
|
|
|
|
{0x0,0x5,0x5,0x25,0x5,0x5,0x25,0x5,0x5,0x0},
|
|
|
|
{0x5,0x5,0x25,0x5,0x5,0x5,0x5,0x25,0x5,0x5}
|
2006-01-23 16:00:06 +00:00
|
|
|
},
|
2010-02-27 08:02:12 +00:00
|
|
|
{ /* level 9 */
|
2006-01-23 16:00:06 +00:00
|
|
|
{0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2},
|
|
|
|
{0x2,0x3,0x0,0x0,0x0,0x0,0x0,0x0,0x3,0x2},
|
|
|
|
{0x2,0x0,0x3,0x0,0x1,0x1,0x0,0x3,0x0,0x2},
|
|
|
|
{0x2,0x0,0x0,0x1,0x0,0x0,0x1,0x0,0x0,0x2},
|
|
|
|
{0x2,0x0,0x1,0x0,0x3,0x3,0x0,0x1,0x0,0x2},
|
|
|
|
{0x2,0x0,0x0,0x1,0x0,0x0,0x1,0x0,0x0,0x2},
|
|
|
|
{0x2,0x2,0x0,0x0,0x1,0x1,0x0,0x0,0x2,0x2},
|
|
|
|
{0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2}
|
|
|
|
},
|
2010-02-27 08:02:12 +00:00
|
|
|
{ /* level 10 */
|
2006-01-23 16:00:06 +00:00
|
|
|
{0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0},
|
|
|
|
{0x0,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0x0,0x6,0x0,0x6,0x0,0x6,0x2},
|
|
|
|
{0x2,0x2,0x6,0x0,0x6,0x0,0x6,0x0,0x2,0x2},
|
|
|
|
{0x0,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x0}
|
|
|
|
},
|
|
|
|
{ /* level 22 (Spider) by ts-x */
|
2006-01-26 23:31:00 +00:00
|
|
|
{0x31,0x3,0x1,0x1,0x0,0x0,0x1,0x1,0x3,0x31},
|
2006-01-23 16:00:06 +00:00
|
|
|
{0x0,0x0,0x1,0x1,0x1,0x1,0x1,0x1,0x0,0x0},
|
2006-01-26 23:31:00 +00:00
|
|
|
{0x33,0x1,0x1,0x36,0x1,0x1,0x36,0x1,0x1,0x33},
|
2006-01-23 16:00:06 +00:00
|
|
|
{0x0,0x0,0x1,0x1,0x1,0x1,0x1,0x1,0x0,0x0},
|
|
|
|
{0x0,0x0,0x1,0x1,0x0,0x0,0x1,0x1,0x0,0x0},
|
2006-01-26 23:31:00 +00:00
|
|
|
{0x21,0x3,0x1,0x21,0x2,0x2,0x21,0x1,0x3,0x21},
|
|
|
|
{0x0,0x0,0x0,0x1,0x21,0x1,0x1,0x0,0x0,0x0},
|
2006-01-23 16:00:06 +00:00
|
|
|
{0x3,0x1,0x3,0x1,0x0,0x0,0x1,0x3,0x1,0x3}
|
|
|
|
},
|
|
|
|
{ /* level 23 (Pool) by ts-x */
|
|
|
|
{0x0,0x7,0x7,0x7,0x0,0x7,0x7,0x7,0x7,0x0},
|
|
|
|
{0x0,0x0,0x5,0x0,0x2,0x0,0x0,0x0,0x2,0x0},
|
|
|
|
{0x7,0x3,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x7},
|
|
|
|
{0x7,0x0,0x0,0x0,0x0,0x0,0x0,0x5,0x0,0x7},
|
|
|
|
{0x7,0x0,0x4,0x0,0x0,0x3,0x0,0x0,0x0,0x7},
|
|
|
|
{0x7,0x0,0x0,0x6,0x0,0x0,0x0,0x0,0x4,0x7},
|
|
|
|
{0x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
|
2006-01-23 16:00:06 +00:00
|
|
|
},
|
|
|
|
{ /* level 26 (Bowtie) by ts-x */
|
|
|
|
{0x5,0x1,0x5,0x1,0x0,0x0,0x1,0x5,0x1,0x5},
|
|
|
|
{0x1,0x0,0x0,0x1,0x5,0x5,0x1,0x0,0x0,0x1},
|
|
|
|
{0x5,0x0,0x6,0x0,0x1,0x1,0x0,0x6,0x0,0x5},
|
|
|
|
{0x1,0x0,0x6,0x6,0x0,0x0,0x6,0x6,0x0,0x1},
|
|
|
|
{0x1,0x0,0x6,0x6,0x0,0x0,0x6,0x6,0x0,0x1},
|
|
|
|
{0x5,0x0,0x6,0x0,0x1,0x1,0x0,0x6,0x0,0x5},
|
|
|
|
{0x1,0x0,0x0,0x1,0x5,0x5,0x1,0x0,0x0,0x1},
|
|
|
|
{0x5,0x1,0x5,0x1,0x0,0x0,0x1,0x5,0x1,0x5}
|
|
|
|
},
|
|
|
|
{ /* level 27 (Frog) by ts-x */
|
2006-01-26 23:31:00 +00:00
|
|
|
{0x0,0x5,0x25,0x0,0x0,0x0,0x0,0x25,0x5,0x0},
|
2006-01-23 16:00:06 +00:00
|
|
|
{0x5,0x5,0x5,0x5,0x5,0x5,0x5,0x5,0x5,0x5},
|
2006-01-26 23:31:00 +00:00
|
|
|
{0x25,0x0,0x0,0x5,0x6,0x6,0x5,0x0,0x0,0x25},
|
2006-01-23 16:00:06 +00:00
|
|
|
{0x5,0x0,0x3,0x0,0x6,0x6,0x0,0x3,0x0,0x5},
|
2006-01-26 23:31:00 +00:00
|
|
|
{0x5,0x0,0x31,0x0,0x6,0x6,0x0,0x31,0x0,0x5},
|
2006-01-23 16:00:06 +00:00
|
|
|
{0x5,0x0,0x0,0x5,0x6,0x6,0x5,0x0,0x0,0x5},
|
2006-01-26 23:31:00 +00:00
|
|
|
{0x5,0x5,0x5,0x35,0x0,0x0,0x35,0x5,0x5,0x5},
|
|
|
|
{0x0,0x25,0x5,0x0,0x4,0x4,0x0,0x5,0x25,0x0}
|
2006-01-23 16:00:06 +00:00
|
|
|
},
|
|
|
|
{ /* level 28 (DigDug) by ts-x */
|
2006-01-26 23:31:00 +00:00
|
|
|
{0x35,0x5,0x5,0x25,0x0,0x25,0x25,0x5,0x5,0x35},
|
2006-01-23 16:00:06 +00:00
|
|
|
{0x6,0x0,0x0,0x6,0x0,0x6,0x6,0x0,0x0,0x6},
|
2006-01-26 23:31:00 +00:00
|
|
|
{0x7,0x0,0x37,0x37,0x0,0x37,0x37,0x7,0x0,0x7},
|
2006-01-23 16:00:06 +00:00
|
|
|
{0x7,0x0,0x7,0x0,0x0,0x0,0x7,0x7,0x7,0x7},
|
2006-01-26 23:31:00 +00:00
|
|
|
{0x4,0x4,0x4,0x24,0x0,0x24,0x4,0x0,0x0,0x4},
|
2006-01-23 16:00:06 +00:00
|
|
|
{0x4,0x4,0x0,0x0,0x0,0x4,0x4,0x0,0x4,0x4},
|
2006-01-26 23:31:00 +00:00
|
|
|
{0x24,0x24,0x4,0x4,0x4,0x4,0x0,0x0,0x24,0x4},
|
|
|
|
{0x1,0x1,0x1,0x1,0x1,0x1,0x21,0x21,0x1,0x1}
|
2006-01-23 16:00:06 +00:00
|
|
|
},
|
2009-10-08 19:26:07 +00:00
|
|
|
{ /* level 29 UK Flag by Seth Opgenorth */
|
|
|
|
{0x32,0x0,0x3,0x3,0x2,0x2,0x3,0x3,0x0,0x32},
|
|
|
|
{0x0,0x2,0x0,0x3,0x32,0x22,0x33,0x0,0x32,0x0},
|
|
|
|
{0x33,0x0,0x22,0x0,0x2,0x2,0x0,0x2,0x0,0x33},
|
|
|
|
{0x22,0x32,0x2,0x2,0x2,0x2,0x2,0x2,0x22,0x2},
|
|
|
|
{0x3,0x0,0x0,0x32,0x22,0x2,0x2,0x0,0x0,0x3},
|
|
|
|
{0x23,0x0,0x32,0x0,0x32,0x2,0x0,0x2,0x0,0x3},
|
|
|
|
{0x0,0x2,0x0,0x3,0x2,0x2,0x3,0x0,0x22,0x0},
|
|
|
|
{0x32,0x0,0x3,0x23,0x2,0x2,0x23,0x33,0x0,0x32}
|
|
|
|
},
|
|
|
|
{ /* level 30 Win-Logo by Seth Opgenorth */
|
|
|
|
{0x0,0x0,0x0,0x22,0x0,0x0,0x0,0x0,0x0,0x0},
|
|
|
|
{0x0,0x0,0x32,0x2,0x2,0x25,0x0,0x5,0x0,0x0},
|
|
|
|
{0x0,0x0,0x2,0x22,0x2,0x5,0x5,0x35,0x0,0x0},
|
|
|
|
{0x0,0x0,0x2,0x1,0x2,0x5,0x5,0x25,0x0,0x0},
|
|
|
|
{0x0,0x0,0x21,0x1,0x1,0x36,0x7,0x26,0x0,0x0},
|
|
|
|
{0x0,0x0,0x1,0x1,0x1,0x6,0x6,0x6,0x0,0x0},
|
|
|
|
{0x0,0x0,0x21,0x0,0x21,0x6,0x6,0x26,0x0,0x0},
|
|
|
|
{0x0,0x0,0x0,0x0,0x0,0x0,0x6,0x0,0x0,0x0}
|
|
|
|
},
|
|
|
|
{ /* level 31 Color wave/V by Seth Opgenorth */
|
|
|
|
{0x25,0x34,0x2,0x31,0x33,0x23,0x1,0x2,0x34,0x5},
|
|
|
|
{0x3,0x5,0x24,0x2,0x1,0x1,0x2,0x4,0x5,0x3},
|
|
|
|
{0x1,0x3,0x5,0x4,0x2,0x2,0x4,0x5,0x3,0x1},
|
|
|
|
{0x2,0x1,0x33,0x35,0x4,0x4,0x5,0x33,0x1,0x22},
|
|
|
|
{0x31,0x22,0x1,0x3,0x5,0x25,0x3,0x1,0x2,0x31},
|
|
|
|
{0x3,0x1,0x2,0x1,0x3,0x3,0x1,0x2,0x21,0x3},
|
|
|
|
{0x5,0x23,0x1,0x32,0x1,0x1,0x2,0x1,0x3,0x5},
|
|
|
|
{0x4,0x35,0x3,0x1,0x2,0x22,0x31,0x3,0x5,0x4}
|
|
|
|
},
|
|
|
|
{ /* level 32 Sweedish Flag by Seth Opgenorth */
|
|
|
|
{0x3,0x3,0x3,0x36,0x3,0x3,0x3,0x3,0x3,0x3},
|
|
|
|
{0x3,0x3,0x3,0x36,0x3,0x3,0x3,0x3,0x3,0x3},
|
|
|
|
{0x3,0x3,0x3,0x36,0x3,0x3,0x3,0x3,0x3,0x3},
|
|
|
|
{0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36},
|
|
|
|
{0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36},
|
|
|
|
{0x3,0x3,0x3,0x36,0x3,0x3,0x3,0x3,0x3,0x3},
|
|
|
|
{0x3,0x3,0x3,0x36,0x3,0x3,0x3,0x3,0x3,0x3},
|
|
|
|
{0x3,0x3,0x3,0x36,0x3,0x3,0x3,0x3,0x3,0x3}
|
|
|
|
},
|
|
|
|
{ /* level 33 Color Pyramid by Seth Opgenorth */
|
|
|
|
{0x0,0x0,0x0,0x0,0x2,0x2,0x0,0x0,0x0,0x0},
|
|
|
|
{0x0,0x0,0x0,0x4,0x24,0x4,0x24,0x0,0x0,0x0},
|
|
|
|
{0x0,0x0,0x23,0x3,0x3,0x3,0x23,0x3,0x0,0x0},
|
|
|
|
{0x0,0x0,0x25,0x5,0x25,0x35,0x5,0x35,0x0,0x0},
|
|
|
|
{0x0,0x36,0x6,0x6,0x6,0x6,0x26,0x6,0x6,0x0},
|
|
|
|
{0x0,0x7,0x7,0x7,0x7,0x25,0x27,0x7,0x27,0x0},
|
|
|
|
{0x2,0x2,0x22,0x2,0x2,0x2,0x22,0x2,0x2,0x2},
|
|
|
|
{0x21,0x1,0x1,0x31,0x1,0x21,0x1,0x1,0x31,0x1}
|
|
|
|
},
|
|
|
|
{ /* level 34 Rhombus by Seth Opgenorth */
|
|
|
|
{0x0,0x0,0x0,0x0,0x3,0x33,0x0,0x0,0x0,0x0},
|
|
|
|
{0x0,0x0,0x0,0x3,0x32,0x22,0x23,0x0,0x0,0x0},
|
|
|
|
{0x0,0x0,0x3,0x2,0x24,0x4,0x2,0x23,0x0,0x0},
|
|
|
|
{0x26,0x3,0x2,0x4,0x5,0x5,0x4,0x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0,0x0,0x6,0x6,0x3,0x0},
|
|
|
|
{0x4,0x3,0x4,0x23,0x24,0x3,0x4,0x33,0x4,0x0}
|
|
|
|
},
|
|
|
|
{ /* level 37 It's 8-Bit by Seth Opgenorth */
|
|
|
|
{0x26,0x26,0x6,0x6,0x5,0x6,0x26,0x6,0x26,0x6},
|
|
|
|
{0x2,0x2,0x22,0x3,0x3,0x0,0x0,0x0,0x4,0x0},
|
|
|
|
{0x2,0x0,0x2,0x33,0x3,0x3,0x5,0x0,0x24,0x0},
|
|
|
|
{0x32,0x2,0x2,0x33,0x0,0x23,0x0,0x4,0x4,0x4},
|
|
|
|
{0x2,0x22,0x2,0x3,0x3,0x0,0x5,0x4,0x4,0x24},
|
|
|
|
{0x2,0x0,0x2,0x23,0x0,0x3,0x25,0x0,0x4,0x0},
|
|
|
|
{0x22,0x2,0x2,0x3,0x23,0x0,0x5,0x0,0x4,0x0},
|
|
|
|
{0x6,0x26,0x6,0x36,0x6,0x36,0x6,0x6,0x6,0x6}
|
|
|
|
},
|
|
|
|
{ /* level 38 Linux by Seth Opgenorth */
|
|
|
|
{0x27,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0},
|
|
|
|
{0x7,0x0,0x0,0x0,0x33,0x0,0x23,0x0,0x0,0x0},
|
|
|
|
{0x7,0x32,0x0,0x0,0x3,0x0,0x23,0x6,0x0,0x6},
|
|
|
|
{0x37,0x0,0x0,0x0,0x23,0x0,0x3,0x6,0x0,0x26},
|
|
|
|
{0x7,0x22,0x24,0x0,0x3,0x33,0x3,0x0,0x26,0x0},
|
|
|
|
{0x37,0x22,0x24,0x24,0x4,0x0,0x0,0x0,0x26,0x0},
|
|
|
|
{0x7,0x2,0x4,0x0,0x4,0x0,0x0,0x6,0x0,0x26},
|
|
|
|
{0x7,0x27,0x4,0x0,0x34,0x0,0x0,0x6,0x0,0x26}
|
|
|
|
},
|
|
|
|
{ /* level 39 Colorful Squares by Seth Opgenorth*/
|
|
|
|
{0x0,0x4,0x4,0x4,0x4,0x4,0x4,0x4,0x4,0x0},
|
|
|
|
{0x0,0x4,0x5,0x5,0x5,0x5,0x5,0x5,0x4,0x0},
|
|
|
|
{0x0,0x4,0x5,0x3,0x3,0x3,0x3,0x5,0x4,0x0},
|
|
|
|
{0x0,0x4,0x5,0x3,0x4,0x4,0x3,0x5,0x4,0x0},
|
|
|
|
{0x0,0x4,0x5,0x3,0x4,0x4,0x3,0x5,0x4,0x0},
|
|
|
|
{0x0,0x4,0x5,0x3,0x3,0x3,0x3,0x5,0x4,0x0},
|
|
|
|
{0x0,0x4,0x5,0x5,0x5,0x5,0x5,0x5,0x4,0x0},
|
|
|
|
{0x0,0x4,0x4,0x4,0x4,0x4,0x4,0x4,0x4,0x0}
|
|
|
|
},
|
2006-01-23 16:00:06 +00:00
|
|
|
{ /* TheEnd */
|
|
|
|
{0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0},
|
2009-10-08 19:26:07 +00:00
|
|
|
{0x32,0x32,0x36,0x0,0x0,0x36,0x34,0x34,0x0,0x0},
|
|
|
|
{0x32,0x0,0x36,0x36,0x0,0x36,0x34,0x0,0x34,0x0},
|
|
|
|
{0x32,0x32,0x36,0x36,0x0,0x36,0x34,0x0,0x34,0x0},
|
|
|
|
{0x32,0x32,0x36,0x0,0x36,0x36,0x34,0x0,0x34,0x0},
|
|
|
|
{0x32,0x0,0x36,0x0,0x36,0x36,0x34,0x0,0x34,0x0},
|
|
|
|
{0x32,0x32,0x36,0x0,0x0,0x36,0x34,0x34,0x0,0x0},
|
2006-01-23 16:00:06 +00:00
|
|
|
{0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2010-02-26 14:36:37 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Enums and structs
|
|
|
|
*
|
|
|
|
*/
|
2009-07-18 23:26:50 +00:00
|
|
|
|
2010-02-26 14:06:34 +00:00
|
|
|
enum power_types
|
|
|
|
{
|
|
|
|
POWER_TYPE_LIFE_GAIN = 0,
|
|
|
|
POWER_TYPE_LIFE_LOSS,
|
|
|
|
POWER_TYPE_PADDLE_STICKY,
|
|
|
|
POWER_TYPE_PADDLE_SHOOTER,
|
|
|
|
POWER_TYPE_PADDLE_NORMAL,
|
2010-02-26 14:32:27 +00:00
|
|
|
POWER_TYPE_PADDLE_FLIP,
|
2010-02-26 14:06:34 +00:00
|
|
|
POWER_TYPE_EXTRA_BALL,
|
2010-02-26 14:32:27 +00:00
|
|
|
POWER_TYPE_PADDLE_LONG,
|
|
|
|
POWER_TYPE_PADDLE_SHORT,
|
2010-02-27 09:35:47 +00:00
|
|
|
NUMBER_OF_POWERUPS,
|
2010-02-26 14:06:34 +00:00
|
|
|
};
|
2010-02-26 14:36:37 +00:00
|
|
|
|
2010-02-27 09:35:47 +00:00
|
|
|
#define POWERUP_HEIGHT FIXED3(BMPHEIGHT_brickmania_powerups/NUMBER_OF_POWERUPS)
|
2010-02-26 14:36:37 +00:00
|
|
|
/* Increasing this value makes the game with less powerups */
|
2010-02-27 09:35:47 +00:00
|
|
|
#define POWER_RAND (NUMBER_OF_POWERUPS + 15)
|
2010-02-26 14:06:34 +00:00
|
|
|
|
|
|
|
enum difficulty_options
|
|
|
|
{
|
|
|
|
EASY,
|
|
|
|
NORMAL
|
2009-07-18 23:26:50 +00:00
|
|
|
};
|
|
|
|
|
2010-02-26 14:36:37 +00:00
|
|
|
enum game_state
|
2010-02-26 14:06:34 +00:00
|
|
|
{
|
|
|
|
ST_READY,
|
|
|
|
ST_START,
|
|
|
|
ST_PAUSE
|
2010-02-26 14:36:37 +00:00
|
|
|
};
|
2009-08-28 23:55:44 +00:00
|
|
|
|
2010-02-27 08:02:12 +00:00
|
|
|
enum paddle_type
|
|
|
|
{
|
2010-02-26 14:06:34 +00:00
|
|
|
PADDLE_TYPE_NORMAL = 0,
|
|
|
|
PADDLE_TYPE_STICKY,
|
|
|
|
PADDLE_TYPE_SHOOTER,
|
2010-02-27 08:02:12 +00:00
|
|
|
};
|
2009-08-28 23:55:44 +00:00
|
|
|
|
2010-02-27 18:23:46 +00:00
|
|
|
enum intersection
|
|
|
|
{
|
|
|
|
INTERSECTION_TOP,
|
|
|
|
INTERSECTION_BOTTOM,
|
|
|
|
INTERSECTION_LEFT,
|
|
|
|
INTERSECTION_RIGHT,
|
2010-02-27 18:45:37 +00:00
|
|
|
INTERSECTION_ALL,
|
2010-02-27 18:23:46 +00:00
|
|
|
};
|
|
|
|
|
2010-02-26 14:06:34 +00:00
|
|
|
struct brick
|
2009-10-03 08:26:19 +00:00
|
|
|
{
|
|
|
|
bool used; /* Is the brick still in play? */
|
2006-01-23 16:00:06 +00:00
|
|
|
int color;
|
2009-10-03 08:26:19 +00:00
|
|
|
int hits; /* How many hits can this brick take? */
|
2006-02-01 18:25:24 +00:00
|
|
|
int hiteffect;
|
2010-02-26 14:06:34 +00:00
|
|
|
};
|
2006-01-23 16:00:06 +00:00
|
|
|
|
2010-02-26 14:06:34 +00:00
|
|
|
struct ball
|
2009-10-03 08:26:19 +00:00
|
|
|
{
|
2010-01-02 04:51:32 +00:00
|
|
|
/* pos_x and y store the current center position of the ball */
|
2006-02-15 17:37:45 +00:00
|
|
|
int pos_x;
|
|
|
|
int pos_y;
|
2010-01-02 04:51:32 +00:00
|
|
|
/* tempx and tempy store an absolute position the ball should be in. If
|
2009-10-03 08:26:19 +00:00
|
|
|
* they are equal to 0, they are not used when positioning the ball.
|
|
|
|
*/
|
2006-02-15 17:37:45 +00:00
|
|
|
int tempx;
|
2009-10-03 08:26:19 +00:00
|
|
|
int tempy;
|
2010-01-02 04:51:32 +00:00
|
|
|
/* speedx and speedy store the current speed of the ball */
|
2009-10-03 08:26:19 +00:00
|
|
|
int speedx;
|
|
|
|
int speedy;
|
|
|
|
bool glue; /* Is the ball stuck to the paddle? */
|
2010-02-26 14:06:34 +00:00
|
|
|
};
|
2006-01-23 16:00:06 +00:00
|
|
|
|
2010-02-26 14:06:34 +00:00
|
|
|
struct fire
|
|
|
|
{
|
2009-10-03 08:26:19 +00:00
|
|
|
int top; /* This stores the fire y position, it is a fixed point num */
|
|
|
|
int x_pos; /* This stores the fire x position, it is a whole number */
|
2010-02-26 14:06:34 +00:00
|
|
|
};
|
|
|
|
|
2010-02-27 08:02:12 +00:00
|
|
|
struct power
|
|
|
|
{
|
2010-02-26 14:06:34 +00:00
|
|
|
int top; /* This stores the powerup y position, it is a fixed point num */
|
|
|
|
int x_pos; /* This stores the (middle of) powerup x position, it is a whole number */
|
|
|
|
enum power_types type; /* This stores the powerup type */
|
|
|
|
};
|
2006-01-23 16:00:06 +00:00
|
|
|
|
2010-02-26 14:36:37 +00:00
|
|
|
struct point
|
|
|
|
{
|
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct line
|
|
|
|
{
|
|
|
|
struct point p1;
|
|
|
|
struct point p2;
|
|
|
|
};
|
|
|
|
|
2010-02-27 18:23:46 +00:00
|
|
|
struct rect
|
|
|
|
{
|
|
|
|
struct point top_left;
|
|
|
|
struct point bottom_right;
|
|
|
|
};
|
2010-02-26 14:36:37 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Globals
|
|
|
|
*
|
|
|
|
*/
|
2006-01-23 16:00:06 +00:00
|
|
|
|
2010-04-20 08:16:00 +00:00
|
|
|
static enum game_state game_state;
|
2010-02-27 08:02:12 +00:00
|
|
|
static int pad_pos_x;
|
|
|
|
static int life;
|
2010-04-20 08:16:00 +00:00
|
|
|
static int score,vscore;
|
|
|
|
static bool flip_sides;
|
|
|
|
static int level;
|
|
|
|
static int brick_on_board;
|
|
|
|
static int used_balls;
|
|
|
|
static int used_fires;
|
|
|
|
static int used_powers;
|
2010-02-27 08:02:12 +00:00
|
|
|
static int difficulty = NORMAL;
|
|
|
|
static int pad_width;
|
|
|
|
static int flip_sides_delay;
|
|
|
|
static bool resume = false;
|
|
|
|
static bool resume_file = false;
|
|
|
|
static struct brick brick[NUM_BRICKS_ROWS][NUM_BRICKS_COLS];
|
|
|
|
static struct ball ball[MAX_BALLS];
|
|
|
|
static struct fire fire[MAX_FIRES];
|
|
|
|
static struct power power[MAX_POWERS];
|
|
|
|
static enum paddle_type paddle_type;
|
2010-02-26 14:36:37 +00:00
|
|
|
|
|
|
|
static struct configdata config[] =
|
|
|
|
{
|
2009-08-02 13:45:39 +00:00
|
|
|
{TYPE_INT, 0, 1, { .int_p = &difficulty }, "difficulty", NULL},
|
2006-01-23 16:00:06 +00:00
|
|
|
};
|
|
|
|
|
2010-02-27 14:45:37 +00:00
|
|
|
static struct highscore highscores[NUM_SCORES];
|
2009-07-18 23:26:50 +00:00
|
|
|
|
2009-10-03 08:26:19 +00:00
|
|
|
|
2010-02-26 14:36:37 +00:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Functions
|
|
|
|
*
|
|
|
|
*/
|
2009-10-03 08:26:19 +00:00
|
|
|
|
2010-02-19 07:36:56 +00:00
|
|
|
/*
|
2009-10-03 08:26:19 +00:00
|
|
|
* check_lines:
|
|
|
|
* This is based off an explanation and expanded math presented by Paul Bourke:
|
|
|
|
* http://local.wasp.uwa.edu.au/~pbourke/geometry/lineline2d/
|
|
|
|
*
|
|
|
|
* It takes two lines as inputs and returns 1 if they intersect, 0 if they do
|
2010-02-19 07:36:56 +00:00
|
|
|
* not. hitp returns the point where the two lines intersected.
|
2009-10-03 08:26:19 +00:00
|
|
|
*
|
2010-02-19 07:36:56 +00:00
|
|
|
* This function expects fixed point inputs with a precision of 3. When a
|
2009-10-03 08:26:19 +00:00
|
|
|
* collision occurs hitp is updated with a fixed point location (precision 3)
|
2010-02-19 07:36:56 +00:00
|
|
|
* where the collision happened. The internal calculations are fixed
|
2009-10-03 08:26:19 +00:00
|
|
|
* point with a 7 bit fractional precision.
|
|
|
|
*
|
2010-02-19 07:36:56 +00:00
|
|
|
* If you choose 10 bits of precision a screen size of about 640x480 is the
|
|
|
|
* largest this can go. 7 bits allows for an accurate intersection calculation
|
|
|
|
* with a line length of about 64 and a rougher line lenght of 128 which is
|
|
|
|
* larger than any target currently needs (the pad is the longest line and it
|
|
|
|
* only needs an accuracy of 2^4 at most to figure out which section of the pad
|
|
|
|
* the ball hit). A precision of 7 gives breathing room for larger screens.
|
|
|
|
* Longer line sizes that need accurate intersection points will need more
|
2009-10-03 08:26:19 +00:00
|
|
|
* precision, but will decrease the maximum screen resolution.
|
|
|
|
*/
|
2010-02-19 07:36:56 +00:00
|
|
|
|
2009-10-03 08:26:19 +00:00
|
|
|
#define LINE_PREC 7
|
2010-02-27 08:02:12 +00:00
|
|
|
static int check_lines(struct line *line1, struct line *line2,
|
|
|
|
struct point *hitp)
|
2009-10-03 08:26:19 +00:00
|
|
|
{
|
|
|
|
/* Introduction:
|
|
|
|
* This code is based on the solution of these two input equations:
|
|
|
|
* Pa = P1 + ua (P2-P1)
|
|
|
|
* Pb = P3 + ub (P4-P3)
|
|
|
|
*
|
|
|
|
* Where line one is composed of points P1 and P2 and line two is composed
|
|
|
|
* of points P3 and P4.
|
|
|
|
*
|
|
|
|
* ua/b is the fractional value you can multiply the x and y legs of the
|
|
|
|
* triangle formed by each line to find a point on the line.
|
|
|
|
*
|
|
|
|
* The two equations can be expanded to their x/y components:
|
2010-02-19 07:36:56 +00:00
|
|
|
* Pa.x = p1.x + ua(p2.x - p1.x)
|
|
|
|
* Pa.y = p1.y + ua(p2.y - p1.y)
|
2009-10-03 08:26:19 +00:00
|
|
|
*
|
|
|
|
* Pb.x = p3.x + ub(p4.x - p3.x)
|
|
|
|
* Pb.y = p3.y + ub(p4.y - p3.y)
|
|
|
|
*
|
2010-02-19 07:36:56 +00:00
|
|
|
* When Pa.x == Pb.x and Pa.y == Pb.y the lines intersect so you can come
|
2009-10-03 08:26:19 +00:00
|
|
|
* up with two equations (one for x and one for y):
|
|
|
|
*
|
|
|
|
* p1.x + ua(p2.x - p1.x) = p3.x + ub(p4.x - p3.x)
|
|
|
|
* p1.y + ua(p2.y - p1.y) = p3.y + ub(p4.y - p3.y)
|
|
|
|
*
|
|
|
|
* ua and ub can then be individually solved for. This results in the
|
|
|
|
* equations used in the following code.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Denominator for ua and ub are the same so store this calculation */
|
|
|
|
int d = FIXED3_MUL((line2->p2.y - line2->p1.y),(line1->p2.x-line1->p1.x))
|
|
|
|
-FIXED3_MUL((line2->p2.x - line2->p1.x),(line1->p2.y-line1->p1.y));
|
2010-02-19 07:36:56 +00:00
|
|
|
|
2009-10-03 08:26:19 +00:00
|
|
|
/* n_a and n_b are calculated as seperate values for readability */
|
2010-02-19 07:36:56 +00:00
|
|
|
int n_a = FIXED3_MUL((line2->p2.x - line2->p1.x),(line1->p1.y-line2->p1.y))
|
2009-10-03 08:26:19 +00:00
|
|
|
-FIXED3_MUL((line2->p2.y - line2->p1.y),(line1->p1.x-line2->p1.x));
|
2010-02-19 07:36:56 +00:00
|
|
|
|
2009-10-03 08:26:19 +00:00
|
|
|
int n_b = FIXED3_MUL((line1->p2.x - line1->p1.x),(line1->p1.y-line2->p1.y))
|
|
|
|
-FIXED3_MUL((line1->p2.y - line1->p1.y),(line1->p1.x-line2->p1.x));
|
2010-02-19 07:36:56 +00:00
|
|
|
|
2009-10-03 08:26:19 +00:00
|
|
|
/* Make sure there is not a division by zero - this also indicates that
|
2010-02-19 07:36:56 +00:00
|
|
|
* the lines are parallel.
|
2009-10-03 08:26:19 +00:00
|
|
|
*
|
2010-02-19 07:36:56 +00:00
|
|
|
* If n_a and n_b were both equal to zero the lines would be on top of each
|
|
|
|
* other (coincidental). This check is not done because it is not
|
2009-10-03 08:26:19 +00:00
|
|
|
* necessary for this implementation (the parallel check accounts for this).
|
|
|
|
*/
|
|
|
|
if(d == 0)
|
|
|
|
return 0;
|
2010-02-19 07:36:56 +00:00
|
|
|
|
2009-10-03 08:26:19 +00:00
|
|
|
/* Calculate the intermediate fractional point that the lines potentially
|
|
|
|
* intersect.
|
|
|
|
*/
|
|
|
|
int ua = (n_a << LINE_PREC)/d;
|
|
|
|
int ub = (n_b << LINE_PREC)/d;
|
2010-02-19 07:36:56 +00:00
|
|
|
|
2009-10-03 08:26:19 +00:00
|
|
|
/* The fractional point will be between 0 and 1 inclusive if the lines
|
|
|
|
* intersect. If the fractional calculation is larger than 1 or smaller
|
|
|
|
* than 0 the lines would need to be longer to intersect.
|
|
|
|
*/
|
|
|
|
if(ua >=0 && ua <= (1<<LINE_PREC) && ub >= 0 && ub <= (1<<LINE_PREC))
|
|
|
|
{
|
|
|
|
hitp->x = line1->p1.x + ((ua * (line1->p2.x - line1->p1.x))>>LINE_PREC);
|
|
|
|
hitp->y = line1->p1.y + ((ua * (line1->p2.y - line1->p1.y))>>LINE_PREC);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-02-27 18:23:46 +00:00
|
|
|
|
|
|
|
static int check_rect(struct line *line, struct rect *rect,
|
|
|
|
enum intersection intersection, struct point *hitp)
|
|
|
|
{
|
|
|
|
struct line edge;
|
|
|
|
|
|
|
|
switch (intersection)
|
|
|
|
{
|
|
|
|
case INTERSECTION_TOP:
|
|
|
|
{
|
|
|
|
edge.p1.x = rect->top_left.x;
|
|
|
|
edge.p1.y = rect->top_left.y;
|
|
|
|
|
|
|
|
edge.p2.x = rect->bottom_right.x;
|
|
|
|
edge.p2.y = rect->top_left.y;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case INTERSECTION_BOTTOM:
|
|
|
|
{
|
|
|
|
edge.p1.x = rect->top_left.x;
|
|
|
|
edge.p1.y = rect->bottom_right.y;
|
|
|
|
|
|
|
|
edge.p2.x = rect->bottom_right.x;
|
|
|
|
edge.p2.y = rect->bottom_right.y;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case INTERSECTION_LEFT:
|
|
|
|
{
|
|
|
|
edge.p1.x = rect->top_left.x;
|
|
|
|
edge.p1.y = rect->top_left.y;
|
|
|
|
|
|
|
|
edge.p2.x = rect->top_left.x;
|
|
|
|
edge.p2.y = rect->bottom_right.y;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case INTERSECTION_RIGHT:
|
|
|
|
{
|
|
|
|
edge.p1.x = rect->bottom_right.x;
|
|
|
|
edge.p1.y = rect->top_left.y;
|
|
|
|
|
|
|
|
edge.p2.x = rect->bottom_right.x;
|
|
|
|
edge.p2.y = rect->bottom_right.y;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2010-02-27 18:45:37 +00:00
|
|
|
case INTERSECTION_ALL: /* Test hit on all edges */
|
|
|
|
{
|
|
|
|
return (check_rect(line, rect, INTERSECTION_TOP, hitp) ||
|
|
|
|
check_rect(line, rect, INTERSECTION_BOTTOM, hitp) ||
|
|
|
|
check_rect(line, rect, INTERSECTION_LEFT, hitp) ||
|
|
|
|
check_rect(line, rect, INTERSECTION_RIGHT, hitp));
|
|
|
|
}
|
2010-02-27 18:23:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return check_lines(line, &edge, hitp);
|
|
|
|
}
|
|
|
|
|
2009-10-04 22:27:42 +00:00
|
|
|
static void brickmania_init_game(bool new_game)
|
2006-01-23 16:00:06 +00:00
|
|
|
{
|
|
|
|
int i,j;
|
2006-03-03 07:24:34 +00:00
|
|
|
|
2009-10-03 08:26:19 +00:00
|
|
|
pad_pos_x = GAMESCREEN_WIDTH/2 - PAD_WIDTH/2;
|
|
|
|
|
2010-02-19 07:36:56 +00:00
|
|
|
for(i=0;i<MAX_BALLS;i++)
|
2009-10-03 08:26:19 +00:00
|
|
|
{
|
|
|
|
ball[i].speedx = 0;
|
|
|
|
ball[i].speedy = 0;
|
|
|
|
ball[i].tempy = 0;
|
|
|
|
ball[i].tempx = 0;
|
2010-02-16 20:58:59 +00:00
|
|
|
ball[i].pos_y = ON_PAD_POS_Y;
|
2010-01-02 04:51:32 +00:00
|
|
|
ball[i].pos_x = GAMESCREEN_WIDTH/2;
|
2009-10-03 08:26:19 +00:00
|
|
|
ball[i].glue = false;
|
2006-02-15 17:37:45 +00:00
|
|
|
}
|
2006-03-03 07:24:34 +00:00
|
|
|
|
2009-10-03 08:26:19 +00:00
|
|
|
used_balls = 1;
|
2010-02-19 16:34:18 +00:00
|
|
|
used_fires = 0;
|
2010-02-26 14:06:34 +00:00
|
|
|
used_powers = 0;
|
2009-10-03 08:26:19 +00:00
|
|
|
game_state = ST_READY;
|
2010-02-26 14:06:34 +00:00
|
|
|
paddle_type = PADDLE_TYPE_NORMAL;
|
2009-10-03 08:26:19 +00:00
|
|
|
pad_width = PAD_WIDTH;
|
|
|
|
flip_sides = false;
|
2010-02-19 07:32:27 +00:00
|
|
|
flip_sides_delay = FLIP_SIDES_DELAY;
|
2006-03-03 07:24:34 +00:00
|
|
|
|
2009-10-04 22:27:42 +00:00
|
|
|
if (new_game) {
|
2006-03-03 07:24:34 +00:00
|
|
|
brick_on_board=0;
|
2009-07-18 23:26:50 +00:00
|
|
|
/* add one life per achieved level */
|
|
|
|
if (difficulty==EASY && life<2) {
|
2010-02-19 12:52:31 +00:00
|
|
|
score+=SCORE_LEVEL_COMPLETED;
|
2009-07-18 23:26:50 +00:00
|
|
|
life++;
|
|
|
|
}
|
|
|
|
}
|
2010-02-19 07:36:56 +00:00
|
|
|
|
2010-02-19 07:28:49 +00:00
|
|
|
for(i=0;i<NUM_BRICKS_ROWS;i++) {
|
|
|
|
for(j=0;j<NUM_BRICKS_COLS;j++) {
|
2009-10-04 22:27:42 +00:00
|
|
|
if (new_game) {
|
2010-02-24 20:08:30 +00:00
|
|
|
brick[i][j].hits=levels[level][i][j]>=10?
|
2009-07-18 23:26:50 +00:00
|
|
|
levels[level][i][j]/16-1:0;
|
2010-02-24 20:08:30 +00:00
|
|
|
brick[i][j].hiteffect=0;
|
|
|
|
brick[i][j].used=!(levels[level][i][j]==0);
|
|
|
|
brick[i][j].color=(levels[level][i][j]>=10?
|
2009-07-18 23:26:50 +00:00
|
|
|
levels[level][i][j]%16:
|
|
|
|
levels[level][i][j])-1;
|
|
|
|
if (levels[level][i][j]!=0)
|
2006-03-03 07:24:34 +00:00
|
|
|
brick_on_board++;
|
2006-01-23 16:00:06 +00:00
|
|
|
}
|
2006-03-03 07:24:34 +00:00
|
|
|
}
|
|
|
|
}
|
2006-01-23 16:00:06 +00:00
|
|
|
}
|
|
|
|
|
2009-08-02 13:45:39 +00:00
|
|
|
static void brickmania_loadgame(void)
|
|
|
|
{
|
|
|
|
int fd;
|
|
|
|
|
|
|
|
resume = false;
|
|
|
|
|
|
|
|
/* open game file */
|
|
|
|
fd = rb->open(SAVE_FILE, O_RDONLY);
|
|
|
|
if(fd < 0) return;
|
|
|
|
|
|
|
|
/* read in saved game */
|
2010-02-18 22:01:40 +00:00
|
|
|
if((rb->read(fd, &pad_pos_x, sizeof(pad_pos_x)) <= 0) ||
|
|
|
|
(rb->read(fd, &life, sizeof(life)) <= 0) ||
|
|
|
|
(rb->read(fd, &game_state, sizeof(game_state)) <= 0) ||
|
2010-02-26 14:06:34 +00:00
|
|
|
(rb->read(fd, &paddle_type, sizeof(paddle_type)) <= 0) ||
|
2010-02-18 22:01:40 +00:00
|
|
|
(rb->read(fd, &score, sizeof(score)) <= 0) ||
|
|
|
|
(rb->read(fd, &flip_sides, sizeof(flip_sides)) <= 0) ||
|
|
|
|
(rb->read(fd, &level, sizeof(level)) <= 0) ||
|
|
|
|
(rb->read(fd, &brick_on_board, sizeof(brick_on_board)) <= 0) ||
|
|
|
|
(rb->read(fd, &used_balls, sizeof(used_balls)) <= 0) ||
|
2010-02-19 16:34:18 +00:00
|
|
|
(rb->read(fd, &used_fires, sizeof(used_fires)) <= 0) ||
|
2010-02-26 14:06:34 +00:00
|
|
|
(rb->read(fd, &used_powers, sizeof(used_powers)) <= 0) ||
|
2010-02-18 22:01:40 +00:00
|
|
|
(rb->read(fd, &pad_width, sizeof(pad_width)) <= 0) ||
|
2010-02-19 07:32:27 +00:00
|
|
|
(rb->read(fd, &flip_sides_delay, sizeof(flip_sides_delay)) <= 0) ||
|
2010-02-18 22:01:40 +00:00
|
|
|
(rb->read(fd, &brick, sizeof(brick)) <= 0) ||
|
|
|
|
(rb->read(fd, &ball, sizeof(ball)) <= 0) ||
|
2010-02-26 14:06:34 +00:00
|
|
|
(rb->read(fd, &fire, sizeof(fire)) <= 0) ||
|
|
|
|
(rb->read(fd, &power, sizeof(power)) <= 0))
|
2010-02-18 22:01:40 +00:00
|
|
|
{
|
|
|
|
rb->splash(HZ/2, "Failed to load game");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-08-02 13:45:39 +00:00
|
|
|
vscore = score;
|
|
|
|
resume = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
rb->close(fd);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void brickmania_savegame(void)
|
|
|
|
{
|
|
|
|
int fd;
|
|
|
|
|
|
|
|
/* write out the game state to the save file */
|
2010-05-06 17:35:13 +00:00
|
|
|
fd = rb->open(SAVE_FILE, O_WRONLY|O_CREAT, 0666);
|
2009-12-06 13:52:28 +00:00
|
|
|
if(fd < 0) return;
|
|
|
|
|
2010-02-18 22:01:40 +00:00
|
|
|
if ((rb->write(fd, &pad_pos_x, sizeof(pad_pos_x)) <= 0) ||
|
|
|
|
(rb->write(fd, &life, sizeof(life)) <= 0) ||
|
|
|
|
(rb->write(fd, &game_state, sizeof(game_state)) <= 0) ||
|
2010-02-26 14:06:34 +00:00
|
|
|
(rb->write(fd, &paddle_type, sizeof(paddle_type)) <= 0) ||
|
2010-02-18 22:01:40 +00:00
|
|
|
(rb->write(fd, &score, sizeof(score)) <= 0) ||
|
|
|
|
(rb->write(fd, &flip_sides, sizeof(flip_sides)) <= 0) ||
|
|
|
|
(rb->write(fd, &level, sizeof(level)) <= 0) ||
|
|
|
|
(rb->write(fd, &brick_on_board, sizeof(brick_on_board)) <= 0) ||
|
|
|
|
(rb->write(fd, &used_balls, sizeof(used_balls)) <= 0) ||
|
2010-02-19 16:34:18 +00:00
|
|
|
(rb->write(fd, &used_fires, sizeof(used_fires)) <= 0) ||
|
2010-02-26 14:06:34 +00:00
|
|
|
(rb->write(fd, &used_powers, sizeof(used_powers)) <= 0) ||
|
2010-02-18 22:01:40 +00:00
|
|
|
(rb->write(fd, &pad_width, sizeof(pad_width)) <= 0) ||
|
2010-02-19 07:32:27 +00:00
|
|
|
(rb->write(fd, &flip_sides_delay, sizeof(flip_sides_delay)) <= 0) ||
|
2010-02-18 22:01:40 +00:00
|
|
|
(rb->write(fd, &brick, sizeof(brick)) <= 0) ||
|
|
|
|
(rb->write(fd, &ball, sizeof(ball)) <= 0) ||
|
2010-02-26 14:06:34 +00:00
|
|
|
(rb->write(fd, &fire, sizeof(fire)) <= 0) ||
|
|
|
|
(rb->write(fd, &power, sizeof(power)) <= 0))
|
2010-02-18 22:01:40 +00:00
|
|
|
{
|
|
|
|
rb->close(fd);
|
|
|
|
rb->remove(SAVE_FILE);
|
|
|
|
rb->splash(HZ/2, "Failed to save game");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-08-02 13:45:39 +00:00
|
|
|
rb->close(fd);
|
|
|
|
}
|
2006-01-23 16:00:06 +00:00
|
|
|
|
2009-07-18 23:26:50 +00:00
|
|
|
/* brickmania_sleep timer counting the score */
|
|
|
|
static void brickmania_sleep(int secs)
|
2006-03-03 07:24:34 +00:00
|
|
|
{
|
|
|
|
bool done=false;
|
|
|
|
char s[20];
|
|
|
|
int count=0;
|
2009-08-02 13:45:39 +00:00
|
|
|
int sw, w;
|
2006-03-03 07:24:34 +00:00
|
|
|
|
2010-02-19 07:36:56 +00:00
|
|
|
while (!done)
|
2009-10-05 02:13:13 +00:00
|
|
|
{
|
|
|
|
if (count == 0)
|
|
|
|
count = *rb->current_tick + HZ*secs;
|
2009-10-18 15:50:30 +00:00
|
|
|
if ( (TIME_AFTER(*rb->current_tick, count)) && (vscore == score) )
|
2009-10-05 02:13:13 +00:00
|
|
|
done = true;
|
|
|
|
|
|
|
|
if(vscore != score)
|
|
|
|
{
|
2009-07-18 23:26:50 +00:00
|
|
|
if (vscore<score)
|
|
|
|
vscore++;
|
|
|
|
if (vscore>score)
|
|
|
|
vscore--;
|
2006-03-03 07:24:34 +00:00
|
|
|
rb->snprintf(s, sizeof(s), "%d", vscore);
|
|
|
|
rb->lcd_getstringsize(s, &sw, &w);
|
|
|
|
rb->lcd_putsxy(LCD_WIDTH/2-sw/2, 0, s);
|
|
|
|
rb->lcd_update_rect(0,0,LCD_WIDTH,w+2);
|
2008-06-09 20:59:55 +00:00
|
|
|
}
|
2008-12-13 07:36:44 +00:00
|
|
|
rb->yield();
|
2006-01-23 16:00:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-18 23:26:50 +00:00
|
|
|
static int brickmania_help(void)
|
2006-01-23 16:00:06 +00:00
|
|
|
{
|
2009-07-18 23:26:50 +00:00
|
|
|
static char *help_text[] = {
|
|
|
|
"Brickmania", "", "Aim", "",
|
2009-07-14 13:03:17 +00:00
|
|
|
"Destroy", "all", "the", "bricks", "by", "bouncing",
|
|
|
|
"the", "ball", "of", "them", "using", "the", "paddle.", "", "",
|
|
|
|
"Controls", "",
|
2010-02-07 20:19:34 +00:00
|
|
|
#if CONFIG_KEYPAD == COWON_D2_PAD
|
|
|
|
"- & +:",
|
|
|
|
#else
|
|
|
|
"< & >:",
|
|
|
|
#endif
|
|
|
|
"Moves", "the", "paddle", "",
|
2006-02-22 10:34:36 +00:00
|
|
|
#if CONFIG_KEYPAD == ONDIO_PAD
|
2009-07-18 23:26:50 +00:00
|
|
|
"MENU:",
|
2009-12-02 03:12:14 +00:00
|
|
|
#elif (CONFIG_KEYPAD == RECORDER_PAD) || (CONFIG_KEYPAD == IAUDIO_M3_PAD)
|
2009-07-18 23:26:50 +00:00
|
|
|
"PLAY:",
|
2006-02-22 10:34:36 +00:00
|
|
|
#elif CONFIG_KEYPAD == IRIVER_H300_PAD
|
2009-07-18 23:26:50 +00:00
|
|
|
"NAVI:",
|
2010-02-07 20:19:34 +00:00
|
|
|
#elif CONFIG_KEYPAD == COWON_D2_PAD
|
|
|
|
"MENU:",
|
2006-02-22 10:34:36 +00:00
|
|
|
#else
|
2009-07-18 23:26:50 +00:00
|
|
|
"SELECT:",
|
2006-02-22 10:34:36 +00:00
|
|
|
#endif
|
2009-07-18 23:26:50 +00:00
|
|
|
"Releases", "the", "ball/Fire!", "",
|
2008-03-22 10:24:28 +00:00
|
|
|
#if CONFIG_KEYPAD == IAUDIO_M3_PAD
|
2009-08-02 13:45:39 +00:00
|
|
|
"REC:",
|
2009-07-14 13:03:17 +00:00
|
|
|
#elif (CONFIG_KEYPAD == GIGABEAT_S_PAD) || \
|
|
|
|
(CONFIG_KEYPAD == CREATIVEZVM_PAD)
|
2009-07-18 23:26:50 +00:00
|
|
|
"BACK:",
|
2009-07-14 13:03:17 +00:00
|
|
|
#elif (CONFIG_KEYPAD == IPOD_4G_PAD) || \
|
|
|
|
(CONFIG_KEYPAD == IPOD_3G_PAD) || \
|
2009-07-18 23:26:50 +00:00
|
|
|
(CONFIG_KEYPAD == IPOD_1G2G_PAD) || \
|
|
|
|
(CONFIG_KEYPAD == SANSA_FUZE_PAD)
|
|
|
|
"MENU:",
|
2009-07-14 13:03:17 +00:00
|
|
|
#elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
|
|
|
|
(CONFIG_KEYPAD == IRIVER_H300_PAD) || \
|
|
|
|
(CONFIG_KEYPAD == ONDIO_PAD) || \
|
|
|
|
(CONFIG_KEYPAD == RECORDER_PAD) || \
|
|
|
|
(CONFIG_KEYPAD == ARCHOS_AV300_PAD)
|
2009-07-18 23:26:50 +00:00
|
|
|
"STOP:",
|
2008-03-22 10:24:28 +00:00
|
|
|
#else
|
2009-07-18 23:26:50 +00:00
|
|
|
"POWER:",
|
2008-03-22 10:24:28 +00:00
|
|
|
#endif
|
2009-07-18 23:26:50 +00:00
|
|
|
"Returns", "to", "menu", "", "",
|
2009-07-14 13:03:17 +00:00
|
|
|
"Specials", "",
|
|
|
|
"N", "Normal:", "returns", "paddle", "to", "normal", "",
|
|
|
|
"D", "DIE!:", "loses", "a", "life", "",
|
2009-07-18 23:26:50 +00:00
|
|
|
"L", "Life:", "gains", "a", "life/power", "up", "",
|
2009-07-14 13:03:17 +00:00
|
|
|
"F", "Fire:", "allows", "you", "to", "shoot", "bricks", "",
|
|
|
|
"G", "Glue:", "ball", "sticks", "to", "paddle", "",
|
|
|
|
"B", "Ball:", "generates", "another", "ball", "",
|
2009-07-18 23:26:50 +00:00
|
|
|
"FL", "Flip:", "flips", "left / right", "movement", "",
|
2009-07-26 20:46:40 +00:00
|
|
|
"<->", "or", "<E>:", "enlarges", "the", "paddle", "",
|
2009-08-02 13:45:39 +00:00
|
|
|
">-<", "or", ">S<:", "shrinks", "the", "paddle", "",
|
2009-07-14 13:03:17 +00:00
|
|
|
};
|
|
|
|
static struct style_text formation[]={
|
|
|
|
{ 0, TEXT_CENTER|TEXT_UNDERLINE },
|
|
|
|
{ 2, C_RED },
|
|
|
|
{ 19, C_RED },
|
2009-07-18 23:26:50 +00:00
|
|
|
{ 37, C_RED },
|
|
|
|
{ 39, C_BLUE },
|
|
|
|
{ 46, C_RED },
|
|
|
|
{ 52, C_GREEN },
|
|
|
|
{ 59, C_ORANGE },
|
|
|
|
{ 67, C_GREEN },
|
|
|
|
{ 74, C_YELLOW },
|
|
|
|
{ 80, C_RED },
|
2010-02-22 07:17:15 +00:00
|
|
|
LAST_STYLE_ITEM
|
2009-07-14 13:03:17 +00:00
|
|
|
};
|
2009-08-02 13:45:39 +00:00
|
|
|
|
|
|
|
rb->lcd_setfont(FONT_UI);
|
2009-07-23 17:45:33 +00:00
|
|
|
#ifdef HAVE_LCD_COLOR
|
|
|
|
rb->lcd_set_background(LCD_BLACK);
|
|
|
|
rb->lcd_set_foreground(LCD_WHITE);
|
|
|
|
#endif
|
2010-02-22 07:17:15 +00:00
|
|
|
if (display_text(ARRAYLEN(help_text), help_text, formation, NULL, true))
|
2009-08-02 13:45:39 +00:00
|
|
|
return 1;
|
2009-07-14 13:03:17 +00:00
|
|
|
rb->lcd_setfont(FONT_SYSFIXED);
|
2010-02-22 07:17:15 +00:00
|
|
|
|
2006-02-24 15:13:04 +00:00
|
|
|
return 0;
|
2006-01-23 16:00:06 +00:00
|
|
|
}
|
|
|
|
|
2009-07-18 23:26:50 +00:00
|
|
|
static int brickmania_menu_cb(int action, const struct menu_item_ex *this_item)
|
|
|
|
{
|
2009-08-02 13:45:39 +00:00
|
|
|
int i = ((intptr_t)this_item);
|
2009-07-18 23:26:50 +00:00
|
|
|
if(action == ACTION_REQUEST_MENUITEM
|
2009-08-02 13:45:39 +00:00
|
|
|
&& !resume && (i==0 || i==6))
|
2009-07-18 23:26:50 +00:00
|
|
|
return ACTION_EXIT_MENUITEM;
|
|
|
|
return action;
|
|
|
|
}
|
|
|
|
|
2009-08-02 13:45:39 +00:00
|
|
|
static int brickmania_menu(void)
|
2009-07-18 23:26:50 +00:00
|
|
|
{
|
2009-08-02 13:45:39 +00:00
|
|
|
int selected = 0;
|
2009-07-18 23:26:50 +00:00
|
|
|
|
|
|
|
static struct opt_items options[] = {
|
|
|
|
{ "Easy", -1 },
|
2009-08-02 13:45:39 +00:00
|
|
|
{ "Normal", -1 },
|
2009-07-18 23:26:50 +00:00
|
|
|
};
|
|
|
|
|
2009-10-04 19:16:18 +00:00
|
|
|
#ifdef HAVE_TOUCHSCREEN
|
|
|
|
/* Entering Menu, set the touchscreen to the global setting */
|
|
|
|
rb->touchscreen_set_mode(rb->global_settings->touch_mode);
|
|
|
|
#endif
|
|
|
|
|
2009-08-02 13:45:39 +00:00
|
|
|
MENUITEM_STRINGLIST(main_menu, "Brickmania Menu", brickmania_menu_cb,
|
|
|
|
"Resume Game", "Start New Game",
|
|
|
|
"Difficulty", "Help", "High Scores",
|
|
|
|
"Playback Control",
|
|
|
|
"Quit without Saving", "Quit");
|
|
|
|
|
|
|
|
rb->button_clear_queue();
|
2009-07-18 23:26:50 +00:00
|
|
|
while (true) {
|
2009-08-02 13:45:39 +00:00
|
|
|
switch (rb->do_menu(&main_menu, &selected, NULL, false)) {
|
2009-07-18 23:26:50 +00:00
|
|
|
case 0:
|
2009-08-02 13:45:39 +00:00
|
|
|
if(game_state!=ST_READY)
|
|
|
|
game_state = ST_PAUSE;
|
2009-09-06 14:14:22 +00:00
|
|
|
if(resume_file)
|
|
|
|
rb->remove(SAVE_FILE);
|
2009-07-18 23:26:50 +00:00
|
|
|
return 0;
|
|
|
|
case 1:
|
|
|
|
score=0;
|
|
|
|
vscore=0;
|
|
|
|
life=2;
|
|
|
|
level=0;
|
2009-10-04 22:27:42 +00:00
|
|
|
brickmania_init_game(true);
|
2009-07-18 23:26:50 +00:00
|
|
|
return 0;
|
|
|
|
case 2:
|
2010-02-19 07:36:56 +00:00
|
|
|
rb->set_option("Difficulty", &difficulty, INT,
|
2009-10-03 08:26:19 +00:00
|
|
|
options, 2, NULL);
|
2009-07-18 23:26:50 +00:00
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
if (brickmania_help())
|
|
|
|
return 1;
|
|
|
|
break;
|
|
|
|
case 4:
|
2010-02-27 14:45:37 +00:00
|
|
|
highscore_show(-1, highscores, NUM_SCORES, true);
|
2009-07-18 23:26:50 +00:00
|
|
|
break;
|
|
|
|
case 5:
|
2009-08-02 13:45:39 +00:00
|
|
|
if (playback_control(NULL))
|
|
|
|
return 1;
|
2009-07-18 23:26:50 +00:00
|
|
|
break;
|
|
|
|
case 6:
|
2009-08-02 13:45:39 +00:00
|
|
|
return 1;
|
|
|
|
case 7:
|
|
|
|
if (resume) {
|
|
|
|
rb->splash(HZ*1, "Saving game ...");
|
|
|
|
brickmania_savegame();
|
2009-07-18 23:26:50 +00:00
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
case MENU_ATTACHED_USB:
|
|
|
|
return 1;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-10-04 19:16:18 +00:00
|
|
|
#ifdef HAVE_TOUCHSCREEN
|
|
|
|
rb->touchscreen_set_mode(TOUCHSCREEN_POINT);
|
|
|
|
#endif
|
2009-07-18 23:26:50 +00:00
|
|
|
}
|
|
|
|
|
2010-02-27 08:02:12 +00:00
|
|
|
static void brick_hit(int i, int j)
|
2009-10-03 08:26:19 +00:00
|
|
|
{
|
2010-02-24 20:08:30 +00:00
|
|
|
if(!brick[i][j].used)
|
2009-10-05 05:02:53 +00:00
|
|
|
return;
|
|
|
|
|
2009-10-03 08:26:19 +00:00
|
|
|
/* if this is a crackable brick hits starts as
|
|
|
|
* greater than 0.
|
|
|
|
*/
|
2010-02-24 20:08:30 +00:00
|
|
|
if (brick[i][j].hits > 0) {
|
|
|
|
brick[i][j].hits--;
|
|
|
|
brick[i][j].hiteffect++;
|
2010-02-19 12:52:31 +00:00
|
|
|
score+=SCORE_BALL_HIT_BRICK;
|
2009-10-03 08:26:19 +00:00
|
|
|
}
|
|
|
|
else {
|
2010-02-24 20:08:30 +00:00
|
|
|
brick[i][j].used=false;
|
2010-02-26 14:06:34 +00:00
|
|
|
if (used_powers<MAX_POWERS)
|
|
|
|
{
|
|
|
|
int ran = rb->rand()%POWER_RAND;
|
|
|
|
|
2010-02-27 09:35:47 +00:00
|
|
|
if (ran<NUMBER_OF_POWERUPS)
|
2010-02-26 14:06:34 +00:00
|
|
|
{
|
|
|
|
power[used_powers].top = TOPMARGIN + i*BRICK_HEIGHT;
|
|
|
|
power[used_powers].x_pos = LEFTMARGIN + j*BRICK_WIDTH +
|
|
|
|
(BRICK_WIDTH >> 1);
|
|
|
|
power[used_powers].type = ran;
|
|
|
|
used_powers++;
|
|
|
|
}
|
2009-10-03 08:26:19 +00:00
|
|
|
}
|
|
|
|
brick_on_board--;
|
2010-02-19 12:52:31 +00:00
|
|
|
score+=SCORE_BALL_DEMOLISHED_BRICK;
|
2009-10-03 08:26:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-18 23:26:50 +00:00
|
|
|
static int brickmania_game_loop(void)
|
2006-03-03 07:24:34 +00:00
|
|
|
{
|
2009-10-04 22:27:42 +00:00
|
|
|
int j,i,k;
|
2010-04-20 08:14:33 +00:00
|
|
|
int sw, sh;
|
2006-02-22 10:34:36 +00:00
|
|
|
char s[30];
|
2009-08-02 13:45:39 +00:00
|
|
|
int sec_count=0;
|
2006-01-27 10:02:13 +00:00
|
|
|
int end;
|
2010-02-19 07:36:56 +00:00
|
|
|
|
2010-02-27 18:45:37 +00:00
|
|
|
/* pad_rect used for powerup/ball checks */
|
|
|
|
struct rect pad_rect;
|
2009-10-03 08:26:19 +00:00
|
|
|
/* This is used for various lines that are checked (ball and powerup) */
|
2010-02-26 14:36:37 +00:00
|
|
|
struct line misc_line;
|
2010-02-19 07:36:56 +00:00
|
|
|
|
2009-10-03 08:26:19 +00:00
|
|
|
/* This stores the point that the two lines intersected in a test */
|
2010-02-26 14:36:37 +00:00
|
|
|
struct point pt_hit;
|
2006-03-03 07:24:34 +00:00
|
|
|
|
2009-10-04 22:27:42 +00:00
|
|
|
if (brickmania_menu()) {
|
2009-08-02 13:45:39 +00:00
|
|
|
return 1;
|
2006-01-23 16:00:06 +00:00
|
|
|
}
|
2009-08-02 13:45:39 +00:00
|
|
|
resume = false;
|
2009-09-06 14:14:22 +00:00
|
|
|
resume_file = false;
|
2010-02-19 07:36:56 +00:00
|
|
|
|
2009-10-04 22:27:42 +00:00
|
|
|
#ifdef HAVE_LCD_COLOR
|
|
|
|
rb->lcd_set_background(LCD_BLACK);
|
|
|
|
rb->lcd_set_foreground(LCD_WHITE);
|
|
|
|
rb->lcd_set_drawmode(DRMODE_SOLID);
|
|
|
|
rb->lcd_clear_display();
|
|
|
|
#endif
|
2006-01-23 16:00:06 +00:00
|
|
|
|
2006-01-27 10:02:13 +00:00
|
|
|
while(true) {
|
|
|
|
/* Convert CYCLETIME (in ms) to HZ */
|
|
|
|
end = *rb->current_tick + (CYCLETIME * HZ) / 1000;
|
|
|
|
|
2006-01-23 16:00:06 +00:00
|
|
|
if (life >= 0) {
|
2006-03-03 07:24:34 +00:00
|
|
|
rb->lcd_clear_display();
|
|
|
|
|
2010-02-19 07:36:56 +00:00
|
|
|
if (flip_sides)
|
2009-10-04 22:27:42 +00:00
|
|
|
{
|
2009-10-18 15:50:30 +00:00
|
|
|
if (TIME_AFTER(*rb->current_tick, sec_count))
|
2009-10-04 22:27:42 +00:00
|
|
|
{
|
2006-03-03 07:24:34 +00:00
|
|
|
sec_count=*rb->current_tick+HZ;
|
2010-04-20 08:33:16 +00:00
|
|
|
if (flip_sides_delay > 1)
|
2010-02-19 07:32:27 +00:00
|
|
|
flip_sides_delay--;
|
2006-03-03 07:24:34 +00:00
|
|
|
else
|
|
|
|
flip_sides=false;
|
|
|
|
}
|
2010-02-19 07:32:27 +00:00
|
|
|
rb->snprintf(s, sizeof(s), "%d", flip_sides_delay);
|
2006-03-03 07:24:34 +00:00
|
|
|
rb->lcd_getstringsize(s, &sw, NULL);
|
2009-10-03 08:26:19 +00:00
|
|
|
rb->lcd_putsxy(LCD_WIDTH/2-2, INT3(STRINGPOS_FLIP), s);
|
2006-03-03 07:24:34 +00:00
|
|
|
}
|
|
|
|
|
2006-01-26 23:31:00 +00:00
|
|
|
/* write life num */
|
2006-02-22 10:34:36 +00:00
|
|
|
#if (LCD_WIDTH == 112) && (LCD_HEIGHT == 64)
|
2010-08-28 21:46:45 +00:00
|
|
|
#define LIFE_STR "L:%d"
|
2006-02-22 10:34:36 +00:00
|
|
|
#else
|
2010-08-28 21:46:45 +00:00
|
|
|
#define LIFE_STR "Life: %d"
|
2006-02-22 10:34:36 +00:00
|
|
|
#endif
|
2010-08-28 21:46:45 +00:00
|
|
|
rb->lcd_putsxyf(0, 0, LIFE_STR, life);
|
2006-03-03 07:24:34 +00:00
|
|
|
|
2006-02-22 10:34:36 +00:00
|
|
|
#if (LCD_WIDTH == 112) && (LCD_HEIGHT == 64)
|
2009-07-18 23:26:50 +00:00
|
|
|
rb->snprintf(s, sizeof(s), "L%d", level+1);
|
2006-02-22 10:34:36 +00:00
|
|
|
#else
|
2009-07-18 23:26:50 +00:00
|
|
|
rb->snprintf(s, sizeof(s), "Level %d", level+1);
|
2006-02-22 10:34:36 +00:00
|
|
|
#endif
|
2006-01-23 16:00:06 +00:00
|
|
|
|
2009-08-02 17:24:16 +00:00
|
|
|
rb->lcd_getstringsize(s, &sw, NULL);
|
|
|
|
rb->lcd_putsxy(LCD_WIDTH-sw, 0, s);
|
|
|
|
|
2006-01-23 16:00:06 +00:00
|
|
|
if (vscore<score) vscore++;
|
|
|
|
rb->snprintf(s, sizeof(s), "%d", vscore);
|
|
|
|
rb->lcd_getstringsize(s, &sw, NULL);
|
2006-02-22 10:34:36 +00:00
|
|
|
rb->lcd_putsxy(LCD_WIDTH/2-sw/2, 0, s);
|
2006-01-23 16:00:06 +00:00
|
|
|
|
|
|
|
/* continue game */
|
2010-02-19 07:36:56 +00:00
|
|
|
if (game_state == ST_PAUSE)
|
2009-10-03 08:26:19 +00:00
|
|
|
{
|
2009-10-04 22:27:42 +00:00
|
|
|
rb->snprintf(s, sizeof(s), CONTINUE_TEXT);
|
2006-02-22 10:34:36 +00:00
|
|
|
rb->lcd_getstringsize(s, &sw, NULL);
|
2009-10-03 08:26:19 +00:00
|
|
|
rb->lcd_putsxy(LCD_WIDTH/2-sw/2, INT3(STRINGPOS_NAVI), s);
|
2006-02-22 10:34:36 +00:00
|
|
|
|
2006-01-26 23:31:00 +00:00
|
|
|
sec_count=*rb->current_tick+HZ;
|
2006-01-23 16:00:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* draw the ball */
|
2006-02-15 17:37:45 +00:00
|
|
|
for(i=0;i<used_balls;i++)
|
2010-02-19 07:36:56 +00:00
|
|
|
rb->lcd_bitmap(brickmania_ball,
|
|
|
|
INT3(ball[i].pos_x - HALFBALL),
|
|
|
|
INT3(ball[i].pos_y - HALFBALL),
|
2010-01-02 04:51:32 +00:00
|
|
|
INT3(BALL), INT3(BALL));
|
2006-01-23 16:00:06 +00:00
|
|
|
|
2006-03-03 07:24:34 +00:00
|
|
|
if (brick_on_board==0)
|
|
|
|
brick_on_board--;
|
2006-01-23 16:00:06 +00:00
|
|
|
|
2010-02-27 08:24:45 +00:00
|
|
|
/* Setup the pad line-later used in intersection test */
|
2010-02-27 18:45:37 +00:00
|
|
|
pad_rect.top_left.x = pad_pos_x;
|
|
|
|
pad_rect.top_left.y = PAD_POS_Y;
|
2010-02-27 08:24:45 +00:00
|
|
|
|
2010-02-27 18:45:37 +00:00
|
|
|
pad_rect.bottom_right.x = pad_pos_x + pad_width;
|
|
|
|
pad_rect.bottom_right.y = PAD_POS_Y + PAD_HEIGHT;
|
2010-02-27 08:24:45 +00:00
|
|
|
|
2010-02-19 16:34:18 +00:00
|
|
|
if (game_state!=ST_PAUSE)
|
2009-10-03 08:26:19 +00:00
|
|
|
{
|
2010-02-26 14:06:34 +00:00
|
|
|
/* move the fires */
|
2010-02-19 16:34:18 +00:00
|
|
|
for(k=0;k<used_fires;k++)
|
2009-10-03 08:26:19 +00:00
|
|
|
{
|
2010-02-19 16:34:18 +00:00
|
|
|
fire[k].top -= SPEED_FIRE;
|
|
|
|
if (fire[k].top < 0)
|
|
|
|
{
|
|
|
|
used_fires--;
|
|
|
|
fire[k].top = fire[used_fires].top;
|
|
|
|
fire[k].x_pos = fire[used_fires].x_pos;
|
|
|
|
k--;
|
|
|
|
}
|
|
|
|
else if (fire[k].x_pos >= LEFTMARGIN &&
|
|
|
|
fire[k].x_pos < LEFTMARGIN + NUM_BRICKS_COLS * BRICK_WIDTH)
|
|
|
|
{
|
|
|
|
j = (fire[k].x_pos - LEFTMARGIN) / BRICK_WIDTH;
|
|
|
|
for (i=NUM_BRICKS_ROWS-1;i>=0;i--)
|
|
|
|
{
|
2010-04-20 09:08:21 +00:00
|
|
|
if (TOPMARGIN + i*BRICK_HEIGHT<=fire[k].top)
|
|
|
|
break;
|
2010-02-24 20:08:30 +00:00
|
|
|
if (brick[i][j].used)
|
2010-02-19 16:34:18 +00:00
|
|
|
{
|
|
|
|
score += SCORE_FIRE_HIT_BRICK;
|
2010-02-24 20:08:30 +00:00
|
|
|
brick_hit(i, j);
|
2010-02-19 16:34:18 +00:00
|
|
|
used_fires--;
|
|
|
|
fire[k].top = fire[used_fires].top;
|
|
|
|
fire[k].x_pos = fire[used_fires].x_pos;
|
|
|
|
k--;
|
|
|
|
break;
|
|
|
|
}
|
2010-02-26 14:06:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-02-27 08:24:45 +00:00
|
|
|
|
|
|
|
/* move and handle the powerups */
|
2010-02-26 14:06:34 +00:00
|
|
|
for (k=0;k<used_powers;k++)
|
|
|
|
{
|
|
|
|
int remove_power = 0;
|
|
|
|
|
|
|
|
power[k].top += SPEED_POWER;
|
|
|
|
|
|
|
|
if (power[k].top > PAD_POS_Y)
|
|
|
|
{
|
|
|
|
/* power hit bottom */
|
|
|
|
remove_power = 1;
|
|
|
|
}
|
2010-02-27 08:24:45 +00:00
|
|
|
else
|
2010-02-26 14:06:34 +00:00
|
|
|
{
|
2010-02-27 08:24:45 +00:00
|
|
|
/* Use misc_line to check if the center of the powerup
|
|
|
|
* hit the paddle.
|
|
|
|
*/
|
|
|
|
misc_line.p1.x = power[k].x_pos;
|
|
|
|
misc_line.p1.y = power[k].top;
|
|
|
|
|
|
|
|
misc_line.p2 = misc_line.p1;
|
|
|
|
misc_line.p2.y += SPEED_POWER;
|
|
|
|
|
|
|
|
/* Check if the powerup will hit the paddle */
|
2010-02-27 18:45:37 +00:00
|
|
|
if (check_rect(&misc_line, &pad_rect, INTERSECTION_ALL,
|
|
|
|
&pt_hit))
|
2010-02-26 14:06:34 +00:00
|
|
|
{
|
2010-02-27 08:24:45 +00:00
|
|
|
|
|
|
|
/* power hit paddle */
|
|
|
|
remove_power = 1;
|
|
|
|
switch(power[k].type)
|
|
|
|
{
|
|
|
|
case POWER_TYPE_LIFE_GAIN:
|
|
|
|
life++;
|
|
|
|
score += SCORE_POWER_LIFE_GAIN;
|
|
|
|
break;
|
|
|
|
case POWER_TYPE_LIFE_LOSS:
|
|
|
|
life--;
|
|
|
|
if (life>=0)
|
|
|
|
{
|
|
|
|
brickmania_init_game(false);
|
|
|
|
brickmania_sleep(2);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case POWER_TYPE_PADDLE_STICKY:
|
|
|
|
score += SCORE_POWER_PADDLE_STICKY;
|
|
|
|
paddle_type = PADDLE_TYPE_STICKY;
|
|
|
|
break;
|
|
|
|
case POWER_TYPE_PADDLE_SHOOTER:
|
|
|
|
score += SCORE_POWER_PADDLE_SHOOTER;
|
|
|
|
paddle_type = PADDLE_TYPE_SHOOTER;
|
|
|
|
for(i=0;i<used_balls;i++)
|
|
|
|
ball[i].glue=false;
|
|
|
|
break;
|
|
|
|
case POWER_TYPE_PADDLE_NORMAL:
|
|
|
|
score += SCORE_POWER_PADDLE_NORMAL;
|
|
|
|
paddle_type = PADDLE_TYPE_NORMAL;
|
|
|
|
for(i=0;i<used_balls;i++)
|
|
|
|
ball[i].glue=false;
|
|
|
|
flip_sides=false;
|
|
|
|
pad_pos_x += (pad_width-PAD_WIDTH)/2;
|
2010-02-26 14:06:34 +00:00
|
|
|
pad_width = PAD_WIDTH;
|
2010-02-27 08:24:45 +00:00
|
|
|
break;
|
|
|
|
case POWER_TYPE_PADDLE_FLIP:
|
|
|
|
score += SCORE_POWER_FLIP;
|
|
|
|
sec_count = *rb->current_tick+HZ;
|
|
|
|
flip_sides_delay = FLIP_SIDES_DELAY;
|
|
|
|
flip_sides = true;
|
|
|
|
break;
|
|
|
|
case POWER_TYPE_EXTRA_BALL:
|
|
|
|
score += SCORE_POWER_EXTRA_BALL;
|
|
|
|
if(used_balls<MAX_BALLS)
|
|
|
|
{
|
|
|
|
/* Set the speed */
|
|
|
|
if(rb->rand()%2 == 0)
|
|
|
|
ball[used_balls].speedx=-SPEED_4Q_X;
|
|
|
|
else
|
|
|
|
ball[used_balls].speedx= SPEED_4Q_X;
|
|
|
|
ball[used_balls].speedy= SPEED_4Q_Y;
|
|
|
|
/* Ball is not glued */
|
|
|
|
ball[used_balls].glue= false;
|
|
|
|
used_balls++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case POWER_TYPE_PADDLE_LONG:
|
|
|
|
score+=SCORE_POWER_LONG_PADDLE;
|
|
|
|
if (pad_width==PAD_WIDTH)
|
|
|
|
{
|
|
|
|
pad_width = LONG_PAD_WIDTH;
|
|
|
|
pad_pos_x -= (LONG_PAD_WIDTH -
|
|
|
|
PAD_WIDTH)/2;
|
|
|
|
}
|
|
|
|
else if (pad_width==SHORT_PAD_WIDTH)
|
|
|
|
{
|
|
|
|
pad_width = PAD_WIDTH;
|
|
|
|
pad_pos_x-=(PAD_WIDTH-
|
|
|
|
SHORT_PAD_WIDTH)/2;
|
|
|
|
}
|
|
|
|
if (pad_pos_x < 0)
|
|
|
|
pad_pos_x = 0;
|
|
|
|
else if(pad_pos_x + pad_width >
|
|
|
|
GAMESCREEN_WIDTH)
|
|
|
|
pad_pos_x = GAMESCREEN_WIDTH-pad_width;
|
|
|
|
break;
|
|
|
|
case POWER_TYPE_PADDLE_SHORT:
|
|
|
|
if (pad_width==PAD_WIDTH)
|
|
|
|
{
|
|
|
|
pad_width=SHORT_PAD_WIDTH;
|
|
|
|
pad_pos_x+=(PAD_WIDTH-
|
|
|
|
SHORT_PAD_WIDTH)/2;
|
|
|
|
}
|
|
|
|
else if (pad_width==LONG_PAD_WIDTH)
|
|
|
|
{
|
|
|
|
pad_width=PAD_WIDTH;
|
|
|
|
pad_pos_x+=(LONG_PAD_WIDTH-PAD_WIDTH)/2;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2010-02-19 16:34:18 +00:00
|
|
|
}
|
2010-02-26 14:06:34 +00:00
|
|
|
|
2010-02-27 08:24:45 +00:00
|
|
|
if (remove_power)
|
2010-02-27 07:58:48 +00:00
|
|
|
{
|
2010-02-27 08:24:45 +00:00
|
|
|
used_powers--;
|
|
|
|
if (k != used_powers)
|
|
|
|
{
|
|
|
|
power[k].top = power[used_powers].top;
|
|
|
|
power[k].x_pos = power[used_powers].x_pos;
|
|
|
|
power[k].type = power[used_powers].type;
|
|
|
|
}
|
|
|
|
k--;
|
2010-02-27 07:58:48 +00:00
|
|
|
}
|
2010-02-26 14:06:34 +00:00
|
|
|
}
|
2006-01-23 16:00:06 +00:00
|
|
|
}
|
|
|
|
}
|
2010-02-19 07:36:56 +00:00
|
|
|
|
2010-02-19 16:34:18 +00:00
|
|
|
/* draw the fires */
|
|
|
|
for(k=0;k<used_fires;k++)
|
|
|
|
{
|
2010-03-28 16:36:30 +00:00
|
|
|
rb->lcd_vline(INT3(fire[k].x_pos), INT3(fire[k].top),
|
2010-02-19 16:34:18 +00:00
|
|
|
INT3(fire[k].top + FIRE_LENGTH));
|
|
|
|
}
|
|
|
|
|
2010-02-26 14:06:34 +00:00
|
|
|
/* draw the powerups */
|
|
|
|
for(k=0;k<used_powers;k++)
|
|
|
|
{
|
|
|
|
rb->lcd_bitmap_part(brickmania_powerups,0,
|
|
|
|
INT3(POWERUP_HEIGHT)*power[k].type,
|
|
|
|
STRIDE(SCREEN_MAIN, BMPWIDTH_brickmania_powerups,
|
|
|
|
BMPHEIGHT_brickmania_powerups),
|
|
|
|
INT3(power[k].x_pos - (POWERUP_WIDTH >> 1)),
|
|
|
|
INT3(power[k].top), INT3(POWERUP_WIDTH),
|
|
|
|
INT3(POWERUP_HEIGHT));
|
|
|
|
}
|
|
|
|
|
2010-02-27 08:24:45 +00:00
|
|
|
/* handle all of the bricks */
|
2010-02-19 07:36:56 +00:00
|
|
|
for (i=0; i<NUM_BRICKS_ROWS; i++)
|
2009-10-03 08:26:19 +00:00
|
|
|
{
|
2010-02-19 07:36:56 +00:00
|
|
|
for (j=0; j<NUM_BRICKS_COLS ;j++)
|
2009-10-03 08:26:19 +00:00
|
|
|
{
|
2010-02-26 14:06:34 +00:00
|
|
|
int brickx,bricky;
|
2006-01-23 16:00:06 +00:00
|
|
|
|
2009-10-04 22:27:42 +00:00
|
|
|
/* The brick is a brick, but it may or may not be in use */
|
2010-02-26 14:06:34 +00:00
|
|
|
if(brick[i][j].used)
|
2009-10-04 22:27:42 +00:00
|
|
|
{
|
2010-02-27 18:23:46 +00:00
|
|
|
struct rect brick_rect;
|
|
|
|
|
2009-10-04 22:27:42 +00:00
|
|
|
brickx = LEFTMARGIN + j*BRICK_WIDTH;
|
2010-02-26 14:06:34 +00:00
|
|
|
bricky = TOPMARGIN + i*BRICK_HEIGHT;
|
2010-02-19 07:36:56 +00:00
|
|
|
|
2010-02-27 18:23:46 +00:00
|
|
|
brick_rect.top_left.x = brickx;
|
|
|
|
brick_rect.top_left.y = bricky;
|
2010-02-19 07:36:56 +00:00
|
|
|
|
2010-02-27 18:23:46 +00:00
|
|
|
brick_rect.bottom_right.x = brickx + BRICK_WIDTH;
|
|
|
|
brick_rect.bottom_right.y = bricky + BRICK_HEIGHT;
|
2010-02-19 07:36:56 +00:00
|
|
|
|
2009-10-04 22:27:42 +00:00
|
|
|
/* Draw the brick */
|
2006-03-03 07:24:34 +00:00
|
|
|
rb->lcd_bitmap_part(brickmania_bricks,0,
|
2010-02-24 20:08:30 +00:00
|
|
|
INT3(BRICK_HEIGHT)*brick[i][j].color,
|
2010-02-19 07:36:56 +00:00
|
|
|
STRIDE( SCREEN_MAIN,
|
2009-09-04 00:46:24 +00:00
|
|
|
BMPWIDTH_brickmania_bricks,
|
2009-09-01 02:40:18 +00:00
|
|
|
BMPHEIGHT_brickmania_bricks),
|
2009-10-03 08:26:19 +00:00
|
|
|
INT3(brickx),
|
2010-02-26 14:06:34 +00:00
|
|
|
INT3(bricky),
|
2009-10-03 08:26:19 +00:00
|
|
|
INT3(BRICK_WIDTH), INT3(BRICK_HEIGHT) );
|
2010-02-19 07:36:56 +00:00
|
|
|
|
2006-02-19 21:24:46 +00:00
|
|
|
#ifdef HAVE_LCD_COLOR /* No transparent effect for greyscale lcds for now */
|
2010-02-24 20:08:30 +00:00
|
|
|
if (brick[i][j].hiteffect > 0)
|
2009-08-02 13:45:39 +00:00
|
|
|
rb->lcd_bitmap_transparent_part(brickmania_break,0,
|
2010-02-24 20:08:30 +00:00
|
|
|
INT3(BRICK_HEIGHT)*brick[i][j].hiteffect,
|
2010-02-19 07:36:56 +00:00
|
|
|
STRIDE( SCREEN_MAIN,
|
|
|
|
BMPWIDTH_brickmania_break,
|
2009-09-01 02:40:18 +00:00
|
|
|
BMPHEIGHT_brickmania_break),
|
2009-10-03 08:26:19 +00:00
|
|
|
INT3(brickx),
|
2010-02-26 14:06:34 +00:00
|
|
|
INT3(bricky),
|
2009-10-03 08:26:19 +00:00
|
|
|
INT3(BRICK_WIDTH), INT3(BRICK_HEIGHT) );
|
2006-02-19 21:24:46 +00:00
|
|
|
#endif
|
2009-10-04 22:27:42 +00:00
|
|
|
|
|
|
|
/* Check if any balls collided with the brick */
|
2010-02-19 07:36:56 +00:00
|
|
|
for(k=0; k<used_balls; k++)
|
2009-10-03 08:26:19 +00:00
|
|
|
{
|
2010-02-27 18:23:46 +00:00
|
|
|
int hit = 0;
|
|
|
|
|
2009-10-03 08:26:19 +00:00
|
|
|
/* Setup the ball path to describe the current ball
|
|
|
|
* position and the line it makes to its next
|
2010-02-19 07:36:56 +00:00
|
|
|
* position.
|
2009-10-03 08:26:19 +00:00
|
|
|
*/
|
2010-01-02 04:51:32 +00:00
|
|
|
misc_line.p1.x = ball[k].pos_x;
|
|
|
|
misc_line.p1.y = ball[k].pos_y;
|
2010-02-19 07:36:56 +00:00
|
|
|
|
2010-01-02 04:51:32 +00:00
|
|
|
misc_line.p2.x = ball[k].pos_x + ball[k].speedx;
|
|
|
|
misc_line.p2.y = ball[k].pos_y + ball[k].speedy;
|
2010-02-19 07:36:56 +00:00
|
|
|
|
2009-10-03 08:26:19 +00:00
|
|
|
/* Check to see if the ball and the bottom hit. If
|
|
|
|
* the ball is moving down we don't want to
|
|
|
|
* include the bottom line intersection.
|
|
|
|
*
|
|
|
|
* The order that the sides are checked matters.
|
2010-02-19 07:36:56 +00:00
|
|
|
*
|
2009-10-03 08:26:19 +00:00
|
|
|
* Note that tempx/tempy store the next position
|
|
|
|
* that the ball should be drawn.
|
|
|
|
*/
|
2010-02-27 18:23:46 +00:00
|
|
|
if (ball[k].speedy <= 0 && check_rect(&misc_line,
|
|
|
|
&brick_rect, INTERSECTION_BOTTOM, &pt_hit))
|
2009-10-03 08:26:19 +00:00
|
|
|
{
|
|
|
|
ball[k].speedy = -ball[k].speedy;
|
2010-02-27 18:23:46 +00:00
|
|
|
hit = 1;
|
2009-10-03 08:26:19 +00:00
|
|
|
}
|
|
|
|
/* Check the top, if the ball is moving up dont
|
|
|
|
* count it as a hit.
|
|
|
|
*/
|
2010-02-27 18:23:46 +00:00
|
|
|
else if (ball[k].speedy > 0 && check_rect(&misc_line,
|
|
|
|
&brick_rect, INTERSECTION_TOP, &pt_hit))
|
2009-10-03 08:26:19 +00:00
|
|
|
{
|
|
|
|
ball[k].speedy = -ball[k].speedy;
|
2010-02-27 18:23:46 +00:00
|
|
|
hit = 1;
|
2009-10-03 08:26:19 +00:00
|
|
|
}
|
|
|
|
/* Check the left side of the brick */
|
2010-02-27 18:23:46 +00:00
|
|
|
else if (check_rect(&misc_line, &brick_rect,
|
|
|
|
INTERSECTION_LEFT, &pt_hit))
|
2009-10-03 08:26:19 +00:00
|
|
|
{
|
|
|
|
ball[k].speedx = -ball[k].speedx;
|
2010-02-27 18:23:46 +00:00
|
|
|
hit = 1;
|
2009-10-03 08:26:19 +00:00
|
|
|
}
|
|
|
|
/* Check the right side of the brick */
|
2010-02-27 18:23:46 +00:00
|
|
|
else if (check_rect(&misc_line, &brick_rect,
|
|
|
|
INTERSECTION_RIGHT, &pt_hit))
|
2009-10-03 08:26:19 +00:00
|
|
|
{
|
|
|
|
ball[k].speedx = -ball[k].speedx;
|
2010-02-27 18:23:46 +00:00
|
|
|
hit = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hit)
|
|
|
|
{
|
2010-01-02 04:51:32 +00:00
|
|
|
ball[k].tempy = pt_hit.y;
|
|
|
|
ball[k].tempx = pt_hit.x;
|
2010-02-24 20:08:30 +00:00
|
|
|
brick_hit(i, j);
|
2010-03-27 17:56:54 +00:00
|
|
|
break;
|
2006-01-23 16:00:06 +00:00
|
|
|
}
|
2009-10-04 22:27:42 +00:00
|
|
|
} /* for k */
|
|
|
|
} /* if(used) */
|
2010-02-19 07:36:56 +00:00
|
|
|
|
2006-02-15 17:37:45 +00:00
|
|
|
} /* for j */
|
|
|
|
} /* for i */
|
2006-01-23 16:00:06 +00:00
|
|
|
|
2009-10-08 00:15:54 +00:00
|
|
|
/* draw the paddle according to the PAD_WIDTH */
|
|
|
|
if( pad_width == PAD_WIDTH ) /* Normal width */
|
|
|
|
{
|
|
|
|
rb->lcd_bitmap_part(
|
|
|
|
brickmania_pads,
|
2010-02-26 14:06:34 +00:00
|
|
|
0, paddle_type*INT3(PAD_HEIGHT),
|
2010-02-19 07:36:56 +00:00
|
|
|
STRIDE( SCREEN_MAIN, BMPWIDTH_brickmania_pads,
|
2009-10-08 00:15:54 +00:00
|
|
|
BMPHEIGHT_brickmania_pads),
|
2010-02-19 07:36:56 +00:00
|
|
|
INT3(pad_pos_x), INT3(PAD_POS_Y),
|
2009-10-08 00:15:54 +00:00
|
|
|
INT3(pad_width), INT3(PAD_HEIGHT) );
|
|
|
|
}
|
|
|
|
else if( pad_width == LONG_PAD_WIDTH ) /* Long Pad */
|
|
|
|
{
|
|
|
|
rb->lcd_bitmap_part(
|
|
|
|
brickmania_long_pads,
|
2010-02-26 14:06:34 +00:00
|
|
|
0,paddle_type*INT3(PAD_HEIGHT),
|
2010-02-19 07:36:56 +00:00
|
|
|
STRIDE( SCREEN_MAIN, BMPWIDTH_brickmania_long_pads,
|
2009-10-08 00:15:54 +00:00
|
|
|
BMPHEIGHT_brickmania_long_pads),
|
2010-02-19 07:36:56 +00:00
|
|
|
INT3(pad_pos_x), INT3(PAD_POS_Y),
|
2009-10-08 00:15:54 +00:00
|
|
|
INT3(pad_width), INT3(PAD_HEIGHT) );
|
|
|
|
}
|
|
|
|
else /* Short pad */
|
|
|
|
{
|
|
|
|
rb->lcd_bitmap_part(
|
2009-09-01 02:40:18 +00:00
|
|
|
brickmania_short_pads,
|
2010-02-26 14:06:34 +00:00
|
|
|
0,paddle_type*INT3(PAD_HEIGHT),
|
2010-02-19 07:36:56 +00:00
|
|
|
STRIDE( SCREEN_MAIN, BMPWIDTH_brickmania_short_pads,
|
2009-10-08 00:15:54 +00:00
|
|
|
BMPHEIGHT_brickmania_short_pads),
|
2010-02-19 07:36:56 +00:00
|
|
|
INT3(pad_pos_x), INT3(PAD_POS_Y),
|
2009-10-08 00:15:54 +00:00
|
|
|
INT3(pad_width), INT3(PAD_HEIGHT) );
|
|
|
|
}
|
2009-10-03 08:26:19 +00:00
|
|
|
|
2009-08-28 23:55:44 +00:00
|
|
|
/* If the game is not paused continue */
|
|
|
|
if (game_state!=ST_PAUSE)
|
|
|
|
{
|
|
|
|
/* Loop through all of the balls in play */
|
2010-02-19 07:36:56 +00:00
|
|
|
for(k=0;k<used_balls;k++)
|
2009-08-28 23:55:44 +00:00
|
|
|
{
|
2010-02-26 14:36:37 +00:00
|
|
|
struct line screen_edge;
|
2009-12-23 03:52:50 +00:00
|
|
|
|
|
|
|
/* Describe the ball movement for the edge collision detection */
|
2010-01-02 04:51:32 +00:00
|
|
|
misc_line.p1.x = ball[k].pos_x;
|
|
|
|
misc_line.p1.y = ball[k].pos_y;
|
2010-02-19 07:36:56 +00:00
|
|
|
|
2010-01-02 04:51:32 +00:00
|
|
|
misc_line.p2.x = ball[k].pos_x + ball[k].speedx;
|
|
|
|
misc_line.p2.y = ball[k].pos_y + ball[k].speedy;
|
2009-12-23 03:52:50 +00:00
|
|
|
|
2009-08-28 23:55:44 +00:00
|
|
|
/* Did the Ball hit the top of the screen? */
|
2009-12-23 03:52:50 +00:00
|
|
|
screen_edge.p1.x = 0;
|
|
|
|
screen_edge.p1.y = 0;
|
2010-02-19 07:36:56 +00:00
|
|
|
|
2010-02-21 16:13:43 +00:00
|
|
|
screen_edge.p2.x = GAMESCREEN_WIDTH;
|
2009-12-23 03:52:50 +00:00
|
|
|
screen_edge.p2.y = 0;
|
2010-02-16 20:58:59 +00:00
|
|
|
/* the test for pos_y prevents the ball from bouncing back
|
|
|
|
* from _over_ the top to infinity on some rare cases */
|
|
|
|
if (ball[k].pos_y > 0 &&
|
2010-02-27 18:23:46 +00:00
|
|
|
check_lines(&misc_line, &screen_edge, &pt_hit))
|
2009-08-28 23:55:44 +00:00
|
|
|
{
|
2010-01-02 04:51:32 +00:00
|
|
|
ball[k].tempy = pt_hit.y + 1;
|
|
|
|
ball[k].tempx = pt_hit.x;
|
2009-08-28 23:55:44 +00:00
|
|
|
/* Reverse the direction */
|
2009-10-03 08:26:19 +00:00
|
|
|
ball[k].speedy = -ball[k].speedy;
|
2009-08-28 23:55:44 +00:00
|
|
|
}
|
2009-12-23 03:52:50 +00:00
|
|
|
|
2009-08-28 23:55:44 +00:00
|
|
|
/* Player missed the ball and hit bottom of screen */
|
2010-02-19 07:36:56 +00:00
|
|
|
if (ball[k].pos_y >= GAMESCREEN_HEIGHT)
|
2009-08-28 23:55:44 +00:00
|
|
|
{
|
|
|
|
/* Player had balls to spare, so handle the removal */
|
2010-02-19 07:36:56 +00:00
|
|
|
if (used_balls>1)
|
2009-08-28 23:55:44 +00:00
|
|
|
{
|
|
|
|
/* decrease number of balls in play */
|
2009-08-02 13:45:39 +00:00
|
|
|
used_balls--;
|
2009-08-28 23:55:44 +00:00
|
|
|
/* Replace removed ball with the last ball */
|
2009-08-02 13:45:39 +00:00
|
|
|
ball[k].pos_x = ball[used_balls].pos_x;
|
|
|
|
ball[k].pos_y = ball[used_balls].pos_y;
|
2009-10-03 08:26:19 +00:00
|
|
|
ball[k].speedy = ball[used_balls].speedy;
|
2009-08-02 13:45:39 +00:00
|
|
|
ball[k].tempy = ball[used_balls].tempy;
|
2009-10-03 08:26:19 +00:00
|
|
|
ball[k].speedx = ball[used_balls].speedx;
|
2009-08-02 13:45:39 +00:00
|
|
|
ball[k].tempx = ball[used_balls].tempx;
|
|
|
|
ball[k].glue = ball[used_balls].glue;
|
|
|
|
|
2009-08-28 23:55:44 +00:00
|
|
|
/* Reset the last ball that was removed */
|
2009-10-03 08:26:19 +00:00
|
|
|
ball[used_balls].speedx=0;
|
|
|
|
ball[used_balls].speedy=0;
|
2009-08-02 13:45:39 +00:00
|
|
|
ball[used_balls].tempy=0;
|
|
|
|
ball[used_balls].tempx=0;
|
2010-02-16 20:58:59 +00:00
|
|
|
ball[used_balls].pos_y=ON_PAD_POS_Y;
|
2010-03-28 16:36:30 +00:00
|
|
|
ball[used_balls].pos_x=pad_pos_x+(pad_width/2)-HALFBALL;
|
2009-08-02 13:45:39 +00:00
|
|
|
|
|
|
|
k--;
|
|
|
|
continue;
|
2009-08-28 23:55:44 +00:00
|
|
|
}
|
2010-02-19 07:36:56 +00:00
|
|
|
else
|
2009-08-28 23:55:44 +00:00
|
|
|
{
|
|
|
|
/* Player lost a life */
|
2009-08-02 13:45:39 +00:00
|
|
|
life--;
|
2010-02-19 07:36:56 +00:00
|
|
|
if (life>=0)
|
2009-08-28 23:55:44 +00:00
|
|
|
{
|
|
|
|
/* No lives left reset game */
|
2009-10-04 22:27:42 +00:00
|
|
|
brickmania_init_game(false);
|
2009-08-02 13:45:39 +00:00
|
|
|
brickmania_sleep(2);
|
2009-10-05 02:13:13 +00:00
|
|
|
rb->button_clear_queue();
|
2009-08-02 13:45:39 +00:00
|
|
|
}
|
2006-02-15 17:37:45 +00:00
|
|
|
}
|
2006-01-23 16:00:06 +00:00
|
|
|
}
|
2006-03-03 07:24:34 +00:00
|
|
|
|
2010-02-21 17:16:07 +00:00
|
|
|
if (game_state != ST_READY && !ball[k].glue)
|
2009-08-28 23:55:44 +00:00
|
|
|
{
|
2010-02-21 17:16:07 +00:00
|
|
|
/* Check if the ball hit the left side */
|
|
|
|
screen_edge.p1.x = 0;
|
|
|
|
screen_edge.p1.y = 0;
|
2009-12-23 03:52:50 +00:00
|
|
|
|
2010-02-21 17:16:07 +00:00
|
|
|
screen_edge.p2.x = 0;
|
|
|
|
screen_edge.p2.y = GAMESCREEN_HEIGHT;
|
|
|
|
if (check_lines(&misc_line, &screen_edge, &pt_hit))
|
|
|
|
{
|
|
|
|
/* Reverse direction */
|
2010-04-20 08:38:53 +00:00
|
|
|
ball[k].speedx = abs(ball[k].speedx);
|
2009-10-03 08:26:19 +00:00
|
|
|
|
2010-02-21 17:16:07 +00:00
|
|
|
/* Re-position ball in gameboard */
|
|
|
|
ball[k].tempy = pt_hit.y;
|
|
|
|
ball[k].tempx = 0;
|
|
|
|
}
|
2009-12-23 03:52:50 +00:00
|
|
|
|
2010-02-21 17:16:07 +00:00
|
|
|
/* Check if the ball hit the right side */
|
|
|
|
screen_edge.p1.x = GAMESCREEN_WIDTH;
|
|
|
|
screen_edge.p1.y = 0;
|
2010-02-19 07:36:56 +00:00
|
|
|
|
2010-02-21 17:16:07 +00:00
|
|
|
screen_edge.p2.x = GAMESCREEN_WIDTH;
|
|
|
|
screen_edge.p2.y = GAMESCREEN_HEIGHT;
|
|
|
|
if (check_lines(&misc_line, &screen_edge, &pt_hit))
|
2009-08-28 23:55:44 +00:00
|
|
|
{
|
2010-02-21 17:16:07 +00:00
|
|
|
/* Reverse direction */
|
2010-04-20 08:38:53 +00:00
|
|
|
ball[k].speedx = -abs(ball[k].speedx);
|
2010-02-21 17:16:07 +00:00
|
|
|
|
|
|
|
/* Re-position ball in gameboard */
|
|
|
|
ball[k].tempy = pt_hit.y;
|
|
|
|
ball[k].tempx = GAMESCREEN_WIDTH - FIXED3(1);
|
2009-08-02 13:45:39 +00:00
|
|
|
}
|
2010-02-19 07:36:56 +00:00
|
|
|
|
2010-02-21 17:16:07 +00:00
|
|
|
/* Did the ball hit the paddle? Depending on where the ball
|
|
|
|
* Hit set the x/y speed appropriately.
|
2009-08-28 23:55:44 +00:00
|
|
|
*/
|
2010-02-27 18:45:37 +00:00
|
|
|
if(check_rect(&misc_line, &pad_rect, INTERSECTION_TOP,
|
|
|
|
&pt_hit) )
|
2009-08-28 23:55:44 +00:00
|
|
|
{
|
2010-02-21 17:16:07 +00:00
|
|
|
/* Re-position ball based on collision */
|
|
|
|
ball[k].tempy = ON_PAD_POS_Y;
|
|
|
|
ball[k].tempx = pt_hit.x;
|
|
|
|
|
|
|
|
/* Calculate the ball position relative to the paddle width */
|
|
|
|
int ball_repos = pt_hit.x - pad_pos_x;
|
|
|
|
/* If the ball hits the right half of paddle, x speed
|
|
|
|
* should be positive, if it hits the left half it
|
|
|
|
* should be negative.
|
2009-08-28 23:55:44 +00:00
|
|
|
*/
|
2010-02-21 17:16:07 +00:00
|
|
|
int x_direction = -1;
|
|
|
|
|
|
|
|
/* Comparisons are done with respect to 1/2 pad_width */
|
|
|
|
if(ball_repos > pad_width/2)
|
2009-10-03 08:26:19 +00:00
|
|
|
{
|
2010-02-21 17:16:07 +00:00
|
|
|
/* flip the relative position */
|
|
|
|
ball_repos -= ((ball_repos - pad_width/2) << 1);
|
|
|
|
/* Ball hit the right half so X speed calculations
|
|
|
|
* should be positive.
|
|
|
|
*/
|
|
|
|
x_direction = 1;
|
2009-10-03 08:26:19 +00:00
|
|
|
}
|
2010-02-21 17:16:07 +00:00
|
|
|
|
|
|
|
/* Figure out where the ball hit relative to 1/2 pad
|
|
|
|
* and in divisions of 4.
|
|
|
|
*/
|
|
|
|
ball_repos = ball_repos / (pad_width/2/4);
|
|
|
|
|
|
|
|
switch(ball_repos)
|
2009-10-03 08:26:19 +00:00
|
|
|
{
|
2010-02-21 17:16:07 +00:00
|
|
|
/* Ball hit the outer edge of the paddle */
|
|
|
|
case 0:
|
|
|
|
ball[k].speedy = SPEED_1Q_Y;
|
|
|
|
ball[k].speedx = SPEED_1Q_X * x_direction;
|
|
|
|
break;
|
|
|
|
/* Ball hit the next fourth of the paddle */
|
|
|
|
case 1:
|
|
|
|
ball[k].speedy = SPEED_2Q_Y;
|
|
|
|
ball[k].speedx = SPEED_2Q_X * x_direction;
|
|
|
|
break;
|
|
|
|
/* Ball hit the third fourth of the paddle */
|
|
|
|
case 2:
|
|
|
|
ball[k].speedy = SPEED_3Q_Y;
|
|
|
|
ball[k].speedx = SPEED_3Q_X * x_direction;
|
|
|
|
break;
|
|
|
|
/* Ball hit the fourth fourth of the paddle or dead
|
|
|
|
* center.
|
|
|
|
*/
|
|
|
|
case 3:
|
|
|
|
case 4:
|
|
|
|
ball[k].speedy = SPEED_4Q_Y;
|
|
|
|
/* Since this is the middle we don't want to
|
|
|
|
* force the ball in a different direction.
|
|
|
|
* Just keep it going in the same direction
|
|
|
|
* with a specific speed.
|
|
|
|
*/
|
|
|
|
if(ball[k].speedx > 0)
|
|
|
|
{
|
|
|
|
ball[k].speedx = SPEED_4Q_X;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ball[k].speedx = -SPEED_4Q_X;
|
|
|
|
}
|
|
|
|
break;
|
2009-08-28 23:55:44 +00:00
|
|
|
|
2010-02-21 17:16:07 +00:00
|
|
|
default:
|
|
|
|
ball[k].speedy = SPEED_4Q_Y;
|
|
|
|
break;
|
|
|
|
}
|
2010-02-19 07:36:56 +00:00
|
|
|
|
2010-02-26 14:06:34 +00:00
|
|
|
if(paddle_type == PADDLE_TYPE_STICKY)
|
2010-02-21 17:16:07 +00:00
|
|
|
{
|
|
|
|
ball[k].speedy = -ball[k].speedy;
|
|
|
|
ball[k].glue=true;
|
2009-12-23 03:52:50 +00:00
|
|
|
|
2010-02-21 17:16:07 +00:00
|
|
|
/* X location should not be forced since that is moved with the paddle. The Y
|
|
|
|
* position should be forced to keep the ball at the paddle.
|
|
|
|
*/
|
|
|
|
ball[k].tempx = 0;
|
|
|
|
ball[k].tempy = ON_PAD_POS_Y;
|
|
|
|
}
|
2009-10-03 08:26:19 +00:00
|
|
|
}
|
2006-03-03 07:24:34 +00:00
|
|
|
}
|
|
|
|
|
2009-08-28 23:55:44 +00:00
|
|
|
/* Update the ball position */
|
2009-10-03 08:26:19 +00:00
|
|
|
if (!ball[k].glue)
|
|
|
|
{
|
|
|
|
if(ball[k].tempx)
|
|
|
|
ball[k].pos_x = ball[k].tempx;
|
|
|
|
else
|
|
|
|
ball[k].pos_x += ball[k].speedx;
|
2010-02-19 07:36:56 +00:00
|
|
|
|
2009-10-03 08:26:19 +00:00
|
|
|
if(ball[k].tempy)
|
|
|
|
ball[k].pos_y = ball[k].tempy;
|
|
|
|
else
|
|
|
|
ball[k].pos_y += ball[k].speedy;
|
2006-03-03 07:24:34 +00:00
|
|
|
|
2009-08-02 13:45:39 +00:00
|
|
|
ball[k].tempy=0;
|
|
|
|
ball[k].tempx=0;
|
|
|
|
}
|
|
|
|
} /* for k */
|
|
|
|
}
|
2007-01-26 06:14:29 +00:00
|
|
|
|
2006-03-03 07:24:34 +00:00
|
|
|
rb->lcd_update();
|
|
|
|
|
2010-02-19 07:36:56 +00:00
|
|
|
if (brick_on_board < 0)
|
2009-10-03 08:26:19 +00:00
|
|
|
{
|
2010-02-19 07:36:56 +00:00
|
|
|
if (level+1<NUM_LEVELS)
|
2009-10-03 08:26:19 +00:00
|
|
|
{
|
2009-07-18 23:26:50 +00:00
|
|
|
level++;
|
2009-08-02 13:45:39 +00:00
|
|
|
if (difficulty==NORMAL)
|
2010-02-19 12:52:31 +00:00
|
|
|
score+=SCORE_LEVEL_COMPLETED;
|
2009-10-04 22:27:42 +00:00
|
|
|
brickmania_init_game(true);
|
2009-07-18 23:26:50 +00:00
|
|
|
brickmania_sleep(2);
|
2009-10-05 02:13:13 +00:00
|
|
|
rb->button_clear_queue();
|
2006-03-03 07:24:34 +00:00
|
|
|
}
|
2010-02-19 07:36:56 +00:00
|
|
|
else
|
2009-10-03 08:26:19 +00:00
|
|
|
{
|
2010-04-20 08:14:33 +00:00
|
|
|
rb->lcd_getstringsize("Congratulations!", &sw, &sh);
|
|
|
|
rb->lcd_putsxy(LCD_WIDTH/2-sw/2, INT3(STRINGPOS_FINISH) - 2 * sh,
|
2006-03-03 07:24:34 +00:00
|
|
|
"Congratulations!");
|
2006-02-22 10:34:36 +00:00
|
|
|
#if (LCD_WIDTH == 112) && (LCD_HEIGHT == 64)
|
2006-03-03 07:24:34 +00:00
|
|
|
rb->lcd_getstringsize("No more levels", &sw, NULL);
|
2009-10-03 08:26:19 +00:00
|
|
|
rb->lcd_putsxy(LCD_WIDTH/2-sw/2, INT3(STRINGPOS_FINISH),
|
2006-03-03 07:24:34 +00:00
|
|
|
"No more levels");
|
2006-02-22 10:34:36 +00:00
|
|
|
#else
|
2006-03-03 07:24:34 +00:00
|
|
|
rb->lcd_getstringsize("You have finished the game!",
|
|
|
|
&sw, NULL);
|
2009-10-03 08:26:19 +00:00
|
|
|
rb->lcd_putsxy(LCD_WIDTH/2-sw/2, INT3(STRINGPOS_FINISH),
|
2006-03-03 07:24:34 +00:00
|
|
|
"You have finished the game!");
|
2006-02-22 10:34:36 +00:00
|
|
|
#endif
|
2006-03-03 07:24:34 +00:00
|
|
|
vscore=score;
|
|
|
|
rb->lcd_update();
|
2009-08-02 13:45:39 +00:00
|
|
|
brickmania_sleep(2);
|
|
|
|
return 0;
|
2006-03-03 07:24:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-05 02:13:13 +00:00
|
|
|
int button=rb->button_get(false);
|
|
|
|
int move_button = rb->button_status();
|
2006-07-30 03:10:09 +00:00
|
|
|
|
2008-03-22 10:24:28 +00:00
|
|
|
#if defined(HAS_BUTTON_HOLD) && !defined(HAVE_REMOTE_LCD_AS_MAIN)
|
|
|
|
/* FIXME: Should probably check remote hold here */
|
2006-07-30 03:10:09 +00:00
|
|
|
if (rb->button_hold())
|
2009-08-02 13:45:39 +00:00
|
|
|
button = QUIT;
|
2006-07-30 03:10:09 +00:00
|
|
|
#endif
|
|
|
|
|
2008-08-23 09:46:38 +00:00
|
|
|
#ifdef HAVE_TOUCHSCREEN
|
2009-10-05 02:13:13 +00:00
|
|
|
if( move_button & BUTTON_TOUCHSCREEN)
|
2008-06-09 20:59:55 +00:00
|
|
|
{
|
2009-10-05 02:13:13 +00:00
|
|
|
int data;
|
2011-05-22 13:53:31 +00:00
|
|
|
short touch_x;
|
2009-10-05 02:13:13 +00:00
|
|
|
rb->button_status_wdata(&data);
|
|
|
|
touch_x = FIXED3(data >> 16);
|
2010-02-19 07:36:56 +00:00
|
|
|
|
2009-10-04 21:11:51 +00:00
|
|
|
if(flip_sides)
|
|
|
|
{
|
2009-10-05 04:25:28 +00:00
|
|
|
pad_pos_x = GAMESCREEN_WIDTH - (touch_x + pad_width/2);
|
2009-10-04 21:11:51 +00:00
|
|
|
}
|
|
|
|
else
|
2008-06-09 20:59:55 +00:00
|
|
|
{
|
2009-10-04 21:11:51 +00:00
|
|
|
pad_pos_x = (touch_x - pad_width/2);
|
2006-03-03 07:24:34 +00:00
|
|
|
}
|
2009-08-02 13:45:39 +00:00
|
|
|
|
2009-10-04 21:11:51 +00:00
|
|
|
if(pad_pos_x < 0)
|
|
|
|
pad_pos_x = 0;
|
2009-10-05 02:13:13 +00:00
|
|
|
else if(pad_pos_x + pad_width > GAMESCREEN_WIDTH)
|
2009-10-04 21:11:51 +00:00
|
|
|
pad_pos_x = GAMESCREEN_WIDTH-pad_width;
|
2009-10-05 02:13:13 +00:00
|
|
|
for(k=0; k<used_balls; k++)
|
2009-10-04 21:11:51 +00:00
|
|
|
if (game_state==ST_READY || ball[k].glue)
|
2010-01-02 04:51:32 +00:00
|
|
|
ball[k].pos_x = pad_pos_x + pad_width/2;
|
2006-03-03 07:24:34 +00:00
|
|
|
}
|
2008-06-09 20:59:55 +00:00
|
|
|
else
|
|
|
|
#endif
|
2009-10-05 02:13:13 +00:00
|
|
|
{
|
2010-03-27 18:27:29 +00:00
|
|
|
int button_right, button_left;
|
2009-10-03 08:26:19 +00:00
|
|
|
#ifdef ALTRIGHT
|
2009-10-05 02:13:13 +00:00
|
|
|
button_right = move_button & (RIGHT | ALTRIGHT);
|
|
|
|
button_left = move_button & (LEFT | ALTLEFT);
|
2009-10-03 08:26:19 +00:00
|
|
|
#else
|
2009-11-03 08:03:13 +00:00
|
|
|
button_right =((move_button & RIGHT)|| SCROLL_FWD(button));
|
|
|
|
button_left =((move_button & LEFT) ||SCROLL_BACK(button));
|
2009-10-03 08:26:19 +00:00
|
|
|
#endif
|
2009-08-02 13:45:39 +00:00
|
|
|
if ((game_state==ST_PAUSE) && (button_right || button_left))
|
2008-06-09 20:59:55 +00:00
|
|
|
continue;
|
2010-03-27 18:17:58 +00:00
|
|
|
|
|
|
|
if (button_left || button_right)
|
2009-10-03 08:26:19 +00:00
|
|
|
{
|
2010-03-27 18:27:29 +00:00
|
|
|
int dx = 0;
|
|
|
|
|
2010-03-27 18:17:58 +00:00
|
|
|
if ((button_right && !flip_sides) ||
|
|
|
|
(button_left && flip_sides))
|
2009-10-03 08:26:19 +00:00
|
|
|
{
|
2010-03-27 18:17:58 +00:00
|
|
|
if (pad_pos_x+SPEED_PAD+pad_width > GAMESCREEN_WIDTH)
|
|
|
|
dx = GAMESCREEN_WIDTH - pad_pos_x - pad_width;
|
|
|
|
else
|
|
|
|
dx = SPEED_PAD;
|
2008-06-09 20:59:55 +00:00
|
|
|
}
|
2010-03-27 18:17:58 +00:00
|
|
|
else if ((button_left && !flip_sides) ||
|
|
|
|
(button_right && flip_sides))
|
2009-10-03 08:26:19 +00:00
|
|
|
{
|
2010-03-27 18:17:58 +00:00
|
|
|
if (pad_pos_x-SPEED_PAD < 0)
|
|
|
|
dx = -pad_pos_x;
|
|
|
|
else
|
|
|
|
dx = -SPEED_PAD;
|
2008-06-09 20:59:55 +00:00
|
|
|
}
|
2010-03-27 18:17:58 +00:00
|
|
|
|
|
|
|
pad_pos_x+=dx;
|
|
|
|
for(k=0;k<used_balls;k++)
|
2009-10-03 08:26:19 +00:00
|
|
|
{
|
2010-03-27 18:17:58 +00:00
|
|
|
if (game_state==ST_READY || ball[k].glue)
|
2010-03-27 18:23:43 +00:00
|
|
|
{
|
2010-03-27 18:17:58 +00:00
|
|
|
ball[k].pos_x+=dx;
|
2010-03-27 18:23:43 +00:00
|
|
|
|
|
|
|
if (ball[k].pos_x < HALFBALL)
|
|
|
|
ball[k].pos_x = HALFBALL;
|
|
|
|
else if (ball[k].pos_x > GAMESCREEN_WIDTH - HALFBALL)
|
|
|
|
ball[k].pos_x = GAMESCREEN_WIDTH - HALFBALL;
|
|
|
|
}
|
2008-06-09 20:59:55 +00:00
|
|
|
}
|
2006-03-03 07:24:34 +00:00
|
|
|
}
|
|
|
|
}
|
2010-02-19 07:36:56 +00:00
|
|
|
|
|
|
|
switch(button)
|
2009-10-05 02:13:13 +00:00
|
|
|
{
|
|
|
|
#if defined(HAVE_TOUCHSCREEN)
|
|
|
|
case (BUTTON_REL | BUTTON_TOUCHSCREEN):
|
2008-06-09 20:59:55 +00:00
|
|
|
#endif
|
2006-03-03 07:24:34 +00:00
|
|
|
case UP:
|
|
|
|
case SELECT:
|
2010-02-07 20:19:34 +00:00
|
|
|
#ifdef ALTSELECT
|
|
|
|
case ALTSELECT:
|
|
|
|
#endif
|
2010-02-19 07:36:56 +00:00
|
|
|
if (game_state==ST_READY)
|
2009-10-05 02:13:13 +00:00
|
|
|
{
|
2009-10-03 08:26:19 +00:00
|
|
|
/* Initialize used balls starting speed */
|
2010-02-19 07:36:56 +00:00
|
|
|
for(k=0 ; k < used_balls ; k++)
|
2009-10-05 02:13:13 +00:00
|
|
|
{
|
2009-10-03 08:26:19 +00:00
|
|
|
ball[k].speedy = SPEED_4Q_Y;
|
|
|
|
if(pad_pos_x + (pad_width/2) >= GAMESCREEN_WIDTH/2)
|
|
|
|
{
|
|
|
|
ball[k].speedx = SPEED_4Q_X;
|
2010-02-19 07:36:56 +00:00
|
|
|
}
|
2009-10-03 08:26:19 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
ball[k].speedx = -SPEED_4Q_X;
|
|
|
|
}
|
2006-03-03 07:24:34 +00:00
|
|
|
}
|
2009-08-02 13:45:39 +00:00
|
|
|
game_state=ST_START;
|
|
|
|
}
|
2010-02-19 07:36:56 +00:00
|
|
|
else if (game_state==ST_PAUSE)
|
2009-10-03 08:26:19 +00:00
|
|
|
{
|
2009-08-02 13:45:39 +00:00
|
|
|
game_state=ST_START;
|
2006-03-03 07:24:34 +00:00
|
|
|
}
|
2010-02-26 14:06:34 +00:00
|
|
|
else if (paddle_type == PADDLE_TYPE_STICKY)
|
2009-10-03 08:26:19 +00:00
|
|
|
{
|
2010-02-19 07:36:56 +00:00
|
|
|
for(k=0;k<used_balls;k++)
|
2009-10-03 08:26:19 +00:00
|
|
|
{
|
2006-03-03 07:24:34 +00:00
|
|
|
if (ball[k].glue)
|
2009-10-03 08:26:19 +00:00
|
|
|
{
|
2006-03-03 07:24:34 +00:00
|
|
|
ball[k].glue=false;
|
2009-10-03 08:26:19 +00:00
|
|
|
ball[k].speedy = -ball[k].speedy;
|
|
|
|
}
|
2006-03-03 07:24:34 +00:00
|
|
|
}
|
2009-08-02 13:45:39 +00:00
|
|
|
}
|
2010-02-26 14:06:34 +00:00
|
|
|
else if (paddle_type == PADDLE_TYPE_SHOOTER)
|
2009-10-03 08:26:19 +00:00
|
|
|
{
|
2010-02-19 16:34:18 +00:00
|
|
|
if (used_fires < MAX_FIRES)
|
|
|
|
{
|
|
|
|
fire[used_fires].top = PAD_POS_Y - FIRE_LENGTH;
|
|
|
|
fire[used_fires].x_pos = pad_pos_x + 1; /* Add 1 for edge */
|
|
|
|
used_fires++;
|
|
|
|
}
|
|
|
|
if (used_fires < MAX_FIRES)
|
|
|
|
{
|
|
|
|
fire[used_fires].top = PAD_POS_Y - FIRE_LENGTH;
|
|
|
|
fire[used_fires].x_pos = pad_pos_x + pad_width - 1; /* Sub1 edge*/
|
|
|
|
used_fires++;
|
|
|
|
}
|
2006-03-03 07:24:34 +00:00
|
|
|
}
|
|
|
|
break;
|
2006-06-30 16:43:47 +00:00
|
|
|
#ifdef RC_QUIT
|
|
|
|
case RC_QUIT:
|
|
|
|
#endif
|
2006-03-03 07:24:34 +00:00
|
|
|
case QUIT:
|
2009-08-02 13:45:39 +00:00
|
|
|
resume = true;
|
|
|
|
return 0;
|
2006-03-03 07:24:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
if(rb->default_event_handler(button) == SYS_USB_CONNECTED)
|
|
|
|
return 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2010-02-19 07:36:56 +00:00
|
|
|
else
|
2009-10-03 08:26:19 +00:00
|
|
|
{
|
2007-12-30 14:56:51 +00:00
|
|
|
#ifdef HAVE_LCD_COLOR
|
|
|
|
rb->lcd_bitmap_transparent(brickmania_gameover,
|
2009-10-03 08:26:19 +00:00
|
|
|
(LCD_WIDTH - INT3(GAMEOVER_WIDTH))/2,
|
|
|
|
INT3(GAMESCREEN_HEIGHT - GAMEOVER_HEIGHT)/2,
|
|
|
|
INT3(GAMEOVER_WIDTH),INT3(GAMEOVER_HEIGHT));
|
2007-12-30 14:56:51 +00:00
|
|
|
#else /* greyscale and mono */
|
2009-10-03 08:26:19 +00:00
|
|
|
rb->lcd_bitmap(brickmania_gameover,(LCD_WIDTH -
|
|
|
|
INT3(GAMEOVER_WIDTH))/2,
|
|
|
|
INT3(GAMESCREEN_HEIGHT - GAMEOVER_HEIGHT)/2,
|
|
|
|
INT3(GAMEOVER_WIDTH),INT3(GAMEOVER_HEIGHT) );
|
2006-02-22 10:34:36 +00:00
|
|
|
#endif
|
2007-12-30 14:56:51 +00:00
|
|
|
rb->lcd_update();
|
2009-07-18 23:26:50 +00:00
|
|
|
brickmania_sleep(2);
|
2009-08-02 13:45:39 +00:00
|
|
|
return 0;
|
2006-03-03 07:24:34 +00:00
|
|
|
}
|
2010-02-19 07:36:56 +00:00
|
|
|
|
2009-10-05 02:13:13 +00:00
|
|
|
/* Game always needs to yield for other threads */
|
|
|
|
rb->yield();
|
2010-02-19 07:36:56 +00:00
|
|
|
|
2009-10-05 02:13:13 +00:00
|
|
|
/* Sleep for a bit if there is time to spare */
|
2009-10-18 15:50:30 +00:00
|
|
|
if (TIME_BEFORE(*rb->current_tick, end))
|
2006-01-27 10:02:13 +00:00
|
|
|
rb->sleep(end-*rb->current_tick);
|
2006-01-23 16:00:06 +00:00
|
|
|
}
|
2009-08-02 13:45:39 +00:00
|
|
|
return 0;
|
2006-01-23 16:00:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* this is the plugin entry point */
|
2009-01-16 10:34:40 +00:00
|
|
|
enum plugin_status plugin_start(const void* parameter)
|
2006-01-23 16:00:06 +00:00
|
|
|
{
|
|
|
|
(void)parameter;
|
2009-08-02 13:45:39 +00:00
|
|
|
int last_difficulty;
|
2006-03-03 07:24:34 +00:00
|
|
|
|
2010-02-27 14:45:37 +00:00
|
|
|
highscore_load(SCORE_FILE, highscores, NUM_SCORES);
|
2009-08-02 13:45:39 +00:00
|
|
|
configfile_load(CONFIG_FILE_NAME,config,1,0);
|
|
|
|
last_difficulty = difficulty;
|
2010-02-19 07:36:56 +00:00
|
|
|
|
2009-10-04 19:16:18 +00:00
|
|
|
#ifdef HAVE_TOUCHSCREEN
|
|
|
|
rb->touchscreen_set_mode(TOUCHSCREEN_POINT);
|
|
|
|
#endif
|
2009-08-02 13:45:39 +00:00
|
|
|
|
2006-02-20 18:56:34 +00:00
|
|
|
rb->lcd_setfont(FONT_SYSFIXED);
|
2006-11-15 06:46:35 +00:00
|
|
|
#if LCD_DEPTH > 1
|
|
|
|
rb->lcd_set_backdrop(NULL);
|
|
|
|
#endif
|
2007-08-15 12:42:09 +00:00
|
|
|
/* Turn off backlight timeout */
|
2011-01-24 12:29:16 +00:00
|
|
|
backlight_ignore_timeout();
|
2006-01-23 16:00:06 +00:00
|
|
|
|
|
|
|
/* now go ahead and have fun! */
|
2009-08-02 13:45:39 +00:00
|
|
|
rb->srand( *rb->current_tick );
|
|
|
|
brickmania_loadgame();
|
2009-09-06 14:14:22 +00:00
|
|
|
resume_file = resume;
|
2009-10-04 22:27:42 +00:00
|
|
|
while(!brickmania_game_loop())
|
|
|
|
{
|
|
|
|
if(!resume)
|
|
|
|
{
|
2010-02-27 14:45:37 +00:00
|
|
|
int position = highscore_update(score, level+1, "",
|
|
|
|
highscores, NUM_SCORES);
|
2010-02-19 07:36:56 +00:00
|
|
|
if (position != -1)
|
2009-10-03 08:26:19 +00:00
|
|
|
{
|
2010-02-27 14:45:37 +00:00
|
|
|
if (position == 0)
|
|
|
|
rb->splash(HZ*2, "New High Score");
|
|
|
|
highscore_show(position, highscores, NUM_SCORES, true);
|
2010-02-19 07:36:56 +00:00
|
|
|
}
|
|
|
|
else
|
2009-10-03 08:26:19 +00:00
|
|
|
{
|
2009-08-02 13:45:39 +00:00
|
|
|
brickmania_sleep(3);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-01-23 16:00:06 +00:00
|
|
|
|
2010-02-27 14:45:37 +00:00
|
|
|
highscore_save(SCORE_FILE, highscores, NUM_SCORES);
|
2009-08-02 13:45:39 +00:00
|
|
|
if(last_difficulty != difficulty)
|
|
|
|
configfile_save(CONFIG_FILE_NAME,config,1,0);
|
2006-01-23 17:23:02 +00:00
|
|
|
/* Restore user's original backlight setting */
|
2006-02-20 18:56:34 +00:00
|
|
|
rb->lcd_setfont(FONT_UI);
|
2007-08-15 12:42:09 +00:00
|
|
|
/* Turn on backlight timeout (revert to settings) */
|
2011-01-24 12:29:16 +00:00
|
|
|
backlight_use_settings();
|
2006-01-23 16:00:06 +00:00
|
|
|
|
|
|
|
return PLUGIN_OK;
|
|
|
|
}
|