[FIX] Map drawing based on camera offset.

[FIX] Speech bubble not following camera.
This commit is contained in:
Tamir Atias 2011-12-29 22:10:31 +02:00
parent 3533f5c607
commit 5befe97969
5 changed files with 31 additions and 17 deletions

View File

@ -65,7 +65,7 @@
LinkIncremental="2"
AdditionalLibraryDirectories="..\..\Dependencies\Lib\"
GenerateDebugInformation="true"
SubSystem="2"
SubSystem="1"
TargetMachine="1"
/>
<Tool
@ -166,7 +166,7 @@
/>
<Tool
Name="VCPostBuildEventTool"
CommandLine="copy ..\..\Dependencies\Bin\jpeg.dll ..\..\..\Bin\&#x0D;&#x0A;copy ..\..\Dependencies\Bin\libfreetype-6.dll ..\..\..\Bin\&#x0D;&#x0A;copy ..\..\Dependencies\Bin\libpng12-0.dll ..\..\..\Bin\&#x0D;&#x0A;copy ..\..\Dependencies\Bin\libtiff-3.dll ..\..\..\Bin\&#x0D;&#x0A;copy ..\..\Dependencies\Bin\SDL.dll ..\..\..\Bin\&#x0D;&#x0A;copy ..\..\Dependencies\Bin\SDL_gfx.dll ..\..\..\Bin\&#x0D;&#x0A;copy ..\..\Dependencies\Bin\SDL_image.dll ..\..\..\Bin\&#x0D;&#x0A;copy ..\..\Dependencies\Bin\SDL_ttf.dll ..\..\..\Bin\&#x0D;&#x0A;copy ..\..\Dependencies\Bin\zlib1.dll ..\..\..\Bin\"
CommandLine="copy ..\..\Dependencies\Bin\jpeg.dll ..\..\..\Bin\&#x0D;&#x0A;copy ..\..\Dependencies\Bin\libfreetype-6.dll ..\..\..\Bin\&#x0D;&#x0A;copy ..\..\Dependencies\Bin\libpng12-0.dll ..\..\..\Bin\&#x0D;&#x0A;copy ..\..\Dependencies\Bin\libtiff-3.dll ..\..\..\Bin\&#x0D;&#x0A;copy ..\..\Dependencies\Bin\SDL.dll ..\..\..\Bin\&#x0D;&#x0A;copy ..\..\Dependencies\Bin\SDL_gfx.dll ..\..\..\Bin\&#x0D;&#x0A;copy ..\..\Dependencies\Bin\SDL_image.dll ..\..\..\Bin\&#x0D;&#x0A;copy ..\..\Dependencies\Bin\SDL_ttf.dll ..\..\..\Bin\&#x0D;&#x0A;copy ..\..\Dependencies\Bin\zlib1.dll ..\..\..\Bin\&#x0D;&#x0A;"
/>
</Configuration>
</Configurations>

View File

@ -174,6 +174,7 @@ void Game::UpdateGame(void) {
}
void Game::Render(void) {
// SDL_FillRect(screen, NULL, 0); // You might want to clear the buffer! --konom
if(_ingameMenu.GetStatus() == false) {
_map.Render();

View File

@ -23,7 +23,7 @@
#endif
#endif
#ifndef _WIN32
#if !defined(_WIN32) || defined(_DEBUG)
int main() {
#else
int WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR,int) {

View File

@ -65,18 +65,18 @@ void Character::Render(void) {
// Draw some fancy speach bubbles. It is a bit of a mess, I am playing.
if(_speachBubble.size() != 0) {
if(_speachBubbleTimer.GetTicks() < SPEACH_BUBBLE_DISPLAY_LENGTH) {
roundedBoxRGBA(screen, (x + w / 2) - 100,
y - 100,
(x + w / 2) + 100,
y - 35,
roundedBoxRGBA(screen, (x + w / 2) - 100 - camera.x,
y - 100 - camera.y,
(x + w / 2) + 100 - camera.x,
y - 35 - camera.y,
5, 255, 255, 255, 255);
filledTrigonRGBA(screen, (x + w / 2) - 100,
y - 100,
(x + w / 2) - 10,
y - 40,
(x + w / 2) + 10,
y - 40,
filledTrigonRGBA(screen, (x + w / 2) - 100 - camera.x,
y - 100 - camera.y,
(x + w / 2) - 10 - camera.x,
y - 40 - camera.y,
(x + w / 2) + 10 - camera.x,
y - 40 - camera.y,
255, 255, 255, 255);
_speachBubbleText.Render((x + w / 2) - 90, y - 90);

View File

@ -133,12 +133,16 @@ void Map::Update(void) {
}
void Map::Render(void) {
int xOrig = (camera.x / TILE_WIDTH);
int yOrig = (camera.y / TILE_HEIGHT);
int xOrig = (camera.x / TILE_WIDTH) - 1;
int yOrig = (camera.y / TILE_HEIGHT) - 1;
int xEnd = (SCREEN_WIDTH / TILE_WIDTH);
int yEnd = (SCREEN_HEIGHT / TILE_HEIGHT);
if (xOrig < 0) xOrig = 0;
if (yOrig < 0) yOrig = 0;
int xEnd = xOrig + (SCREEN_WIDTH / TILE_WIDTH) + 3;
int yEnd = yOrig + (SCREEN_HEIGHT / TILE_HEIGHT) + 3;
/* the fuck is this sara? --konom
if(xEnd < x)
xEnd++;
else
@ -148,6 +152,15 @@ void Map::Render(void) {
yEnd++;
else
yEnd = y;
*/
if (xEnd > x) xEnd = x;
if (yEnd > y) yEnd = y;
if (xEnd < 0) xEnd = 0;
if (yEnd < 0) yEnd = 0;
if (xOrig > xEnd) xOrig = xEnd - 1;
if (yOrig > yEnd) yOrig = yEnd - 1;
for(int i = xOrig; i < xEnd; i++) {
for(int j = yOrig; j < yEnd; j++) {