28 #include "../idlib/precompiled.h"
31 #include "../framework/Session_local.h"
32 #include "../renderer/Image.h"
39 #define BALL_RADIUS 12.f
40 #define BALL_SPEED 250.f
41 #define BALL_MAXSPEED 450.f
43 #define S_UNIQUE_CHANNEL 6
176 color.
w -= timeslice * 2.5;
235 savefile->
Write( &
x,
sizeof(
x) );
236 savefile->
Write( &
y,
sizeof(
y) );
244 savefile->
Write( &index,
sizeof(index) );
253 savefile->
Read( &
x,
sizeof(
x) );
254 savefile->
Read( &
y,
sizeof(
y) );
262 savefile->
Read( &index,
sizeof(index) );
300 if ( vel.
y < 0 && pos.
y > ptA.
y ) {
301 if( pos.
x > ptA.
x && pos.
x < ptB.
x ) {
302 dist = pos.
y - ptA.
y;
308 if ( pos.
x <= ptA.
x ) {
325 if ( vel.
y > 0 && pos.
y < ptA.
y ) {
326 if( pos.
x > ptA.
x && pos.
x < ptB.
x ) {
327 dist = ptA.
y - pos.
y;
333 if ( pos.
x <= ptA.
x ) {
353 if ( vel.
x > 0 && pos.
x < ptA.
x ) {
354 if( pos.
y > ptA.
y && pos.
y < ptB.
y ) {
355 dist = ptA.
x - pos.
x;
361 if ( pos.
y <= ptA.
y ) {
378 if ( vel.
x < 0 && pos.
x > ptA.
x ) {
379 if( pos.
y > ptA.
y && pos.
y < ptB.
y ) {
380 dist = pos.
x - ptA.
x;
386 if ( pos.
y <= ptA.
y ) {
465 savefile->
Write( &numberOfEnts,
sizeof(numberOfEnts) );
466 for ( i=0; i<numberOfEnts; i++ ) {
467 entities[
i]->WriteToSaveGame( savefile );
472 savefile->
Write( &numberOfEnts,
sizeof(numberOfEnts) );
473 for ( i=0; i<numberOfEnts; i++ ) {
475 savefile->
Write( &ballIndex,
sizeof(ballIndex) );
480 savefile->
Write( &numberOfEnts,
sizeof(numberOfEnts) );
481 for ( i=0; i<numberOfEnts; i++ ) {
483 savefile->
Write( &powerIndex,
sizeof(powerIndex) );
493 savefile->
Write( &numberOfEnts,
sizeof(numberOfEnts) );
494 for ( i=0; i<numberOfEnts; i++ ) {
495 board[
row][
i]->WriteToSaveGame( savefile );
543 savefile->
Read( &numberOfEnts,
sizeof(numberOfEnts) );
544 for ( i=0; i<numberOfEnts; i++ ) {
553 savefile->
Read( &numberOfEnts,
sizeof(numberOfEnts) );
554 for ( i=0; i<numberOfEnts; i++ ) {
556 savefile->
Read( &ballIndex,
sizeof(ballIndex) );
561 savefile->
Read( &numberOfEnts,
sizeof(numberOfEnts) );
562 for ( i=0; i<numberOfEnts; i++ ) {
564 savefile->
Read( &powerIndex,
sizeof(powerIndex) );
575 savefile->
Read( &numberOfEnts,
sizeof(numberOfEnts) );
576 for ( i=0; i<numberOfEnts; i++ ) {
653 int key =
event->evValue;
734 }
else if (
idStr::Icmp(_name,
"onContinue") == 0 ) {
736 }
else if (
idStr::Icmp(_name,
"onNewGame") == 0 ) {
738 }
else if (
idStr::Icmp(_name,
"onNewLevel") == 0 ) {
862 balls[0]->removed =
true;
885 boardSize = 9 * 12 * 4;
892 idStr name =
"guis/assets/bustout/level";
899 if ( w != 9 || h != 12 ) {
900 common->
DWarning(
"Hell Bust-Out level image not correct dimensions! (%d x %d)", w, h );
903 memcpy( currentBoard, pic, boardSize );
907 currentBoard += boardSize;
925 float stepx = 619.f / 9.f;
926 float stepy = ( 256 / 12.f );
928 boardSize = 9 * 12 * 4;
934 for ( i=0; i<9; i++ ) {
935 int pixelindex = (j*9*4) + (i*4);
937 if ( currentBoard[pixelindex + 3] ) {
944 bcolor.
x = currentBoard[pixelindex + 0] / 255.f;
945 bcolor.
y = currentBoard[pixelindex + 1] / 255.f;
946 bcolor.
z = currentBoard[pixelindex + 2] / 255.f;
950 pType = currentBoard[pixelindex + 3] / 255.f;
951 if ( pType > 0.
f && pType < 1.
f ) {
952 if ( pType < 0.5
f ) {
1010 powerEnt->
SetMaterial(
"game/bustout/powerup_bigpaddle" );
1013 powerEnt->
SetMaterial(
"game/bustout/powerup_multiball" );
1016 powerEnt->
SetMaterial(
"textures/common/nodraw" );
1020 powerEnt->
SetSize( 619/9, 256/12 );
1063 for (
int b=0;
b<2;
b++ ) {
1128 bool playSoundBounce =
false;
1129 bool playSoundBrick =
false;
1130 static int bounceChannel = 1;
1136 for ( ballnum = 0; ballnum <
balls.
Num(); ballnum++ ) {
1154 playSoundBounce =
true;
1159 playSoundBounce =
true;
1162 playSoundBounce =
true;
1182 paddleVec.
x += (ball->
position.
x - centerX) * 2;
1188 playSoundBounce =
true;
1193 playSoundBounce =
true;
1203 for ( j=0; j<
num; j++ ) {
1230 playSoundBrick =
true;
1241 if ( playSoundBounce ) {
1243 }
else if ( playSoundBrick ) {
1247 if ( playSoundBounce || playSoundBrick ) {
1249 if ( bounceChannel == 4 ) {
1256 for ( ballnum=0; ballnum<
balls.
Num(); ballnum++ ) {
1257 if (
balls[ballnum]->removed ) {
virtual void ReadFromSaveGame(idFile *savefile, idGameBustOutWindow *game)
virtual void SetStateString(const char *varName, const char *value)
idList< BOBrick * > board[BOARD_ROWS]
virtual const idSoundShader * FindSound(const char *name, bool makeDefault=true)=0
virtual const char * Activate(bool activate)
virtual void WriteToSaveGame(idFile *savefile)
virtual bool ParseInternalVar(const char *name, idParser *src)
virtual void Draw(int time, float x, float y)
virtual void PlayShaderDirectly(const char *name, int channel=-1)=0
virtual void ReadFromSaveGame(idFile *savefile)
void R_LoadImage(const char *name, byte **pic, int *width, int *height, ID_TIME_T *timestamp, bool makePowerOf2)
virtual bool ParseInternalVar(const char *name, idParser *src)
float NormalizeFast(void)
void SetVisible(bool isVisible)
virtual void WriteToSaveGame(idFile *savefile)
virtual const idMaterial * FindMaterial(const char *name, bool makeDefault=true)=0
idList< BOEntity * > balls
int Icmp(const char *text) const
virtual void WriteToSaveGame(idFile *savefile)
virtual void Draw(idDeviceContext *dc)
void SetColor(idVec4 bcolor)
void DrawMaterialRotated(float x, float y, float w, float h, const idMaterial *mat, const idVec4 &color, float scalex=1.0, float scaley=1.0, float angle=0.0f)
float LengthFast(void) const
virtual void WriteToSaveGame(idFile *savefile)
void SetMaterial(const char *name)
GLubyte GLubyte GLubyte GLubyte w
static float Fabs(float f)
virtual void virtual void virtual void DWarning(const char *fmt,...) id_attribute((format(printf
virtual void WriteToSaveGame(idFile *savefile)
virtual int Read(void *buffer, int len)
virtual void ReadFromSaveGame(idFile *savefile, idGameBustOutWindow *_game)
void DeleteContents(bool clear)
idList< BOEntity * > powerUps
virtual void ReadFromSaveGame(idFile *savefile)
GLubyte GLubyte GLubyte a
void ReadSaveGameString(idStr &string, idFile *savefile)
void WriteSaveGameString(const char *string, idFile *savefile)
GLenum GLsizei GLsizei height
idList< BOEntity * > entities
idDeclManager * declManager
const idMaterial * material
collideDir_t checkCollision(idVec2 pos, idVec2 vel)
void SetColor(float r, float g, float b, float a)
idGameBustOutWindow * game
int Append(const type &obj)
GLdouble GLdouble GLdouble r
GLenum GLenum GLvoid * row
idUserInterfaceLocal * gui
void SetSize(float _width, float _height)
bool RemoveIndex(int index)
virtual int Write(const void *buffer, int len)
idGameBustOutWindow(idUserInterfaceLocal *gui)
void SetSort(float s) const
BOEntity(idGameBustOutWindow *_game)
int FindIndex(const type &obj) const
void * Mem_Alloc(const int size)
virtual idWinVar * GetWinVarByName(const char *_name, bool winLookup=false, drawWin_t **owner=NULL)
BOEntity * CreatePowerup(BOBrick *brick)
char * va(const char *fmt,...)
virtual const char * HandleEvent(const sysEvent_t *event, bool *updateVisuals)
virtual void HandleNamedEvent(const char *namedEvent)
virtual void Update(float timeslice, int guiTime)
virtual idWinVar * GetWinVarByName(const char *_name, bool winLookup=false, drawWin_t **owner=NULL)
BOEntity * CreateNewBall()
bool Remove(const type &obj)
virtual void ReadFromSaveGame(idFile *savefile)
virtual const char * HandleEvent(const sysEvent_t *event, bool *updateVisuals)