Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
#include <TriBase.h> #include <windows.h> #include "Menu.h" class Menu; enum GameState { GS_NONE, GS_INTRO, GS_MENU, GS_OPTION, GS_NORMALMP }; class VierGewinnt { public: Menu* menu; GameState gState; PDIRECT3DSTATEBLOCK9 StateBlock; tbConfig config; float fTime; tbResult Init(); tbResult SetGameState(GameState state); tbResult Load(); tbResult Unload(); tbResult Run(); }; extern VierGewinnt* vG; |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
#include "VierGewinnt.h" VierGewinnt* vG = NULL; int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, char* pcCommandLine, int iShowCommand) { vG = new VierGewinnt; vG->Init(); vG->Run(); } tbResult VierGewinnt::Init() { tbInit(); tbDoConfigDialog(&config); tbDirect3D::Instance().Init(&config, "4 gewinnt", NULL, NULL); menu = new Menu; return TB_OK; } tbResult VierGewinnt::Load() { menu->Load(); tbDirect3D::Instance()->CreateStateBlock(D3DSBT_ALL, &StateBlock); return TB_OK; } tbResult VierGewinnt::Unload() { SetGameState(GS_NONE); TB_SAFE_DELETE(menu); menu->Unload(); return TB_OK; } tbResult VierGewinnt::SetGameState(GameState State) { gState = State; switch(State) { case GS_MENU: menu->Init(); break; } return TB_OK; } tbResult VierGewinnt::Run() { Load(); SetGameState(GS_MENU); tbDelay(1400); Unload(); tbExit(); tbDirect3D::Instance().Exit(); return TB_OK; } |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
#include <TriBase.h> class VierGewinnt; class Menu { public: int isToken; LPDIRECT3DTEXTURE9 texture; inline Menu() {ZeroMemory(this, sizeof(Menu));} tbResult Init(); tbResult Load(); tbResult Unload(); tbResult Input(); tbResult Render(); }; |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
#include "Menu.h" struct Vertex { tbVector3 pos; float fRHW; D3DCOLOR color; tbVector2 texcoord; static const DWORD dwFVF; }; const DWORD Vertex::dwFVF = D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1; tbResult Menu::Init() { Load(); Render(); return TB_OK; } tbResult Menu::Load() { texture = tbTextureManager::Instance().GetTexture("C:\\...\\titel.jpg"); if(texture == NULL) { TB_ERROR("Fehler beim Laden der Textur!", TB_ERROR); } return TB_OK; } tbResult Menu::Unload() { //tbTextureManager::Instance().ReleaseTexture(texture); tbDirect3D::Instance().Exit(); return TB_OK; } tbResult Menu::Input() { return TB_OK; } tbResult Menu::Render() { Vertex vertizes[4]; tbDirect3D& D3D = tbDirect3D::Instance(); D3D->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, tbColor(0.0f, 0.0f, 0.0f), 1.0f, 0); D3D->BeginScene(); D3D.SetFVF(Vertex::dwFVF); D3D.SetTexture(0, texture); D3D.SetRS(D3DRS_ZENABLE, D3DZB_FALSE); //Links unten vertizes[0].pos = tbVector3(0.0f, D3D.GetScreenSize().y, 0.5f); vertizes[0].fRHW = 1.0f; vertizes[0].color = tbColor(1.0f, 0.8f, 0.8f); vertizes[0].texcoord = tbVector2(0.0f, 1.0f); // Links oben vertizes[1].pos = tbVector3(0.0f, 0.0f, 0.0f); vertizes[1].fRHW = 1.0f; vertizes[1].color = tbColor(0.8f, 1.0f, 0.8f); vertizes[1].texcoord = tbVector2(0.0f, 0.0f); // Rechts unten vertizes[2].pos = tbVector3(D3D.GetScreenSize().x, D3D.GetScreenSize().y, 0.5f); vertizes[2].fRHW = 1.0f; vertizes[2].color = tbColor(0.8f, 0.8f, 1.0f); vertizes[2].texcoord = tbVector2(1.0f, 1.0f); // Rechts oben vertizes[3].pos = tbVector3(D3D.GetScreenSize().x, 0.0f, 0.5f); vertizes[3].fRHW = 1.0f; vertizes[3].color = tbColor(1.0f, 1.0f, 0.8f); vertizes[3].texcoord = tbVector2(1.0f, 0.0f); D3D->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, vertizes, sizeof(Vertex)); D3D->Present(NULL, NULL, NULL, NULL); D3D->EndScene(); return TB_OK; } |
Quellcode |
|
1 2 3 4 5 6 7 |
tbResult VierGewinnt::Unload() { SetGameState(GS_NONE); TB_SAFE_DELETE(menu); menu->Unload(); return TB_OK; } |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
//Variablen LPD3DXMESH modell; LPDIRECT3DTEXTURE9 texture; D3DXLoadMeshFromX("Data\\Spielfeld8.x", D3DXMESH_MANAGED, tbDirect3D::Instance().GetDevice(), NULL, NULL, NULL, NULL, &modell); texture = tbTextureManager::Instance().GetTexture("Data\\spielfeldtexture.jpg"); //Render-Funktion tbDirect3D& D3D = tbDirect3D::Instance(); D3D->BeginScene(); D3D->SetTexture(0, texture); modell->DrawSubset(0); D3D->EndScene(); D3D->Present(NULL, NULL, NULL, NULL); |
Werbeanzeige