SBSPSS/source/map/map.cpp

608 lines
16 KiB
C++
Raw Normal View History

2001-04-24 18:15:04 +02:00
/*=========================================================================
map.cpp
Author: PKG
Created:
Project: Spongebob
Purpose:
Copyright (c) 2001 Climax Development Ltd
===========================================================================*/
/*----------------------------------------------------------------------
Includes
-------- */
2001-04-24 21:37:12 +02:00
#include "map\map.h"
2001-04-24 18:15:04 +02:00
#ifndef __GFX_FONT_H__
#include "gfx\font.h"
#endif
#ifndef __PAD_PADS_H__
#include "pad\pads.h"
#endif
#ifndef __PRIM_HEADER__
#include "gfx\prim.h"
#endif
2001-04-25 20:15:19 +02:00
#ifndef __GAME_GAME_H__
#include "game\game.h"
2001-04-24 18:15:04 +02:00
#endif
#ifndef __GFX_FADER_H__
#include "gfx\fader.h"
#endif
2001-04-24 21:37:12 +02:00
#ifndef __VID_HEADER_
#include "system\vid.h"
#endif
#ifndef _FILEIO_HEADER_
#include "fileio\fileio.h"
#endif
2001-04-25 01:14:50 +02:00
#ifndef __MATHTABLE_HEADER__
#include "utils\mathtab.h"
#endif
2001-05-09 22:15:01 +02:00
#ifndef __GAME_GAMESLOT_H__
#include "game\gameslot.h"
#endif
2001-06-06 04:11:50 +02:00
#ifndef __SOUND_SOUND_H__
#include "sound\sound.h"
#endif
2001-04-24 18:15:04 +02:00
/* Std Lib
------- */
/* Data
---- */
#ifndef __STRING_ENUMS__
#include <trans.h>
#endif
2001-04-25 01:14:50 +02:00
#ifndef __SPR_SPRITES_H__
#include <sprites.h>
#endif
2001-05-30 16:58:29 +02:00
// Level data include files:
#include <CHAPTER01_LEVEL01_INF.h>
#include <CHAPTER01_LEVEL02_INF.h>
#include <CHAPTER01_LEVEL03_INF.h>
#include <CHAPTER01_LEVEL04_INF.h>
#include <CHAPTER02_LEVEL01_INF.h>
#include <CHAPTER02_LEVEL02_INF.h>
#include <CHAPTER02_LEVEL03_INF.h>
#include <CHAPTER02_LEVEL04_INF.h>
#include <CHAPTER03_LEVEL01_INF.h>
#include <CHAPTER03_LEVEL02_INF.h>
#include <CHAPTER03_LEVEL03_INF.h>
#include <CHAPTER03_LEVEL04_INF.h>
#include <CHAPTER04_LEVEL01_INF.h>
#include <CHAPTER04_LEVEL02_INF.h>
#include <CHAPTER04_LEVEL03_INF.h>
#include <CHAPTER04_LEVEL04_INF.h>
#include <CHAPTER05_LEVEL01_INF.h>
#include <CHAPTER05_LEVEL02_INF.h>
#include <CHAPTER05_LEVEL03_INF.h>
#include <CHAPTER05_LEVEL04_INF.h>
#include <CHAPTER06_LEVEL01_INF.h>
#include <CHAPTER06_LEVEL02_INF.h>
#include <CHAPTER06_LEVEL03_INF.h>
#include <CHAPTER06_LEVEL04_INF.h>
#include <CHAPTER06_LEVEL05_INF.h>
2001-04-24 18:15:04 +02:00
/*----------------------------------------------------------------------
Tyepdefs && Defines
------------------- */
/*----------------------------------------------------------------------
Structure defintions
-------------------- */
/*----------------------------------------------------------------------
Function Prototypes
------------------- */
/*----------------------------------------------------------------------
Vars
---- */
CMapScene MapScene;
2001-05-30 16:58:29 +02:00
CMapScene::sMapLevelData CMapScene::s_mapLevelData[MAP_NUM_CHAPTERS][MAP_NUM_LEVELS_PER_CHAPTER]=
2001-04-25 20:15:19 +02:00
{
2001-05-31 23:17:33 +02:00
// mapFile globalLevelNumber spatulaOrTokenCounts questItemFrame kelpWorldLevel
2001-04-25 20:15:19 +02:00
{
2001-05-30 16:58:29 +02:00
{ MAP_C1_L1_GFX, 0, CHAPTER01_LEVEL01_INF_TOTAL_ITEM_GOLDEN_SPATULA, FRM__C1_L1_QUEST_ITEM, false },
{ MAP_C1_L2_GFX, 1, CHAPTER01_LEVEL02_INF_TOTAL_ITEM_GOLDEN_SPATULA, FRM__C1_L2_QUEST_ITEM, false },
{ MAP_C1_L3_GFX, 2, CHAPTER01_LEVEL03_INF_TOTAL_ITEM_GOLDEN_SPATULA, FRM__C1_L3_QUEST_ITEM, false },
{ MAP_C1_L4_GFX, 3, CHAPTER01_LEVEL04_INF_TOTAL_ITEM_GOLDEN_SPATULA, FRM__C1_L4_QUEST_ITEM, false },
2001-05-31 23:17:33 +02:00
{ MAP_C1_FAIR_GFX, 4, CHAPTER06_LEVEL01_INF_TOTAL_ITEM_KELP_TOKEN, -1, true },
2001-04-25 20:15:19 +02:00
},
{
2001-05-31 23:17:33 +02:00
{ MAP_C2_L1_GFX, 5, CHAPTER02_LEVEL01_INF_TOTAL_ITEM_GOLDEN_SPATULA, FRM__C2_L1_QUEST_ITEM, false },
{ MAP_C2_L2_GFX, 6, CHAPTER02_LEVEL02_INF_TOTAL_ITEM_GOLDEN_SPATULA, FRM__C2_L2_QUEST_ITEM, false },
{ MAP_C2_L3_GFX, 7, CHAPTER02_LEVEL03_INF_TOTAL_ITEM_GOLDEN_SPATULA, FRM__C2_L3_QUEST_ITEM, false },
{ MAP_C2_L4_GFX, 8, CHAPTER02_LEVEL04_INF_TOTAL_ITEM_GOLDEN_SPATULA, FRM__C2_L4_QUEST_ITEM, false },
{ MAP_C2_FAIR_GFX, 9, CHAPTER06_LEVEL02_INF_TOTAL_ITEM_KELP_TOKEN, -1, true },
2001-04-25 20:15:19 +02:00
},
{
2001-05-31 23:17:33 +02:00
{ MAP_C3_L1_GFX, 10, CHAPTER03_LEVEL01_INF_TOTAL_ITEM_GOLDEN_SPATULA, FRM__C3_L1_QUEST_ITEM, false },
{ MAP_C3_L2_GFX, 11, CHAPTER03_LEVEL02_INF_TOTAL_ITEM_GOLDEN_SPATULA, FRM__C3_L2_QUEST_ITEM, false },
{ MAP_C3_L3_GFX, 12, CHAPTER03_LEVEL03_INF_TOTAL_ITEM_GOLDEN_SPATULA, FRM__C3_L3_QUEST_ITEM, false },
{ MAP_C3_L4_GFX, 13, CHAPTER03_LEVEL04_INF_TOTAL_ITEM_GOLDEN_SPATULA, FRM__C3_L4_QUEST_ITEM, false },
{ MAP_C3_FAIR_GFX, 14, CHAPTER06_LEVEL03_INF_TOTAL_ITEM_KELP_TOKEN, -1, true },
2001-04-25 20:15:19 +02:00
},
{
2001-05-31 23:17:33 +02:00
{ MAP_C4_L1_GFX, 15, CHAPTER04_LEVEL01_INF_TOTAL_ITEM_GOLDEN_SPATULA, FRM__C4_QUEST_ITEM_1, false },
{ MAP_C4_L2_GFX, 16, CHAPTER04_LEVEL02_INF_TOTAL_ITEM_GOLDEN_SPATULA, FRM__C4_QUEST_ITEM_1, false },
{ MAP_C4_L3_GFX, 17, CHAPTER04_LEVEL03_INF_TOTAL_ITEM_GOLDEN_SPATULA, FRM__C4_QUEST_ITEM_1, false },
{ MAP_C4_L4_GFX, 18, CHAPTER04_LEVEL04_INF_TOTAL_ITEM_GOLDEN_SPATULA, FRM__C4_QUEST_ITEM_2, false },
{ MAP_C4_FAIR_GFX, 19, CHAPTER06_LEVEL04_INF_TOTAL_ITEM_KELP_TOKEN, -1, true },
2001-04-25 20:15:19 +02:00
},
{
2001-05-31 23:17:33 +02:00
{ MAP_C5_L1_GFX, 20, CHAPTER05_LEVEL01_INF_TOTAL_ITEM_GOLDEN_SPATULA, FRM__C5_L1_QUEST_ITEM, false },
{ MAP_C5_L2_GFX, 21, CHAPTER05_LEVEL02_INF_TOTAL_ITEM_GOLDEN_SPATULA, FRM__C5_L2_QUEST_ITEM, false },
{ MAP_C5_L3_GFX, 22, CHAPTER05_LEVEL03_INF_TOTAL_ITEM_GOLDEN_SPATULA, FRM__C5_L3_QUEST_ITEM, false },
{ MAP_C5_L4_GFX, 23, CHAPTER05_LEVEL04_INF_TOTAL_ITEM_GOLDEN_SPATULA, FRM__C5_L4_QUEST_ITEM, false },
2001-05-30 16:58:29 +02:00
{ MAP_C5_FAIR_GFX, 24, CHAPTER06_LEVEL05_INF_TOTAL_ITEM_KELP_TOKEN, -1, true },
2001-04-25 20:15:19 +02:00
},
};
2001-05-30 16:58:29 +02:00
DVECTOR CMapScene::s_mapLevelPositions[MAP_NUM_LEVELS_PER_CHAPTER]=
{
{ 42,49 },
{ 186,49 },
{ 330,49 },
{ 42,113 },
{ 330,113 },
};
2001-04-25 20:15:19 +02:00
extern int s_globalLevelSelectThing;
2001-04-24 18:15:04 +02:00
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CMapScene::init()
{
2001-04-24 21:37:12 +02:00
m_font=new ("map screen font") FontBank();
2001-04-24 18:15:04 +02:00
m_font->initialise(&standardFont);
2001-04-25 01:14:50 +02:00
m_font->setOt(10);
m_font->setJustification(FontBank::JUST_LEFT);
2001-04-25 20:15:19 +02:00
m_currentChapterSelection=0;
m_currentLevelSelection=0;
2001-04-24 21:37:12 +02:00
m_screenImage=MemAlloc(512*256*2,"MapScreen");
2001-04-25 20:15:19 +02:00
generateMapScreenImage();
2001-04-24 21:37:12 +02:00
SetScreenImage((u8*)m_screenImage);
2001-04-25 01:14:50 +02:00
m_readyToExit=false;
2001-05-17 20:42:59 +02:00
CFader::setFadingIn(CFader::BLACK_FADE);
2001-04-24 18:15:04 +02:00
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CMapScene::shutdown()
{
2001-04-24 21:37:12 +02:00
ClearScreenImage();
MemFree(m_screenImage);
2001-04-24 18:15:04 +02:00
m_font->dump(); delete m_font;
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CMapScene::render()
{
2001-05-31 23:17:33 +02:00
SpriteBank *sb;
2001-05-30 16:58:29 +02:00
sMapLevelData *level;
int i;
char buf[100];
2001-04-25 01:14:50 +02:00
2001-05-31 23:17:33 +02:00
sb=CGameScene::getSpriteBank();
2001-05-30 16:58:29 +02:00
level=&s_mapLevelData[m_currentChapterSelection][0];
// Render spatula/kelp counts and quest items
for(i=0;i<MAP_NUM_LEVELS_PER_CHAPTER;i++)
2001-04-25 01:14:50 +02:00
{
2001-06-12 20:56:40 +02:00
if(isLevelOpen(m_currentChapterSelection,i))
{
DVECTOR pos;
2001-06-01 20:59:33 +02:00
2001-06-12 20:56:40 +02:00
pos=s_mapLevelPositions[i];
2001-05-30 16:58:29 +02:00
2001-06-12 20:56:40 +02:00
if(!level->m_kelpWorldLevel)
2001-04-25 01:14:50 +02:00
{
2001-06-12 20:56:40 +02:00
sFrameHdr *fh;
POLY_FT4 *ft4;
// Normal level
m_font->setColour(253,251,67);
sprintf(buf,"%d/%d",CGameSlotManager::getSlotData()->getSpatulaCollectedCount(m_currentChapterSelection,i),level->m_spatulaOrTokenCounts);
fh=sb->getFrameHeader(level->m_questItemFrame);
ft4=sb->printFT4(fh,pos.vx+MAP_LEVEL_WIDTH-fh->W,pos.vy+MAP_LEVEL_HEIGHT-fh->H,0,0,10);
if(!hasQuestItemBeenCollected(m_currentChapterSelection,i))
{
setRGB0(ft4,50,50,50);
}
}
else
{
// Bonuse level
m_font->setColour(67,251,67);
sprintf(buf,"%d/%d",CGameSlotManager::getSlotData()->getKelpTokenCollectedCount(m_currentChapterSelection,i),level->m_spatulaOrTokenCounts);
2001-04-25 01:14:50 +02:00
}
2001-05-30 16:58:29 +02:00
2001-06-12 20:56:40 +02:00
m_font->print(pos.vx,pos.vy,buf);
}
2001-05-30 16:58:29 +02:00
level++;
2001-04-25 01:14:50 +02:00
}
2001-05-31 23:17:33 +02:00
renderPointer();
renderInstructions();
2001-04-25 20:15:19 +02:00
sprintf(buf,"Chapter %d, Level %d",m_currentChapterSelection+1,m_currentLevelSelection+1);
m_font->setColour(0,255,0);
m_font->print(24,24,buf);
m_font->setColour(0,0,0);
m_font->print(25,25,buf);
2001-04-24 18:15:04 +02:00
}
2001-05-31 23:17:33 +02:00
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CMapScene::renderPointer()
{
SpriteBank *sb;
sFrameHdr *fh;
POLY_FT4 *ft4;
sb=CGameScene::getSpriteBank();
fh=sb->getFrameHeader(FRM__MAPPOINTER);
ft4=sb->printFT4(fh,m_pointerPos.vx-(fh->W/2),m_pointerPos.vy-(fh->H/2),0,0,9);
if(!m_pointerArrivedAtTarget)
{
setSemiTrans(ft4,true);
}
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CMapScene::renderInstructions()
{
// Instructions
2001-06-12 20:56:40 +02:00
int renderChapterControls;
2001-05-31 23:17:33 +02:00
SpriteBank *sb;
sFrameHdr *fh1,*fh2;
int width;
int x,y;
2001-06-12 20:56:40 +02:00
// If only the first chapter is open then you can't select other ones...
renderChapterControls=isChapterOpen(1)?true:false;
2001-05-31 23:17:33 +02:00
sb=CGameScene::getSpriteBank();
m_font->setColour(MAP_INSTRUCTIONS_TEXT_R,MAP_INSTRUCTIONS_TEXT_G,MAP_INSTRUCTIONS_TEXT_B);
y=MAP_INSTRUCTIONS_YSTART;
fh1=sb->getFrameHeader(FRM__BUTL);
fh2=sb->getFrameHeader(FRM__BUTR);
width=fh1->W+MAP_INSTRUCTIONS_GAP_BETWEEN_BUTTONS+fh2->W+MAP_INSTRUCTIONS_GAP_BETWEEN_BUTTONS_AND_TEXT+m_font->getStringWidth(STR__MAP_SCREEN__LEFT_RIGHT_TO_SELECT_LEVEL);
x=256-(width/2);
sb->printFT4(fh1,x,y+MAP_INSTRUCTIONS_BUTTON_Y_OFFSET,0,0,0);
x+=fh1->W+MAP_INSTRUCTIONS_GAP_BETWEEN_BUTTONS;
sb->printFT4(fh2,x,y+MAP_INSTRUCTIONS_BUTTON_Y_OFFSET,0,0,0);
x+=fh2->W+MAP_INSTRUCTIONS_GAP_BETWEEN_BUTTONS_AND_TEXT;
m_font->print(x,y,STR__MAP_SCREEN__LEFT_RIGHT_TO_SELECT_LEVEL);
y+=MAP_INSTRUCTIONS_Y_SPACE_BETWEEN_LINES;
fh1=sb->getFrameHeader(FRM__BUTU);
fh2=sb->getFrameHeader(FRM__BUTD);
width=fh1->W+MAP_INSTRUCTIONS_GAP_BETWEEN_BUTTONS+fh2->W+MAP_INSTRUCTIONS_GAP_BETWEEN_BUTTONS_AND_TEXT+m_font->getStringWidth(STR__MAP_SCREEN__UP_DOWN_TO_SELECT_CHAPTER);
x=256-(width/2);
2001-06-12 20:56:40 +02:00
if(renderChapterControls)
{
sb->printFT4(fh1,x,y+MAP_INSTRUCTIONS_BUTTON_Y_OFFSET,0,0,0);
}
2001-05-31 23:17:33 +02:00
x+=fh1->W+MAP_INSTRUCTIONS_GAP_BETWEEN_BUTTONS;
2001-06-12 20:56:40 +02:00
if(renderChapterControls)
{
sb->printFT4(fh2,x,y+MAP_INSTRUCTIONS_BUTTON_Y_OFFSET,0,0,0);
}
2001-05-31 23:17:33 +02:00
x+=fh2->W+MAP_INSTRUCTIONS_GAP_BETWEEN_BUTTONS_AND_TEXT;
2001-06-12 20:56:40 +02:00
if(renderChapterControls)
{
m_font->print(x,y,STR__MAP_SCREEN__UP_DOWN_TO_SELECT_CHAPTER);
}
2001-05-31 23:17:33 +02:00
y+=MAP_INSTRUCTIONS_Y_SPACE_BETWEEN_LINES;
fh1=sb->getFrameHeader(FRM__BUTX);
width=fh1->W+MAP_INSTRUCTIONS_GAP_BETWEEN_BUTTONS_AND_TEXT+m_font->getStringWidth(STR__MAP_SCREEN__X_TO_START);
x=256-(width/2);
sb->printFT4(fh1,x,y+MAP_INSTRUCTIONS_BUTTON_Y_OFFSET,0,0,0);
x+=fh1->W+MAP_INSTRUCTIONS_GAP_BETWEEN_BUTTONS_AND_TEXT;
m_font->print(x,y,STR__MAP_SCREEN__X_TO_START);
}
2001-04-24 18:15:04 +02:00
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CMapScene::think(int _frames)
{
if(!CFader::isFading()&&!m_readyToExit)
{
2001-06-12 20:56:40 +02:00
int pad=PadGetDown(0);
2001-04-25 20:15:19 +02:00
// Change chapter
2001-06-12 20:56:40 +02:00
if(pad&PAD_UP)
2001-04-25 20:15:19 +02:00
{
2001-06-12 20:56:40 +02:00
int nextChapter=m_currentChapterSelection;
do
{
nextChapter++;
if(nextChapter==MAP_NUM_CHAPTERS)nextChapter=0;
}
while(!isChapterOpen(nextChapter));
if(nextChapter!=m_currentChapterSelection)
{
m_currentChapterSelection=nextChapter;
generateMapScreenImage();
}
2001-04-25 20:15:19 +02:00
}
2001-06-12 20:56:40 +02:00
else if(pad&PAD_DOWN)
2001-04-25 20:15:19 +02:00
{
2001-06-12 20:56:40 +02:00
int nextChapter=m_currentChapterSelection;
do
{
nextChapter--;
if(nextChapter<0)nextChapter=MAP_NUM_CHAPTERS-1;
}
while(!isChapterOpen(nextChapter));
if(nextChapter!=m_currentChapterSelection)
{
m_currentChapterSelection=nextChapter;
generateMapScreenImage();
}
}
#ifdef __VERSION_DEBUG__
else if(pad&PAD_L1)
{
CGameSlotManager::getSlotData()->debugCheatOpenAllLevels();
2001-04-25 20:15:19 +02:00
generateMapScreenImage();
}
2001-06-12 20:56:40 +02:00
#endif
2001-04-25 20:15:19 +02:00
2001-04-25 01:14:50 +02:00
// Move cursor
2001-05-31 23:17:33 +02:00
int lastLevel=m_currentLevelSelection;
2001-06-12 20:56:40 +02:00
if(pad&PAD_LEFT)
2001-04-25 01:14:50 +02:00
{
do
{
2001-05-30 16:58:29 +02:00
if(--m_currentLevelSelection<0)m_currentLevelSelection=MAP_NUM_LEVELS_PER_CHAPTER-1;
2001-04-25 01:14:50 +02:00
}
while(!isLevelOpen(m_currentChapterSelection,m_currentLevelSelection));
}
2001-06-12 20:56:40 +02:00
else if(pad&PAD_RIGHT)
2001-04-25 01:14:50 +02:00
{
do
{
2001-05-30 16:58:29 +02:00
if(++m_currentLevelSelection>=MAP_NUM_LEVELS_PER_CHAPTER)m_currentLevelSelection=0;
2001-04-25 01:14:50 +02:00
}
while(!isLevelOpen(m_currentChapterSelection,m_currentLevelSelection));
}
2001-05-31 23:17:33 +02:00
if(lastLevel!=m_currentLevelSelection)
{
2001-06-06 04:11:50 +02:00
CSoundMediator::playSfx(CSoundMediator::SFX_FRONT_END__MOVE_CURSOR);
2001-05-31 23:17:33 +02:00
m_pointerArrivedAtTarget=false;
m_pointerSin=0;
}
2001-04-25 01:14:50 +02:00
// Calc where the pointer should be
2001-05-31 23:17:33 +02:00
if(m_pointerArrivedAtTarget)
{
m_pointerSin=(m_pointerSin+(_frames*70))&4095;
}
2001-04-25 20:15:19 +02:00
m_pointerTarget=getPointerTargetPosition();
2001-04-25 01:14:50 +02:00
// Move the pointer
for(int i=0;i<_frames;i++)
{
int delta;
delta=m_pointerTarget.vx-m_pointerPos.vx;
if(delta<0)
{
2001-05-31 23:17:33 +02:00
delta/=3;
2001-04-25 01:14:50 +02:00
if(!delta)delta=-1;
}
else if(delta>0)
{
2001-05-31 23:17:33 +02:00
delta/=3;
2001-04-25 01:14:50 +02:00
if(!delta)delta=+1;
}
m_pointerPos.vx+=delta;
2001-05-31 23:17:33 +02:00
delta=(m_pointerTarget.vy+(msin(m_pointerSin)*4>>12))-m_pointerPos.vy;
2001-04-25 01:14:50 +02:00
if(delta<0)
{
2001-05-31 23:17:33 +02:00
delta/=3;
2001-04-25 01:14:50 +02:00
if(!delta)delta=-1;
}
else if(delta>0)
{
2001-05-31 23:17:33 +02:00
delta/=3;
2001-04-25 01:14:50 +02:00
if(!delta)delta=+1;
}
m_pointerPos.vy+=delta;
2001-05-31 23:17:33 +02:00
if(!m_pointerArrivedAtTarget&&
m_pointerTarget.vx==m_pointerPos.vx&&m_pointerTarget.vy==m_pointerPos.vy)
{
m_pointerArrivedAtTarget=true;
}
2001-04-25 01:14:50 +02:00
}
2001-05-31 23:17:33 +02:00
if(m_pointerArrivedAtTarget&&
2001-06-12 20:56:40 +02:00
pad&PAD_CROSS)
2001-04-24 18:15:04 +02:00
{
2001-06-06 04:11:50 +02:00
CSoundMediator::playSfx(CSoundMediator::SFX_FRONT_END__OK);
2001-05-30 16:58:29 +02:00
s_globalLevelSelectThing=s_mapLevelData[m_currentChapterSelection][m_currentLevelSelection].m_globalLevelNumber;
2001-04-24 18:15:04 +02:00
m_readyToExit=true;
2001-04-24 21:37:12 +02:00
// CFader::setFadingOut(CFader::BLACK_FADE);
2001-04-25 20:15:19 +02:00
GameState::setNextScene(&GameScene);
2001-04-24 18:15:04 +02:00
}
}
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
int CMapScene::readyToShutdown()
{
return m_readyToExit&&!CFader::isFading();
}
2001-04-25 20:15:19 +02:00
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CMapScene::generateMapScreenImage()
{
2001-05-30 16:58:29 +02:00
int i;
2001-04-25 20:15:19 +02:00
m_currentLevelSelection=0;
memset(m_screenImage,0,512*256*2);
copyImageToScreen(MAP_MAP_BACKGROUND_GFX,MAP_PARCHMENT_START_X,MAP_PARCHMENT_START_Y,MAP_PARCHMENT_WIDTH,MAP_PARCHMENT_HEIGHT);
2001-05-30 16:58:29 +02:00
for(i=0;i<MAP_NUM_LEVELS_PER_CHAPTER;i++)
2001-04-25 20:15:19 +02:00
{
2001-05-30 16:58:29 +02:00
if(isLevelOpen(m_currentChapterSelection,i))
2001-04-25 20:15:19 +02:00
{
2001-05-30 16:58:29 +02:00
copyImageToScreen(s_mapLevelData[m_currentChapterSelection][i].m_mapFile,s_mapLevelPositions[i].vx,s_mapLevelPositions[i].vy,MAP_LEVEL_WIDTH,MAP_LEVEL_HEIGHT);
2001-04-25 20:15:19 +02:00
}
}
m_pointerPos=getPointerTargetPosition();
2001-05-31 23:17:33 +02:00
m_pointerArrivedAtTarget=true;
2001-04-25 20:15:19 +02:00
}
2001-04-24 21:37:12 +02:00
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CMapScene::copyImageToScreen(int _file,int _x,int _y,int _w,int _h)
{
u8 *image;
u16 *src,*dst;
int x,y;
image=CFileIO::loadFile((FileEquate)_file);ASSERT(image);
src=(u16*)image;
dst=(u16*)m_screenImage+(_x+(_y*512));
for(y=0;y<_h;y++)
{
for(x=0;x<_w;x++)
{
*dst++=*src++;
}
dst+=512-_w;
}
MemFree(image);
}
2001-04-25 20:15:19 +02:00
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
DVECTOR CMapScene::getPointerTargetPosition()
{
DVECTOR pos;
2001-05-30 16:58:29 +02:00
pos=s_mapLevelPositions[m_currentLevelSelection];
pos.vx+=(MAP_LEVEL_WIDTH/2);
2001-05-31 23:17:33 +02:00
pos.vy+=MAP_LEVEL_HEIGHT;//+(msin(m_pointerSin)*4>>12);
2001-05-30 16:58:29 +02:00
2001-04-25 20:15:19 +02:00
return pos;
}
2001-04-25 01:14:50 +02:00
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
2001-05-30 16:58:29 +02:00
int CMapScene::isLevelOpen(unsigned int _chapter,unsigned int _level)
2001-04-25 01:14:50 +02:00
{
2001-06-12 20:56:40 +02:00
return CGameSlotManager::getSlotData()->isLevelOpen(_chapter,_level);
}
int CMapScene::isChapterOpen(unsigned int _chapter)
{
return CGameSlotManager::getSlotData()->isLevelOpen(_chapter,0);
2001-04-25 01:14:50 +02:00
}
2001-05-30 16:58:29 +02:00
int CMapScene::getSpatulaCollectedCount(unsigned int _chapter,unsigned int _level)
2001-04-25 01:14:50 +02:00
{
2001-05-09 22:15:01 +02:00
return CGameSlotManager::getSlotData()->getSpatulaCollectedCount(_chapter,_level);
2001-04-25 01:14:50 +02:00
}
2001-05-30 16:58:29 +02:00
int CMapScene::hasQuestItemBeenCollected(unsigned int _chapter,unsigned int _level)
{
2001-06-12 20:56:40 +02:00
return CGameSlotManager::getSlotData()->hasQustItemBeenCollected(_chapter,_level);
2001-04-25 01:14:50 +02:00
}
2001-04-24 18:15:04 +02:00
/*===========================================================================
end */