Hier een nieuwe aanwinst op het helpmij forum.(een echte aanwinst moet ik wel nog worden)
Ik ben pas begonnen met C++, en wat het gezegde "Alle begin is moeilijk" zegt geldt voor mij dubbel. het zit namelijk zo dat ik al een tijdje vastzit met een fout in mijn code.
en als foutmelding geeft hij: error C2181: illegal else without matching if
dit is mijn 'code':
//-----------------------------------------------------------------
// Game Skeleton
// C++ Source - Skeleton.cpp - versie 2008 v1_09
//-----------------------------------------------------------------
//-----------------------------------------------------------------
// Include Files
//-----------------------------------------------------------------
#include "Resource.h" // include file om de resources te kunnen gebruiken
#include "GameEngine.h" // include file om de game engine te kunnen aanspreken
//-----------------------------------------------------------------
// Game Defines
//-----------------------------------------------------------------
#define GAME_ENGINE (GameEngine::GetSingleton())
//-----------------------------------------------------------------
// Game Code
//-----------------------------------------------------------------
TextBox* txtNaamPtr;
Button* btnGenereerPtr;
void GameInitialize(HINSTANCE hInstance)
{
// Stel de verplichte waarden in
GAME_ENGINE->SetTitle("Nieuw Project");
GAME_ENGINE->SetIcon(IDI_BIG);
GAME_ENGINE->SetSmallIcon(IDI_SMALL);
//GAME_ENGINE->RunGameLoop(true);
// Stel de optionele waarden in
GAME_ENGINE->SetWidth(640);
GAME_ENGINE->SetHeight(480);
GAME_ENGINE->SetFrameRate(50);
}
void Generatie(Button* bronPtr)
{
GAME_ENGINE->RunGameLoop(true);
}
void GameStart()
{
txtNaamPtr = new TextBox;
txtNaamPtr -> SetBounds(550,10,80,20);
txtNaamPtr -> Show();
btnGenereerPtr = new Button("Genereer");
btnGenereerPtr -> SetBounds(550,60,80,20);
btnGenereerPtr -> SetAction(Generatie);
btnGenereerPtr -> Show();
}
void GameEnd()
{
delete btnGenereerPtr;
delete txtNaamPtr;
}
void GameActivate(HDC hDC, RECT rect)
{
}
void GameDeactivate(HDC hDC, RECT rect)
{
}
void MouseButtonAction(BOOL isLeft, BOOL isDown, int x, int y, WPARAM wParam)
{
}
void MouseMove(int x, int y, WPARAM wParam)
{
}
void CheckKeyboard()
{
}
void KeyPressed(TCHAR cKey)
{
}
void GamePaint(RECT rect)
{
}
void GameCycle(RECT rect)
{
GAME_ENGINE->DrawSolidBackground(RGB(255,255,255));
String sNaam = txtNaamPtr ->GetText();
String sText = "D";
String sTexta = "XXX";
if(sNaam == sText)
OutputDebugString("Strings are equal\n");
GAME_ENGINE->DrawString(String("")+sText,90,90);
else
OutputDebugString("Strings are not equal\n");
GAME_ENGINE->DrawString(String("")+sTexta,90,90);
}
Alvast bedankt aan de helper
:thumb:
Ik ben pas begonnen met C++, en wat het gezegde "Alle begin is moeilijk" zegt geldt voor mij dubbel. het zit namelijk zo dat ik al een tijdje vastzit met een fout in mijn code.
en als foutmelding geeft hij: error C2181: illegal else without matching if
dit is mijn 'code':
//-----------------------------------------------------------------
// Game Skeleton
// C++ Source - Skeleton.cpp - versie 2008 v1_09
//-----------------------------------------------------------------
//-----------------------------------------------------------------
// Include Files
//-----------------------------------------------------------------
#include "Resource.h" // include file om de resources te kunnen gebruiken
#include "GameEngine.h" // include file om de game engine te kunnen aanspreken
//-----------------------------------------------------------------
// Game Defines
//-----------------------------------------------------------------
#define GAME_ENGINE (GameEngine::GetSingleton())
//-----------------------------------------------------------------
// Game Code
//-----------------------------------------------------------------
TextBox* txtNaamPtr;
Button* btnGenereerPtr;
void GameInitialize(HINSTANCE hInstance)
{
// Stel de verplichte waarden in
GAME_ENGINE->SetTitle("Nieuw Project");
GAME_ENGINE->SetIcon(IDI_BIG);
GAME_ENGINE->SetSmallIcon(IDI_SMALL);
//GAME_ENGINE->RunGameLoop(true);
// Stel de optionele waarden in
GAME_ENGINE->SetWidth(640);
GAME_ENGINE->SetHeight(480);
GAME_ENGINE->SetFrameRate(50);
}
void Generatie(Button* bronPtr)
{
GAME_ENGINE->RunGameLoop(true);
}
void GameStart()
{
txtNaamPtr = new TextBox;
txtNaamPtr -> SetBounds(550,10,80,20);
txtNaamPtr -> Show();
btnGenereerPtr = new Button("Genereer");
btnGenereerPtr -> SetBounds(550,60,80,20);
btnGenereerPtr -> SetAction(Generatie);
btnGenereerPtr -> Show();
}
void GameEnd()
{
delete btnGenereerPtr;
delete txtNaamPtr;
}
void GameActivate(HDC hDC, RECT rect)
{
}
void GameDeactivate(HDC hDC, RECT rect)
{
}
void MouseButtonAction(BOOL isLeft, BOOL isDown, int x, int y, WPARAM wParam)
{
}
void MouseMove(int x, int y, WPARAM wParam)
{
}
void CheckKeyboard()
{
}
void KeyPressed(TCHAR cKey)
{
}
void GamePaint(RECT rect)
{
}
void GameCycle(RECT rect)
{
GAME_ENGINE->DrawSolidBackground(RGB(255,255,255));
String sNaam = txtNaamPtr ->GetText();
String sText = "D";
String sTexta = "XXX";
if(sNaam == sText)
OutputDebugString("Strings are equal\n");
GAME_ENGINE->DrawString(String("")+sText,90,90);
else
OutputDebugString("Strings are not equal\n");
GAME_ENGINE->DrawString(String("")+sTexta,90,90);
}
Alvast bedankt aan de helper

Laatst bewerkt: