added fading
This commit is contained in:
parent
afc7f80ae9
commit
a7f62c01a5
6 changed files with 333 additions and 12 deletions
1
Makefile
1
Makefile
|
@ -25,6 +25,7 @@ SOURCES = \
|
|||
Draw \
|
||||
Ending \
|
||||
Escape \
|
||||
Fade \
|
||||
Flags \
|
||||
Game \
|
||||
Generic \
|
||||
|
|
|
@ -11,17 +11,17 @@ int Call_Escape()
|
|||
//Get pressed keys
|
||||
GetTrg();
|
||||
|
||||
if (gKeyTrg & 0x8000) //Escape is pressed, quit game
|
||||
if (gKeyTrg & KEY_ESCAPE) //Escape is pressed, quit game
|
||||
{
|
||||
gKeyTrg = 0;
|
||||
return 0;
|
||||
}
|
||||
if (gKeyTrg & 0x400) //F1 is pressed, continue
|
||||
if (gKeyTrg & KEY_F1) //F1 is pressed, continue
|
||||
{
|
||||
gKeyTrg = 0;
|
||||
return 1;
|
||||
}
|
||||
if (gKeyTrg & 0x800) //F2 is pressed, reset
|
||||
if (gKeyTrg & KEY_F2) //F2 is pressed, reset
|
||||
{
|
||||
gKeyTrg = 0;
|
||||
return 2;
|
||||
|
|
295
src/Fade.cpp
Normal file
295
src/Fade.cpp
Normal file
|
@ -0,0 +1,295 @@
|
|||
#include <string>
|
||||
|
||||
#include "WindowsWrapper.h"
|
||||
|
||||
#include "Fade.h"
|
||||
#include "Game.h"
|
||||
#include "Draw.h"
|
||||
|
||||
FADE gFade;
|
||||
|
||||
void InitFade()
|
||||
{
|
||||
memset(&gFade, 0, sizeof(FADE));
|
||||
}
|
||||
|
||||
void SetFadeMask()
|
||||
{
|
||||
gFade.bMask = true;
|
||||
}
|
||||
|
||||
void ClearFade()
|
||||
{
|
||||
gFade.bMask = false;
|
||||
gFade.mode = 0;
|
||||
}
|
||||
|
||||
void StartFadeOut(char dir)
|
||||
{
|
||||
gFade.mode = 2;
|
||||
gFade.count = 0;
|
||||
gFade.dir = dir;
|
||||
gFade.bMask = false;
|
||||
|
||||
for (int y = 0; y < FADE_HEIGHT; y++)
|
||||
{
|
||||
for (int x = 0; x < FADE_WIDTH; x++)
|
||||
{
|
||||
gFade.ani_no[y][x] = 0;
|
||||
gFade.flag[y][x] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void StartFadeIn(char dir)
|
||||
{
|
||||
gFade.mode = 1;
|
||||
gFade.count = 0;
|
||||
gFade.dir = dir;
|
||||
gFade.bMask = true;
|
||||
|
||||
for (int y = 0; y < FADE_HEIGHT; y++)
|
||||
{
|
||||
for (int x = 0; x < FADE_WIDTH; x++)
|
||||
{
|
||||
gFade.ani_no[y][x] = 15;
|
||||
gFade.flag[y][x] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ProcFade()
|
||||
{
|
||||
if (gFade.mode == 1)
|
||||
{
|
||||
gFade.bMask = false;
|
||||
|
||||
switch (gFade.dir)
|
||||
{
|
||||
case 0:
|
||||
for (int y = 0; y < FADE_HEIGHT; y++)
|
||||
{
|
||||
for (int x = 0; x <= FADE_WIDTH; x++)
|
||||
{
|
||||
if ((FADE_WIDTH - 1) - gFade.count == x)
|
||||
gFade.flag[y][x] = 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
for (int y = 0; y < FADE_HEIGHT; y++)
|
||||
{
|
||||
for (int x = 0; x < FADE_WIDTH; x++)
|
||||
{
|
||||
if ((FADE_HEIGHT - 1) - gFade.count == y)
|
||||
gFade.flag[y][x] = 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
for (int y = 0; y < FADE_HEIGHT; y++)
|
||||
{
|
||||
for (int x = 0; x < FADE_WIDTH; x++)
|
||||
{
|
||||
if (gFade.count == x)
|
||||
gFade.flag[y][x] = 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 3:
|
||||
for (int y = 0; y < FADE_HEIGHT; y++)
|
||||
{
|
||||
for (int x = 0; x < FADE_WIDTH; x++)
|
||||
{
|
||||
if (gFade.count == y)
|
||||
gFade.flag[y][x] = 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 4:
|
||||
for (int y = 0; y < (FADE_HEIGHT / 2); y++)
|
||||
{
|
||||
for (int x = 0; x < (FADE_WIDTH / 2); x++)
|
||||
{
|
||||
if ((FADE_WIDTH - 1) - gFade.count == x + y)
|
||||
gFade.flag[y][x] = 1;
|
||||
}
|
||||
}
|
||||
for (int y = 0; y < (FADE_HEIGHT / 2); y++)
|
||||
{
|
||||
for (int x = (FADE_WIDTH / 2); x < FADE_WIDTH; x++)
|
||||
{
|
||||
if ((FADE_WIDTH - 1) - gFade.count == y + ((FADE_WIDTH - 1) - x))
|
||||
gFade.flag[y][x] = 1;
|
||||
}
|
||||
}
|
||||
for (int y = (FADE_HEIGHT / 2); y < FADE_HEIGHT; y++)
|
||||
{
|
||||
for (int x = 0; x < (FADE_WIDTH / 2); x++)
|
||||
{
|
||||
if ((FADE_WIDTH - 1) - gFade.count == x + ((FADE_HEIGHT - 1) - y))
|
||||
gFade.flag[y][x] = 1;
|
||||
}
|
||||
}
|
||||
for (int y = (FADE_HEIGHT / 2); y < FADE_HEIGHT; y++)
|
||||
{
|
||||
for (int x = (FADE_WIDTH / 2); x < FADE_WIDTH; x++)
|
||||
{
|
||||
if ((FADE_WIDTH - 1) - gFade.count == ((FADE_WIDTH - 1) - x) + ((FADE_HEIGHT - 1) - y))
|
||||
gFade.flag[y][x] = 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
for (int y = 0; y < FADE_HEIGHT; y++)
|
||||
{
|
||||
for (int x = 0; x < FADE_WIDTH; x++)
|
||||
{
|
||||
if (gFade.ani_no[y][x] > 0 && gFade.flag[y][x])
|
||||
--gFade.ani_no[y][x];
|
||||
}
|
||||
}
|
||||
|
||||
if (++gFade.count > ((FADE_WIDTH > FADE_HEIGHT) ? FADE_WIDTH : FADE_HEIGHT) + 16)
|
||||
gFade.mode = 0;
|
||||
}
|
||||
else if (gFade.mode == 2)
|
||||
{
|
||||
switch (gFade.dir)
|
||||
{
|
||||
case 0:
|
||||
for (int y = 0; y < FADE_HEIGHT; y++)
|
||||
{
|
||||
for (int x = 0; x <= FADE_WIDTH; x++)
|
||||
{
|
||||
if ((FADE_WIDTH - 1) - gFade.count == x)
|
||||
gFade.flag[y][x] = 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
for (int y = 0; y < FADE_HEIGHT; y++)
|
||||
{
|
||||
for (int x = 0; x < FADE_WIDTH; x++)
|
||||
{
|
||||
if ((FADE_HEIGHT - 1) - gFade.count == y)
|
||||
gFade.flag[y][x] = 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
for (int y = 0; y < FADE_HEIGHT; y++)
|
||||
{
|
||||
for (int x = 0; x < FADE_WIDTH; x++)
|
||||
{
|
||||
if (gFade.count == x)
|
||||
gFade.flag[y][x] = 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 3:
|
||||
for (int y = 0; y < FADE_HEIGHT; y++)
|
||||
{
|
||||
for (int x = 0; x < FADE_WIDTH; x++)
|
||||
{
|
||||
if (gFade.count == y)
|
||||
gFade.flag[y][x] = 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 4:
|
||||
for (int y = 0; y < (FADE_HEIGHT / 2); y++)
|
||||
{
|
||||
for (int x = 0; x < (FADE_WIDTH / 2); x++)
|
||||
{
|
||||
if (gFade.count == x + y)
|
||||
gFade.flag[y][x] = 1;
|
||||
}
|
||||
}
|
||||
for (int y = 0; y < (FADE_HEIGHT / 2); y++)
|
||||
{
|
||||
for (int x = (FADE_WIDTH / 2); x < FADE_WIDTH; x++)
|
||||
{
|
||||
if (gFade.count == y + ((FADE_WIDTH - 1) - x))
|
||||
gFade.flag[y][x] = 1;
|
||||
}
|
||||
}
|
||||
for (int y = (FADE_HEIGHT / 2); y < FADE_HEIGHT; y++)
|
||||
{
|
||||
for (int x = 0; x < (FADE_WIDTH / 2); x++)
|
||||
{
|
||||
if (gFade.count == x + ((FADE_HEIGHT - 1) - y))
|
||||
gFade.flag[y][x] = 1;
|
||||
}
|
||||
}
|
||||
for (int y = (FADE_HEIGHT / 2); y < FADE_HEIGHT; y++)
|
||||
{
|
||||
for (int x = (FADE_WIDTH / 2); x < FADE_WIDTH; x++)
|
||||
{
|
||||
if (gFade.count == ((FADE_WIDTH - 1) - x) + ((FADE_HEIGHT - 1) - y))
|
||||
gFade.flag[y][x] = 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
for (int y = 0; y < FADE_HEIGHT; y++)
|
||||
{
|
||||
for (int x = 0; x < FADE_WIDTH; x++)
|
||||
{
|
||||
if (gFade.ani_no[y][x] < 15 && gFade.flag[y][x])
|
||||
++gFade.ani_no[y][x];
|
||||
}
|
||||
}
|
||||
|
||||
if (++gFade.count > ((FADE_WIDTH > FADE_HEIGHT) ? FADE_WIDTH : FADE_HEIGHT) + 16)
|
||||
{
|
||||
gFade.bMask = true;
|
||||
gFade.mode = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PutFade()
|
||||
{
|
||||
RECT rect;
|
||||
rect.top = 0;
|
||||
rect.bottom = 16;
|
||||
|
||||
if (gFade.bMask)
|
||||
{
|
||||
CortBox(&grcGame, 0x000020);
|
||||
}
|
||||
else if (gFade.mode)
|
||||
{
|
||||
for (int y = 0; y < FADE_HEIGHT; y++)
|
||||
{
|
||||
for (int x = 0; x < FADE_WIDTH; x++)
|
||||
{
|
||||
rect.left = 16 * gFade.ani_no[y][x];
|
||||
rect.right = rect.left + 16;
|
||||
PutBitmap3(&grcGame, 16 * x, 16 * y, &rect, 6);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool GetFadeActive()
|
||||
{
|
||||
return gFade.mode != 0;
|
||||
}
|
24
src/Fade.h
Normal file
24
src/Fade.h
Normal file
|
@ -0,0 +1,24 @@
|
|||
#pragma once
|
||||
#include "CommonDefines.h"
|
||||
|
||||
#define FADE_WIDTH (((WINDOW_WIDTH - 1) >> 4) + 1)
|
||||
#define FADE_HEIGHT (((WINDOW_HEIGHT - 1) >> 4) + 1)
|
||||
|
||||
struct FADE
|
||||
{
|
||||
int mode;
|
||||
bool bMask;
|
||||
int count;
|
||||
char ani_no[FADE_HEIGHT][FADE_WIDTH];
|
||||
char flag[FADE_HEIGHT][FADE_WIDTH];
|
||||
char dir;
|
||||
};
|
||||
|
||||
void InitFade();
|
||||
void SetFadeMask();
|
||||
void ClearFade();
|
||||
void StartFadeOut(char dir);
|
||||
void StartFadeIn(char dir);
|
||||
void ProcFade();
|
||||
void PutFade();
|
||||
bool GetFadeActive();
|
17
src/Game.cpp
17
src/Game.cpp
|
@ -9,6 +9,7 @@
|
|||
#include "Generic.h"
|
||||
#include "GenericLoad.h"
|
||||
#include "TextScr.h"
|
||||
#include "Fade.h"
|
||||
#include "Flags.h"
|
||||
#include "Escape.h"
|
||||
#include "Stage.h"
|
||||
|
@ -85,13 +86,13 @@ int ModeOpening()
|
|||
//InitNpChar();
|
||||
//InitCaret();
|
||||
//InitStar();
|
||||
//InitFade();
|
||||
InitFade();
|
||||
//InitFlash();
|
||||
//InitBossLife();
|
||||
ChangeMusic(0);
|
||||
TransferStage(72, 100, 3, 3);
|
||||
//SetFrameTargetMyChar(16);
|
||||
//SetFadeMask();
|
||||
SetFadeMask();
|
||||
|
||||
//Reset cliprect and flags
|
||||
grcGame.left = 0;
|
||||
|
@ -109,7 +110,7 @@ int ModeOpening()
|
|||
GetTrg();
|
||||
|
||||
//Escape menu
|
||||
if (gKey & 0x8000)
|
||||
if (gKey & KEY_ESCAPE)
|
||||
{
|
||||
int escRet = Call_Escape();
|
||||
if (escRet == 0)
|
||||
|
@ -119,7 +120,7 @@ int ModeOpening()
|
|||
}
|
||||
|
||||
//Skip intro if OK is pressed
|
||||
if ( gKey & gKeyOk )
|
||||
if (gKey & gKeyOk)
|
||||
break;
|
||||
|
||||
//Update everything
|
||||
|
@ -135,7 +136,7 @@ int ModeOpening()
|
|||
//HitBossBullet();
|
||||
//ActCaret();
|
||||
//MoveFrame3();
|
||||
//ProcFade();
|
||||
ProcFade();
|
||||
|
||||
//Draw everything
|
||||
CortBox(&grcFull, 0x000000);
|
||||
|
@ -151,7 +152,7 @@ int ModeOpening()
|
|||
PutStage_Front(frame_x, frame_y);
|
||||
//PutFront(frame_x, frame_y);
|
||||
//PutCaret(frame_x, frame_y);
|
||||
//PutFade();
|
||||
PutFade();
|
||||
|
||||
//Update Text Script
|
||||
//int tscRet = TextScriptProc();
|
||||
|
@ -159,7 +160,7 @@ int ModeOpening()
|
|||
// return 0;
|
||||
//if (tscRet == 2)
|
||||
// return 1;
|
||||
|
||||
|
||||
PutMapName(false);
|
||||
//PutTextScript();
|
||||
//PutFramePerSecound();
|
||||
|
@ -299,7 +300,7 @@ int ModeTitle()
|
|||
break;
|
||||
}
|
||||
|
||||
if (gKey & 0x8000)
|
||||
if (gKey & KEY_ESCAPE)
|
||||
{
|
||||
int escRet = Call_Escape();
|
||||
if (escRet == 0)
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include "PixTone.h"
|
||||
|
||||
#define FREQUENCY 44100
|
||||
#define STREAM_SIZE (FREQUENCY / 100)
|
||||
#define STREAM_SIZE (FREQUENCY / 200)
|
||||
|
||||
#define clamp(x, y, z) ((x > z) ? z : (x < y) ? y : x)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue