Stratos: Punto de Encuentro de Desarrolladores

¡Bienvenido a Stratos!

Acceder

Foros





Menu

Mostrar Mensajes

Esta sección te permite ver todos los posts escritos por este usuario. Ten en cuenta que sólo puedes ver los posts escritos en zonas a las que tienes acceso en este momento.

Mostrar Mensajes Menu

Mensajes - Blackuknown

#1
Greetings,

Right now i have a tilemap made with the MS Scrolling Engine. I totally love it. However if i use MoveLayer i have to relocate all the sprites on their corresponding positions each time i use it. This of course will drop my framerate alot if i have some creatures and npcs walking around. So what i really would like to do is instead of moving the layers moving the player around and making some sort of camera that follows him.

For this to be done i need to have the map on a seperate surface which i then will be able to clip and blit to CRM32Pro.screen. I can't get this to work. Whenever i give the map a render target different then CRM32Pro.screen i get nothing but a blackscreen.

The map does work on CRM32Pro.screen.

Here is my map.cpp:


#include "Map.h"

Map::Map(SDL_Surface *target){
  this->target = target;

  SE = new cMSSE;
  SE->Init("Map");
  SE->SetRenderTarget(target);

  tileset = new CRM32Pro_CTile;
  //tileset->Create("tiles.bmp","test");
  tileset->Load(GFX_RESOURCE, "Tileset");
  tileset->SetTileSet(1, 32, 32);

  mapBase = new cMSSE_MapBase(100,100);
  mapBase->SetMapBaseValue(-1,-1,2); // Fill all map with value 1
  mapBase->SetTileSizeX(32);
  mapBase->SetTileSizeY(32);
  if(mapBase->CheckMap() == 0)
  ILogSystem.Msg(LOG_NORMAL," - ManualLoad() has found problems checking the map on layer 0\n");
 
// Assign the map and tileset to layer '0'
   SE->SetLayerMapData(0, mapBase);
   SE->SetLayerTileset(0, tileset);
   // Set the status: execution and autospeed
SE->SetLayerStatus(0,SE_LAYERSTATUS_EXECUTE_SPEED);

// -Layer '1' initialization-
   layer1 = new cMSSE_MapBase(100, 100);
   layer1->SetTileSizeX(32);
   layer1->SetTileSizeY(32);
for(int i = 0; i < 100; i++){
for(int j = 0; j < 100; j++){
layer1->iTilemap[i][j] = 6;
}
}

layer1->iTilemap[50][40] = 20;

   layer1->CheckMap();
 
   SE->SetLayerMapData(1, layer1);
   SE->SetLayerTileset(1, tileset);
   SE->SetLayerStatus(1, SE_LAYERSTATUS_EXECUTE_SPEED);

SE->SetLayerPosition(1,SE_LAYERPOSITION_MIDDLE, SE_LAYERPOSITION_MIDDLE);

SDL_Rect offset;

offset.x = 512 - 10*32;
offset.y = 384 - 8*32;
offset.h = 16*32;
offset.w = 20*32;

SE->SetViewport(&offset);
}

void Map::init(){
 
}

void Map::update(){
SE->Update();
}

void Map::moveLayer(int layer, int x, int y){
SE->MoveLayer(layer, x, y);
}


Here are some relevant pieces of code from my Controller.cpp:


//I dont know any other way to initiate an SDL_Surface if there is one //please tell me.
mapSurface = IImage->Load(GFX_RESOURCE, "background");

map = new Map(mapSurface);

//Game loop
void Controller::Run(){
while(!quit){
calculateFrames();
checkInput();
movePlayer();
//AI routine
drawGame();
updateWindow();
clearMemory();
}

CRM32Pro.Quit();
}

//the drawGame method
void Controller::drawGame(){
       //No clipping yet. Calculated camera clipping should happen here.
SDL_BlitSurface(mapSurface,NULL,CRM32Pro.screen,NULL);
map->update();

SDL_BlitSurface(fps,NULL,CRM32Pro.screen,NULL);
player->draw();
}


What am i doing wrong? or what is missing?

Greetings,

Blackunknown(made a typo while registering)
#2
CRM32Pro / Progress
21 de Abril de 2008, 11:59:36 AM
Of course i'd love it actually.

However how exactly should i do that as i haven't really done this before and don't know what would be a decent way to make a nice overview.

King regards,

Blackuknown
#3
CRM32Pro / Fixed
20 de Abril de 2008, 11:21:49 PM
Thanks to MSSE i got a map up and working.

No more need for a reply.

Sorry about the new post, a little mistake in buttons and my spanish :P.
#4
CRM32Pro / CRM32Pro CTile
18 de Abril de 2008, 02:10:41 PM
Hi there,

I hope its okey to post in english here, because i dont know any spanish. Right now i am trying to make an rpg with CRM32Pro. What i find missing is an example making use of CTile. I have no idea how to make use of a tileset from a DPF and how to create a map out of it, the way it was intended by the developers.

So i was wondering if anyone had a sample for me using CTile and perhaps making a tilemap?

Btw i have seen the other sample, but i can't read the explanation because its spanish. Sadly bablefish messes it up alot and i can't really translate it to readable english.

King regards,

Blackuknown





Stratos es un servicio gratuito, cuyos costes se cubren en parte con la publicidad.
Por favor, desactiva el bloqueador de anuncios en esta web para ayudar a que siga adelante.
Muchísimas gracias.