This is my main
Code: Select all
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(lib, "Irrlicht.lib")
#endif
#include <irrlicht.h>
#include <iostream>
#include <driverChoice.h>
#include <IImage.h>
#include <SColor.h>
#include <IVideoDriver.h>
#include "MyEventReceiver.h"
#include "c_Player.h"
#include "Gamescreens.h"
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
core::vector3df CameraLookAt;
core::vector3df CameraPos;
MyEventReceiver receiver;
c_Player player;
int lastFPS = -1;
const f32 MOVEMENT_SPEED = 15.f;
int inmenu =1;
int main(int argc, char** argv)
{
IrrlichtDevice *device =
createDevice(EDT_OPENGL, dimension2d<u32>(1280, 720), 16,false, false, false, &receiver);
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();
guienv->addStaticText(L"Outer Space 2d! ",
rect<int>(10,10,200,22), true);
//driver->setFog(video::SColor(255,255,255,255),EFT_FOG_LINEAR , 5, 1, 0.01f, false,false);
scene::IAnimatedMeshSceneNode* Tile[64][64];
video::IImage* TileMapImage = driver->createImageFromFile("res/tiletest.png");
for(int h = 0 ; h < 64; h ++ )
{
for(int w = 0; w < 64 ; w ++ )
{
video::SColor PixelColor = TileMapImage->getPixel(h,w);
if (PixelColor == video::SColor(255,255,0,0) )
{
printf("found red\n");
Tile[h][w] = smgr->addAnimatedMeshSceneNode(smgr->getMesh("res/walltile_1_180.X"));
printf("tile loaded\n");
Tile[h][w]->setPosition(core::vector3df(h*3,0,w*3));
Tile[h][w]->setMaterialFlag(EMF_LIGHTING,false);
}
if (PixelColor == video::SColor(255,255,255,255) )
{
printf("found white\n");
Tile[h][w] = smgr->addAnimatedMeshSceneNode(smgr->getMesh("res/floortile_1.X"));
printf("tile loaded\n");
Tile[h][w]->setPosition(core::vector3df(h*3,0,w*3-3));
Tile[h][w]->setMaterialFlag(EMF_LIGHTING,false);
}
if (PixelColor == video::SColor(255,255,150,0) )
{
printf("found orange\n");
Tile[h][w] = smgr->addAnimatedMeshSceneNode(smgr->getMesh("res/dungeondoor_1_180.X"));
printf("tile loaded\n");
Tile[h][w]->setPosition(core::vector3df(h*3,0,w*3));
Tile[h][w]->setMaterialFlag(EMF_LIGHTING,false);
}
}
}
CameraLookAt = vector3df(0,2,0);
CameraPos = vector3df(0,2,10);
while(device->run())
{
do{
TitelScreen(driver,smgr);
if(receiver.IsKeyDown(irr::KEY_RETURN))
{
inmenu = 0;
printf("Enter\n");
}
}while(inmenu==1);
//core::vector3df nodePosition = node->getPosition();
ICameraSceneNode * MainCam = smgr->addCameraSceneNode(0,CameraPos, CameraLookAt);
MainCam ->setFarValue(40.f);
player.Handle();
// drawing of the scene
//driver->beginScene(true, true, video::SColor(255,113,113,133));
//smgr->drawAll(); // draw the 3d scene
// hier staat de nieuwe image draw
//driver->endScene();
int fps = driver->getFPS();
if (lastFPS != fps)
{
core::stringw tmp(L"Movement Example - Irrlicht Engine [");
tmp += driver->getName();
tmp += L"] fps: ";
tmp += fps;
device->setWindowCaption(tmp.c_str());
lastFPS = fps;
}
}
device->drop();
return 0;
}
Code: Select all
void TitelScreen(IVideoDriver* menudriver,ISceneManager* menusmgr){
printf("Crash\n");
video::ITexture* menu = menudriver->getTexture("Screens/menu.png");
printf("Crash2\n");
menudriver->beginScene(true, true, video::SColor(255,113,113,133));
menudriver->makeColorKeyTexture(menu, core::position2d<s32>(0,0));
menusmgr->drawAll();
menudriver->draw2DImage(menu, core::position2d<s32>(0,0));
menudriver->endScene();
}