[benötige Hilfe]Spiel Programmieren

12/21/2013 22:53 golle12#1
Hallo liebe Community

und zwar habe ich eine Frage ich möchte eiin Spiel ertstellen aber wenn ich
diesen Quelltext/Sourcecode ausühre:
(Ist nicht die Main Funktion)
PHP Code:
void Start_Spiel()
{
    
HWND console_window GetConsoleWindow();
    
SetWindowPos(console_window,0,0,0,100,100,SWP_HIDEWINDOW);
    
    
sf::RenderWindow window(sf::VideoMode(800,600), "Super Mario Land II");
    
sf::Texture Mariotextur;
    
Mariotextur.loadFromFile("Mario.png");
    
sf::Sprite Mariosprite(Mariotextur);

    
SetWindowPos(console_window,0,100,100,800,340,SWP_SHOWWINDOW);

    while(
window.isOpen())
    {
        
sf::Event event;

        while(
window.pollEvent(event))
        {
            if(
event.type == sf::Event::Closed)
                
window.close();
        }

        
window.clear();
        
window.display();
    }


Hier ist die Main Funktion
PHP Code:
int main(int argcchar **argv)
{
    
int tmp;
    
char Auswahl;
    
bool running true;
    
    do
    {

    
std::cout << "====================================|-----|=====================================";
    
std::cout << "====================================|Spiel|=====================================";
    
std::cout << "====================================|-----|=====================================";
    
std::cout << "=======================       [S]piel Starten" << "        ===========================";
    
std::cout << "=======================       [A]nleitung" << "            ===========================";
    
std::cout << "=======================       [C]redits" << "              ===========================";
    
std::cout << "=======================       [V]erlassen" << "            ===========================";
    
std::cout << "================================================================================";
    
std::cout << "================================================================================";
    
std::cout << "\n";
    
std::cout << "Herzlich Willkommen zu unserem Projekt, welches wir heute vorstellen moechten.  ";
    
std::cout << "Diese Anwendung die ihr hier sieht, ist ein mit C++ geschriebenes Menue welches ";
    
std::cout << "folgende Funkionen besitzt:" << std::endl;
    
std::cout << "\n";
    
std::cout << "|[S]piel Starten|-- Bei dieser Funktion wird das Spiel gestartet.                ";
    
std::cout << "\n";
    
std::cout << "|[A]nleitung|-- Bei der Funktion bekommt ihr eine genauere Beschreibung des     ";
    
std::cout << "Spielablaufes und der Steuerung." << std::endl;
    
std::cout << "\n";
    
std::cout << "|[C]redits|-- Hier werden alle Mitwirkende, die an diesem Projekt mitgearbeitet ";
    
std::cout << "haben, aufgelistet." << std::endl;
    
std::cout << "\n";
    
std::cout << "|[V]erlassen|-- Das (Konsolen)fenster wird geschlossen; Sie verlassen das Spiel ";
    
std::cout << "\n";
    
std::cout << "Deine Eingabe:"std::cin >> Auswahl;

    switch(
Auswahl)
    {
    case (
's'): case('S'):
        
std::cout << "\n";
        
Start_Spiel();
        
system("Cls");
            break;

    case (
'a'): case ('A'):
        
std::cout << "\n";
        
Anleitung();
        
system("Cls");
        break;

    case (
'c'): case ('C'):
        
std::cout << "\n";
        
Credits();
        
system("Cls");
        break;

    case (
'v'): case ('V'):
        return 
0;
        break;
        
    default:
        
std::cout << "\n";
        
std::cout <<"Ungueltige Eingabe\n";
        
std::cout << "\n";
        
std::cout <<"Bitte geben sie den vorgegebenen Buchstaben ein um eine Funktion nutzten\n" << "zu können!\n";
        
system("Cls");
    }    

    }while(
running);

    
std::cin >> tmp;
    return 
0;

kommt folgender Fehler heraus:
Eine Ausnahme (erste Chance) bei 0x6ec11f34 (msvcr100.dll) in GRW Spieleprogrammierung.exe: 0xC0000005: Zugriffsverletzung beim Lesen an Position 0x003e1000.
Unbehandelte Ausnahme bei 0x6ec11f34 (msvcr100.dll) in GRW Spieleprogrammierung.exe: 0xC0000005: Zugriffsverletzung beim Lesen an Position 0x003e1000.

Und da wollte ich fragen was sich da machen lässt hoffe ihr könnt mir da helfen.
12/22/2013 05:04 Dr. Coxxy#2
dafür gibt es den debugger...
12/26/2013 17:37 golle12#3
Edit : Oben hat sich das geklärt

Aber ich brauch noch einmal Hilfe und zwar möchte ich mit Mario wenn ich sund(Pfeiltaste)rechts drückt(und auch links), dass er schneller läuft.Hier das Script:
PHP Code:
#include <iostream>
#include <string>
#include <Windows.h>
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
#include <SFML/Window.hpp>


using namespace sf;

float offsetX=0offsetY=0;


const 
int H 19;
const 
int W 150;

String TileMap[H] = {
"0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"0                                                                                                                                                     0",
"0                                                                                                                                                     0",
"0                                                                                                                                                     0",
"0                                                                                                                                                     0",
"0                                                                                                                                                     0",
"0                                                                                                                                                     0",
"0                                                                                                                                                     0",
"0                                                                                                                                                     0",
"0                                                                                                                                                     0",
"0                                                                                                                                                     0",
"0                                                                                                                                                     0",
"0                                                                                                                                                     0",
"0                                                                                                                                                     0",
"0                                                                                                                                                     0",
"0                                                                                                                                                     0",
"0                                                                                                                                                     0",
 
"PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP",
 
"PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP",
}; 

class 
PLAYER {
public:
float dx,dy;

FloatRect rect;
bool onGround;
Sprite sprite;
float currentFrame;

    
PLAYER(Texture &image)
   {
    
sprite.setTexture(image);
    
rect FloatRect(40,255,16,16);

    
dx=dy=0.1;
    
currentFrame 0;
   }

   
void update(float time)
   {    

     
rect.left += dx time;    
     
Collision(0);
   

     if (!
onGrounddy=dy+0.0005*time;    
     
rect.top += dy*time;
     
onGround=false;
     
Collision(1);
    

     
currentFrame += time 0.005;
     if (
currentFrame 3currentFrame -= 3;


    if (
dx>0sprite.setTextureRect(IntRect(112+31*int(currentFrame),144,16,16));
    if (
dx<0sprite.setTextureRect(IntRect(112+31*int(currentFrame)+16,144,-16,16));
  

     
sprite.setPosition(rect.left offsetXrect.top offsetY);
      
     
dx=0;
   }


   
void Collision(int num)
{
    
    for (
int i rect.top/16 i<(rect.top+rect.height)/16i++)
        for (
int j rect.left/16j<(rect.left+rect.width)/16j++)
             {
                 if ((
TileMap[i][j]=='P') || (TileMap[i][j]=='k') || (TileMap[i][j]=='0') || (TileMap[i][j]=='r') || (TileMap[i][j]=='t'))
                                         { 
                                                   if (
dy>&& num==1)
                                                   { 
rect.top =   i*16 -  rect.height;  dy=0;   onGround=true; }
                                                   if (
dy<&& num==1)
                                                   { 
rect.top i*16 16;   dy=0;}
                                                   if (
dx>&& num==0)
                                                   { 
rect.left =  j*16 -  rect.width; }
                                                   if (
dx<&& num==0)
                                                   { 
rect.left =  j*16 +16;}
                                         }

                 if (
TileMap[i][j]=='c')
                 {
                     
//Nicht ferig -> Coins oder Pilz überprüfung und falscher Code |>^<|
                  
if (dy>&& num==1)
                                                   { 
rect.top =   i*16 -  rect.height;  dy=0;   onGround=true; }
                                                   if (
dy<&& num==1)
                                                   { 
rect.top i*16 16;   dy=0;}
                                                   if (
dx>&& num==0)
                                                   { 
rect.left =  j*16 -  rect.width; }
                                                   if (
dx<&& num==0)
                                                   { 
rect.left =  j*16 +16;}
                                                   
//Ende
                                           
}
             }

}

};

class 
ENEMY
{

public:
float dx,dy;
FloatRect rect;
Sprite sprite;
float currentFrame;
bool life;


   
void set(Texture &imageint xint y)
   {
    
sprite.setTexture(image);
    
rect FloatRect(820,255,16,16);

    
dx=0.05;
    
currentFrame 0;
    
life=true;
   }

   
void update(float time)
   {    
     
rect.left += dx time;
    
     
Collision();
  

     
currentFrame += time 0.005;
     if (
currentFrame 2currentFrame -= 2;

    
sprite.setTextureRect(IntRect(18*int(currentFrame),   016,16));
    if (!
life)sprite.setTextureRect(IntRect(58016,16));
    
    
sprite.setPosition(rect.left offsetXrect.top offsetY);
   }

   
void Collision()
  {

    for (
int i rect.top/16 i<(rect.top+rect.height)/16i++)
        for (
int j rect.left/16j<(rect.left+rect.width)/16j++)
             if ((
TileMap[i][j]=='P') || (TileMap[i][j]=='0'))
                                       { 
                                                    if (
dx>0)
                                                   { 
rect.left =  j*16 rect.widthdx*=-1; }
                                                    else if (
dx<0)
                                                   { 
rect.left =  j*16 16;  dx*=-1; }
                                            
                                        }
  }

};

int main()
{  

    
RenderWindow window(VideoMode(500300), "Super Mario Land II");

    
Texture tileSet;
    
//Texture Tileset;
    
tileSet.loadFromFile("Mario_Tileset.png");
    
//Tileset.loadFromFile("Mario_tileset_end.jpeg");
    
    
PLAYER Mario(tileSet);
    
ENEMY  enemy;
    
enemy.set(tileSet,48*16,13*16);


    
Sprite tile(tileSet);
    
//Sprite tilem(Tileset);

    
SoundBuffer buffer;
    
buffer.loadFromFile("Mario_Jump.ogg");
    
Sound sound(buffer);
    
sound.setVolume(20);

    
Music music;
    
music.openFromFile("Mario_Theme.ogg");
    
music.play();
    
music.setVolume(40);
    
music.setLoop(true);
    

    
Clock clock;

    while (
window.isOpen())
    { 
        
        
float time clock.getElapsedTime().asMicroseconds();
        
clock.restart();

        
time time/500

        if (
time 20time 20

        
Event event;
        while (
window.pollEvent(event))
        {
            if (
event.type == Event::Closed)    
                
window.close();
        }


        if (
Keyboard::isKeyPressed(Keyboard::Left))    Mario.dx=-0.1;
       
        if (
Keyboard::isKeyPressed(Keyboard::Right))    Mario.dx=0.1;
    
        if (
Keyboard::isKeyPressed(Keyboard::Up))    if (Mario.onGround) { Mario.dy=-0.27Mario.onGround=false;  sound.play();}

        if ((
Keyboard::isKeyPressed(Keyboard::S)) &&  ((Keyboard::isKeyPressed(Keyboard::Right))))
        {
            for(
Mario.dx 0Mario.dx >= 0.30.1+0.1+0.1//Mario Rennen
             
{
             
             }
        }

        if ((
Keyboard::isKeyPressed(Keyboard::S)) &&  ((Keyboard::isKeyPressed(Keyboard::Left)))) //Mario Rennen
        
{
            for(
Mario.dx 0Mario.dx <= -0.3; -0.1-0.1-0.1)
            {
        
            }
        }

         
Mario.update(time);
         
enemy.update(time);


         if  (
Mario.rect.intersectsenemy.rect ) )
         {
             if (
enemy.life) {
             if (
Mario.dy>0) { enemy.dx=0Mario.dy=-0.2enemy.life=false;}
             else 
Mario.sprite.setColor(Color::Red);
             }
         }


         if (
Mario.rect.left>200offsetX Mario.rect.left-200;      




         
window.clear(Color(92,148,252));

         for (
int i=0i<Hi++)
             for (
int j=0j<Wj++)
              { 
                if (
TileMap[i][j]=='P')  tile.setTextureRectIntRect(143-16*3,112,16,16) ); //brauner Grundboden

                
if (TileMap[i][j]=='k')  tile.setTextureRectIntRect(143,112,16,16) ); //normaler Gelber Stein(Schornstein)
                                                 
                   
if (TileMap[i][j]=='c')  tile.setTextureRectIntRect(143-16,112,16,16) ); //(?)Fragezeichen Itemstein

                
if (TileMap[i][j]=='t')  tile.setTextureRectIntRect(0,47,32,48) ); //normales Rohr

                
if (TileMap[i][j]=='g')  tile.setTextureRectIntRect(0,16*9-5,3*16,37) ); //kleiner Hügel

                
if (TileMap[i][j]=='G')  tile.setTextureRectIntRect(145,222,222-145,255-222) ); //großer Hügel

                
if (TileMap[i][j]=='d')  tile.setTextureRectIntRect(0,106,74,127-106) ); //3 Busch Hügel

                
if (TileMap[i][j]=='w')  tile.setTextureRectIntRect(99,224,140-99,255-224) ); //1 Wolke

                
if (TileMap[i][j]=='r')  tile.setTextureRectIntRect(143-32,112,16,16) ); //Ein brauner quadratischer Stein

                
if (TileMap[i][j]=='q')  tile.setTextureRectIntRect(0,222,90,35) ); //3 Wolken

                
if (TileMap[i][j]=='e')  tile.setTextureRectIntRect(50,55,45,45) ); //1 Busch Hügel

                
if (TileMap[i][j]=='z')  tile.setTextureRectIntRect(95,5,107,107) ); //End Level Burg

                
if (TileMap[i][j]=='u')  tile.setTextureRectIntRect(95,128,16,16) ); //blauer Grundboden

                
if (TileMap[i][j]=='i')  tile.setTextureRectIntRect(143-32,128,16,16) ); //ein blauer quadratischer Stein

                
if (TileMap[i][j]=='o')  tile.setTextureRectIntRect(143,128,16,16) ); //normaler blauer Stein(Schornstein)

                
if (TileMap[i][j]=='p')  tile.setTextureRectIntRect(160,123,64,20) ); //2 Busch Hügel

                
if (TileMap[i][j]=='a')  tile.setTextureRectIntRect(63,145,12,16) ); //kleines Büschlein (am Ende des Levls an der Burg)

                
if (TileMap[i][j]=='s')  tile.setTextureRectIntRect(0,176,78,32) ); //2 teiliges Rohr

                
if (TileMap[i][j]=='f')  tile.setTextureRectIntRect(95,160,66,32) ); //2 Wolken

                
if (TileMap[i][j]=='h')  tile.setTextureRectIntRect(175,192,49,17) ); //(bewegliche/)Plattform

                
if (TileMap[i][j]=='j')  tile.setTextureRectIntRect(224,176,24,32) ); // Boden mit Wasser

                
if (TileMap[i][j]=='l')  tile.setTextureRectIntRect(224,176,16,16) ); //Wasser

                
if (TileMap[i][j]=='m')  tile.setTextureRectIntRect(239,240,17,16) ); //"Brücke"

                //if (TileMap[i][j]=='n')  tilem.setTextureRect( IntRect(200,5,40,100) ); //Fahnenstangen am Ende des Levels

                
if ((TileMap[i][j]==' ') || (TileMap[i][j]=='0')) continue;

                  
tile.setPosition(j*16 offsetX,i*16 offsetY) ;
                
//tilem.setPosition(j*16 - offsetX,i*16 - offsetY);
                
window.draw(tile); 
             }
         
//window.draw(tilem);

        
window.draw(Mario.sprite);
        
window.draw(enemy.sprite);

        
window.display();
    }

    return 
0;

Dann kommt diese Fehler Meldung :
Code:
1>------ Erstellen gestartet: Projekt: GRW  Spiel Projekt, Konfiguration: Debug Win32 ------
1>  C:\Users\Privat\Desktop\SFML-2.1\bin\libsndfile-1.dll
1>  C:\Users\Privat\Desktop\SFML-2.1\bin\openal32.dll
1>  C:\Users\Privat\Desktop\SFML-2.1\bin\sfml-audio-2.dll
1>  C:\Users\Privat\Desktop\SFML-2.1\bin\sfml-audio-d-2.dll
1>  C:\Users\Privat\Desktop\SFML-2.1\bin\sfml-graphics-2.dll
1>  C:\Users\Privat\Desktop\SFML-2.1\bin\sfml-graphics-d-2.dll
1>  C:\Users\Privat\Desktop\SFML-2.1\bin\sfml-network-2.dll
1>  C:\Users\Privat\Desktop\SFML-2.1\bin\sfml-network-d-2.dll
1>  C:\Users\Privat\Desktop\SFML-2.1\bin\sfml-system-2.dll
1>  C:\Users\Privat\Desktop\SFML-2.1\bin\sfml-system-d-2.dll
1>  C:\Users\Privat\Desktop\SFML-2.1\bin\sfml-window-2.dll
1>  C:\Users\Privat\Desktop\SFML-2.1\bin\sfml-window-d-2.dll
1>         12 Datei(en) kopiert.
1>  main.cpp
1>c:\users\privat\desktop\spiel c++\grw projekt\grw  spiel projekt\grw  spiel projekt\main.cpp(64): warning C4244: '=': Konvertierung von 'double' in 'float', möglicher Datenverlust
1>c:\users\privat\desktop\spiel c++\grw projekt\grw  spiel projekt\grw  spiel projekt\main.cpp(70): warning C4244: '+=': Konvertierung von 'double' in 'float', möglicher Datenverlust
1>c:\users\privat\desktop\spiel c++\grw projekt\grw  spiel projekt\grw  spiel projekt\main.cpp(87): warning C4244: 'Initialisierung': Konvertierung von 'float' in 'int', möglicher Datenverlust
1>c:\users\privat\desktop\spiel c++\grw projekt\grw  spiel projekt\grw  spiel projekt\main.cpp(88): warning C4244: 'Initialisierung': Konvertierung von 'float' in 'int', möglicher Datenverlust
1>c:\users\privat\desktop\spiel c++\grw projekt\grw  spiel projekt\grw  spiel projekt\main.cpp(95): warning C4244: '=': Konvertierung von 'int' in 'float', möglicher Datenverlust
1>c:\users\privat\desktop\spiel c++\grw projekt\grw  spiel projekt\grw  spiel projekt\main.cpp(99): warning C4244: '=': Konvertierung von 'int' in 'float', möglicher Datenverlust
1>c:\users\privat\desktop\spiel c++\grw projekt\grw  spiel projekt\grw  spiel projekt\main.cpp(108): warning C4244: '=': Konvertierung von 'int' in 'float', möglicher Datenverlust
1>c:\users\privat\desktop\spiel c++\grw projekt\grw  spiel projekt\grw  spiel projekt\main.cpp(112): warning C4244: '=': Konvertierung von 'int' in 'float', möglicher Datenverlust
1>c:\users\privat\desktop\spiel c++\grw projekt\grw  spiel projekt\grw  spiel projekt\main.cpp(149): warning C4244: '+=': Konvertierung von 'double' in 'float', möglicher Datenverlust
1>c:\users\privat\desktop\spiel c++\grw projekt\grw  spiel projekt\grw  spiel projekt\main.cpp(161): warning C4244: 'Initialisierung': Konvertierung von 'float' in 'int', möglicher Datenverlust
1>c:\users\privat\desktop\spiel c++\grw projekt\grw  spiel projekt\grw  spiel projekt\main.cpp(162): warning C4244: 'Initialisierung': Konvertierung von 'float' in 'int', möglicher Datenverlust
1>c:\users\privat\desktop\spiel c++\grw projekt\grw  spiel projekt\grw  spiel projekt\main.cpp(168): warning C4244: '=': Konvertierung von 'int' in 'float', möglicher Datenverlust
1>c:\users\privat\desktop\spiel c++\grw projekt\grw  spiel projekt\grw  spiel projekt\main.cpp(210): warning C4244: 'Initialisierung': Konvertierung von 'sf::Int64' in 'float', möglicher Datenverlust
1>c:\users\privat\desktop\sfml-2.1\include\sfml\graphics\rect.inl(113): error C2589: '(': Ungültiges Token auf der rechten Seite von '::'
1>          c:\users\privat\desktop\sfml-2.1\include\sfml\graphics\rect.inl(109): Bei der Kompilierung der  Klassen-template der bool sf::Rect<T>::intersects(const sf::Rect<T> &,sf::Rect<T> &) const-Memberfunktion
1>          with
1>          [
1>              T=float
1>          ]
1>          c:\users\privat\desktop\sfml-2.1\include\sfml\graphics\rect.inl(39): Bei der Kompilierung der  Klassen-template der sf::Rect<T>::Rect(T,T,T,T)-Memberfunktion
1>          with
1>          [
1>              T=float
1>          ]
1>          c:\users\privat\desktop\sfml-2.1\include\sfml\graphics\view.hpp(275): Siehe Verweis auf die Instanziierung der gerade kompilierten Klassen-template "sf::Rect<T>".
1>          with
1>          [
1>              T=float
1>          ]
1>c:\users\privat\desktop\sfml-2.1\include\sfml\graphics\rect.inl(113): error C2059: Syntaxfehler: '::'
1>c:\users\privat\desktop\sfml-2.1\include\sfml\graphics\rect.inl(114): error C2589: '(': Ungültiges Token auf der rechten Seite von '::'
1>c:\users\privat\desktop\sfml-2.1\include\sfml\graphics\rect.inl(114): error C2059: Syntaxfehler: '::'
1>c:\users\privat\desktop\sfml-2.1\include\sfml\graphics\rect.inl(115): error C2589: '(': Ungültiges Token auf der rechten Seite von '::'
1>c:\users\privat\desktop\sfml-2.1\include\sfml\graphics\rect.inl(115): error C2059: Syntaxfehler: '::'
1>c:\users\privat\desktop\sfml-2.1\include\sfml\graphics\rect.inl(116): error C2589: '(': Ungültiges Token auf der rechten Seite von '::'
1>c:\users\privat\desktop\sfml-2.1\include\sfml\graphics\rect.inl(116): error C2059: Syntaxfehler: '::'
1>c:\users\privat\desktop\sfml-2.1\include\sfml\graphics\rect.inl(119): error C2589: '(': Ungültiges Token auf der rechten Seite von '::'
1>c:\users\privat\desktop\sfml-2.1\include\sfml\graphics\rect.inl(119): error C2059: Syntaxfehler: '::'
1>c:\users\privat\desktop\sfml-2.1\include\sfml\graphics\rect.inl(120): error C2589: '(': Ungültiges Token auf der rechten Seite von '::'
1>c:\users\privat\desktop\sfml-2.1\include\sfml\graphics\rect.inl(120): error C2059: Syntaxfehler: '::'
1>c:\users\privat\desktop\sfml-2.1\include\sfml\graphics\rect.inl(121): error C2589: '(': Ungültiges Token auf der rechten Seite von '::'
1>c:\users\privat\desktop\sfml-2.1\include\sfml\graphics\rect.inl(121): error C2059: Syntaxfehler: '::'
1>c:\users\privat\desktop\sfml-2.1\include\sfml\graphics\rect.inl(122): error C2589: '(': Ungültiges Token auf der rechten Seite von '::'
1>c:\users\privat\desktop\sfml-2.1\include\sfml\graphics\rect.inl(122): error C2059: Syntaxfehler: '::'
1>c:\users\privat\desktop\sfml-2.1\include\sfml\graphics\rect.inl(125): error C2589: '(': Ungültiges Token auf der rechten Seite von '::'
1>c:\users\privat\desktop\sfml-2.1\include\sfml\graphics\rect.inl(125): error C2059: Syntaxfehler: '::'
1>c:\users\privat\desktop\sfml-2.1\include\sfml\graphics\rect.inl(126): error C2589: '(': Ungültiges Token auf der rechten Seite von '::'
1>c:\users\privat\desktop\sfml-2.1\include\sfml\graphics\rect.inl(126): error C2059: Syntaxfehler: '::'
1>c:\users\privat\desktop\sfml-2.1\include\sfml\graphics\rect.inl(127): error C2589: '(': Ungültiges Token auf der rechten Seite von '::'
1>c:\users\privat\desktop\sfml-2.1\include\sfml\graphics\rect.inl(127): error C2059: Syntaxfehler: '::'
1>c:\users\privat\desktop\sfml-2.1\include\sfml\graphics\rect.inl(128): error C2589: '(': Ungültiges Token auf der rechten Seite von '::'
1>c:\users\privat\desktop\sfml-2.1\include\sfml\graphics\rect.inl(128): error C2059: Syntaxfehler: '::'
========== Erstellen: 0 erfolgreich, Fehler bei 1, 0 aktuell, 0 übersprungen ==========
Was ist da falsch bei mir denn ich kann keine mehrzeligen Verzweigungen mehr machen. Bitte helft mir .
12/26/2013 18:06 Dr. Coxxy#4
sind wir hier neuerdings dein persönlicher debugger oder was?
räum mal dein projekt auf und lern mit der IDE umzugehen, wir machen das hier net für dich.
01/01/2014 16:32 golle12#5
Hallo liebe Community

und zwar habe ich vollgende Frage ich möchte ein Mario Game programmieren nun bin ich bei den Kollisionen verschiedener Tiles da Mario wenn er in einen Graben fällt sterben soll / bzw. ein Leben verlieren soll und nicht dauraus springt und weiter läut hab ich die Frage wie es funktioniert denn ich versuche auch, das zum Beispiel wenn er in den Graben fällt die Musik(Theme music) aufhört zu spielen und die loose life music spielt aber bei mir macht er nicht sondern spielt die normale theme music weiter ab. Hoffe ihr könnt mir helfen.

Hier ist das Script:
PHP Code:
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
#include <iostream>
#include <Windows.h>

using namespace sf;

float offsetX 0offsetY 0;

const 
int H 20;
const 
int W 150;

String TileMap[H] = {
    
"0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
    
"0                                                                                                                                                     0",
    
"0                                                                                                                                                     0",
    
"0                                                                       w                   w                                                         0",
    
"0                   w                   f                                                                                                             0",
    
"0        w                   q                                                                        f                                               0",
    
"0                                                            w                                                                                        0",
    
"0                                                                               w                                     w                               0",
    
"0                                                                                                                          f                          0",
    
"0                        c                                                                                                                            0",
    
"0                                                                                                                                                     0",
    
"0                                                                                                                                                     0",
    
"0                                                                    c              c   c                                                             0",
    
"0                 c    kckck                       t0         t0                c            kkk          t0                                          0",
    
"0                                         t0       00         00                                   t0     00                                          0",
    
"0G                             t0         00       bvG        bv                                   00     bv                                          0",
    
"0            d    g       e    00         bv p     bv         bv d   g     e          d            bv e   bv g                                        0",
    
"PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP  PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP   PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP",
    
"PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP11PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP111PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP",
    
"000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
};


class 
PLAYER {
public:
    
float dxdy;

    
FloatRect rect;
    
bool onGround;
    
Sprite sprite;
    
float currentFrame;

    
PLAYER(Texture &image)
    {
        
sprite.setTexture(image);
        
rect FloatRect(402551616); //Spawn Position (Mario)

        
dx dy 0.1;
        
currentFrame 0;
    }

    
void update(float time)
    {
        
rect.left += dx time;
        
Collision(0);


        if (!
onGrounddy dy 0.0005*time;
        
rect.top += dy*time;
        
onGround false;
        
Collision(1);


        
currentFrame += time 0.005;
        if (
currentFrame 3currentFrame -= 3;


        if ((
Keyboard::isKeyPressed(Keyboard::Left)) || (Keyboard::isKeyPressed(Keyboard::Right)) || (Keyboard::isKeyPressed(Keyboard::Up)))
        {

            if (
dx>0){ sprite.setTextureRect(IntRect(112 31 int(currentFrame), 1441616)); }
            if (
dx<0){ sprite.setTextureRect(IntRect(112 31 int(currentFrame) + 16144, -1616)); }

            if (
Keyboard::isKeyPressed(Keyboard::Up))
            {
                
sprite.setTextureRect(IntRect(112 31 51441616));
            }
        }
        else
        {
            
sprite.setTextureRect(IntRect(112 311441616));
        }

        
sprite.setPosition(rect.left offsetXrect.top offsetY);

        
dx 0;
    }

    
void Collision(int num)
    {


        for (
int i rect.top 16i<(rect.top rect.height) / 16i++)
        for (
int j rect.left 16j<(rect.left rect.width) / 16j++)
        {
            if ((
TileMap[i][j] == 'P') || (TileMap[i][j] == 'k') || (TileMap[i][j] == '0') || (TileMap[i][j] == 'r') || (TileMap[i][j] == 't') || (TileMap[i][j] == 'u') || (TileMap[i][j] == 'i') || (TileMap[i][j] == 'o') || (TileMap[i][j] == 's') || (TileMap[i][j] == 'h') || (TileMap[i][j] == 'm') || (TileMap[i][j] == 'b') || (TileMap[i][j] == 'v'))
            {
                if (
dy>&& num == 1)
                {
                    
rect.top 16 rect.height;  dy 0;   onGround true;
                }
                if (
dy<&& num == 1)
                {
                    
rect.top 16 16;   dy 0;
                }
                if (
dx>&& num == 0)
                {
                    
rect.left 16 rect.width;
                }
                if (
dx<&& num == 0)
                {
                    
rect.left 16 16;
                }
            }

            
            if (
TileMap[i][j] == 'c')
            {
                
//Nicht ferig -> Coins oder Pilz überprüfung und falscher Code |>^<|
                
if (dy>&& num == 1)
                {
                    
rect.top 16 rect.height;  dy 0;   onGround true;
                }
                if (
dy<&& num == 1)
                {
                    
rect.top 16 16;   dy 0;
                }
                if (
dx>&& num == 0)
                {
                    
rect.left 16 rect.width;
                }
                if (
dx<&& num == 0)
                {
                    
rect.left 16 16;
                }
                
//Ende
            
}
            if (
TileMap[i][j] == '1')//Hier beginnt die Kollision
            
{
                if (
dy>&& num == 0)
                {
                    
Music music;//standard theme music
                    
music.setLoop(false);schleife wird auf alse gesetzt
                    music
.pause();//und wird dann pausiert

                    
SoundBuffer Buffer;////mario_die music
                    
Buffer.loadFromFile("Mario_die.ogg");
                    
Sound ssound(Buffer);

                    
ssound.play();//Hier sollte es abgespielt werden tut es aber nicht :(
                
}
            }
//Hier endet sie
        
}
    }

};

class 
ENEMY
{

public:
    
float dxdy;
    
FloatRect rect;
    
Sprite sprite;
    
float currentFrame;
    
bool life;


    
void set(Texture &imageint xint y)
    {
        
sprite.setTexture(image);
        
rect FloatRect(8202551616);//spawn Position(Enemy)

        
dx 0.05;
        
currentFrame 0;
        
life true;
    }

    
void update(float time)
    {
        
rect.left += dx time;

        
Collision();


        
currentFrame += time 0.005;
        if (
currentFrame 2currentFrame -= 2;

        
sprite.setTextureRect(IntRect(18 int(currentFrame), 01616));
        if (!
life)
        {
            
life false;
            
sprite.setTextureRect(IntRect(5801616));
        }
        else
        {
            
life true;
        }
        
sprite.setPosition(rect.left offsetXrect.top offsetY);
    }

    
void Collision()
    {

        for (
int i rect.top 16i<(rect.top rect.height) / 16i++)
        for (
int j rect.left 16j<(rect.left rect.width) / 16j++)
        if ((
TileMap[i][j] == 'P') || (TileMap[i][j] == '0') || (TileMap[i][j] == 'v') || (TileMap[i][j] == 'b'))
        {
            if (
dx>0)
            {
                
rect.left 16 rect.widthdx *= -1;
            }
            else if (
dx<0)
            {
                
rect.left 16 16;  dx *= -1;
            }

        }
    }

};


void Start_Spiel()
{
    
HWND console_window GetConsoleWindow();
    
system("Cls");
    
//SetWindowPos(console_window,0,0,0,100,100,SWP_HIDEWINDOW);

    
RenderWindow window(VideoMode(500300), "Super Mario Land II");

    
Texture tileSet;
    
//Texture Tileset;
    
tileSet.loadFromFile("Mario_Tileset.png");
    
//Tileset.loadFromFile("Mario_tileset_end.jpeg");

    
PLAYER Mario(tileSet);
    
ENEMY  enemy;
    
enemy.set(tileSet48 1613 16);


    
Sprite tile(tileSet);
    
//Sprite tilem(Tileset);

    
SoundBuffer buffer;
    
buffer.loadFromFile("Mario_Jump.ogg");
    
Sound sound(buffer);
    
sound.setVolume(20);

    
SoundBuffer gmbuffer;
    
gmbuffer.loadFromFile("Mario_Game_Over.ogg");
    
Sound gmsound(gmbuffer);

    
SoundBuffer bfbriet;
    
bfbriet.loadFromFile("Mario_Level_Complete.ogg");
    
Sound bfSound(bfbriet);

    
SoundBuffer briet;
    
briet.loadFromFile("Star_Man.ogg");
    
Sound stsound(briet);

    
SoundBuffer Buffer;
    
Buffer.loadFromFile("Mario_die.ogg");
    
Sound ssound(Buffer);

    
Music music;
    
music.openFromFile("Mario_Theme.ogg");
    
music.play();
    
music.setVolume(40);
    
music.setLoop(true);

    
Clock clock;

    while (
window.isOpen())
    {

        
float time clock.getElapsedTime().asMicroseconds();
        
clock.restart();

        
time time 500;

        if (
time 20time 20;

        
Event event;
        while (
window.pollEvent(event))
        {
            if (
event.type == Event::Closed)
                
window.close();
        }

        if ((
Keyboard::isKeyPressed(Keyboard::S)) && (Keyboard::isKeyPressed(Keyboard::Right)) && (Keyboard::isKeyPressed(Keyboard::Up)))
        {
            if (
Mario.onGround)
            {
                
Mario.dy = -0.30;
                
Mario.onGround false;
                
sound.play();
            }
        }

        if ((
Keyboard::isKeyPressed(Keyboard::S)) && (Keyboard::isKeyPressed(Keyboard::Left)) && (Keyboard::isKeyPressed(Keyboard::Up)))
        {
            if (
Mario.onGround)
            {
                
Mario.dy = -0.30;
                
Mario.onGround false;
                
sound.play();
            }
        }

        if (
Keyboard::isKeyPressed(Keyboard::Left))    Mario.dx = -0.08;

        if (
Keyboard::isKeyPressed(Keyboard::Right))   Mario.dx 0.08;

        if (
Keyboard::isKeyPressed(Keyboard::Up))    if (Mario.onGround) { Mario.dy = -0.29Mario.onGround false;  sound.play(); }

        if ((
Keyboard::isKeyPressed(Keyboard::S)) && (Keyboard::isKeyPressed(Keyboard::Left)))
        {
            
Mario.dx = -0.11;
            
Mario.dx = -0.12;
        }

        if ((
Keyboard::isKeyPressed(Keyboard::S)) && (Keyboard::isKeyPressed(Keyboard::Right)))
        {
            
Mario.dx 0.11;
            
Mario.dx 0.12;
        }



        
Mario.update(time);
        
enemy.update(time);


        if (
Mario.rect.intersects(enemy.rect))
        {
            if (
enemy.life) {
                if (
Mario.dy>0) { enemy.dx 0Mario.dy = -0.2enemy.life false; }
                else 
Mario.sprite.setColor(Color::Red);
            }
        }



        if (
Mario.rect.left>200offsetX Mario.rect.left 200;




        
window.clear(Color(92148252));

        for (
int i 0i<Hi++)
        for (
int j 0j<Wj++)
        {
            if (
TileMap[i][j] == 'P')  tile.setTextureRect(IntRect(143 16 31121616)); //brauner Grundboden

            
if (TileMap[i][j] == 'k')  tile.setTextureRect(IntRect(1431121616)); //normaler Gelber Stein(Schornstein)

            
if (TileMap[i][j] == 'c')  tile.setTextureRect(IntRect(143 161121616)); //(?)Fragezeichen Itemstein

            
if (TileMap[i][j] == 't')  tile.setTextureRect(IntRect(0473248)); //normales Rohr

            
if (TileMap[i][j] == 'g')  tile.setTextureRect(IntRect(016 51637)); //kleiner Hügel

            
if (TileMap[i][j] == 'G')  tile.setTextureRect(IntRect(145222222 145255 222)); //großer Hügel

            
if (TileMap[i][j] == 'd')  tile.setTextureRect(IntRect(010674127 106)); //3 Busch Hügel

            
if (TileMap[i][j] == 'w')  tile.setTextureRect(IntRect(99224140 99255 224)); //1 Wolke

            
if (TileMap[i][j] == 'r')  tile.setTextureRect(IntRect(143 321121616)); //Ein brauner quadratischer Stein

            
if (TileMap[i][j] == 'q')  tile.setTextureRect(IntRect(02229035)); //3 Wolken

            
if (TileMap[i][j] == 'e')  tile.setTextureRect(IntRect(50554545)); //1 Busch Hügel

            
if (TileMap[i][j] == 'z')  tile.setTextureRect(IntRect(955107107)); //End Level Burg

            
if (TileMap[i][j] == 'u')  tile.setTextureRect(IntRect(951281616)); //blauer Grundboden

            
if (TileMap[i][j] == 'i')  tile.setTextureRect(IntRect(143 321281616)); //ein blauer quadratischer Stein

            
if (TileMap[i][j] == 'o')  tile.setTextureRect(IntRect(1431281616)); //normaler blauer Stein(Schornstein)

            
if (TileMap[i][j] == 'p')  tile.setTextureRect(IntRect(1601236420)); //2 Busch Hügel

            
if (TileMap[i][j] == 'a')  tile.setTextureRect(IntRect(631451216)); //kleines Büschlein (am Ende des Levls an der Burg)

            
if (TileMap[i][j] == 's')  tile.setTextureRect(IntRect(01767832)); //2 teiliges Rohr

            
if (TileMap[i][j] == 'f')  tile.setTextureRect(IntRect(951606632)); //2 Wolken

            
if (TileMap[i][j] == 'h')  tile.setTextureRect(IntRect(1751924917)); //(bewegliche/)Plattform

            
if (TileMap[i][j] == 'j')  tile.setTextureRect(IntRect(2241762432)); // Boden mit Wasser

            
if (TileMap[i][j] == 'l')  tile.setTextureRect(IntRect(2241761616)); //Wasser

            
if (TileMap[i][j] == 'm')  tile.setTextureRect(IntRect(2392401716)); //"Brücke"

            
if (TileMap[i][j] == 'b')  tile.setTextureRect(IntRect(0701616)); //weiteres Rohrteil(quadrat->links)

            
if (TileMap[i][j] == 'v')  tile.setTextureRect(IntRect(16701616)); //weiteres Rohrteil(quadrat->rechts)

            //if (TileMap[i][j]=='n')  tilem.setTextureRect( IntRect(552,2,55,350) ); //Fahnenstangen am Ende des Levels

            
if (TileMap[i][j] == '1'tile.setTextureRect(IntRect(0000)); //Fall/Tod

            
if ((TileMap[i][j] == ' ') || (TileMap[i][j] == '0')) continue;

            
tile.setPosition(16 offsetX16 offsetY);
            
//tilem.setPosition(j*16 - offsetX,i*16 - offsetY);
            //window.draw(tilem);
            
window.draw(tile);

        }

        
window.draw(Mario.sprite);
        
window.draw(enemy.sprite);

        
window.display();
    }
    
SetWindowPos(console_window0100100800340SWP_SHOWWINDOW);
}


void Anleitung()
{
    
char AEingabe;
    
system("Cls");

}

void Credits()
{
    
char Eingabe;
    
system("Cls");

    
std::cout << "================================================================================";
    
std::cout << "==================================|-Credits-|===================================";
    
std::cout << "================================================================================";
    
std::cout << "\n";
    
std::cout << "\n";
    
std::cout << "Gesch\x84 \bftsf\x81\hrer-----------------------------------------------------";
    
std::cout << "\n";
    
std::cout << "Angestellte----------------------------   ------------";
    
std::cout << "---------------------------------------  -----------------------";
    
std::cout << "\n";
    
std::cout << "Logo Kreationist---------------------------------------------------";
    
std::cout << "\n";
    
std::cout << "Finanzen------------------------------------------------------------";
    
std::cout << "\n";
    
std::cout << "Gesch\x84 \bftsidee--------------------------  ----------";
    
std::cout << "---------------------------------------------  -------------------";
    
std::cout << "---------------------------------------------   -----------------------";
    
std::cout << "\n";
    
std::cout << "Werbung--------------------------------  -------------------------";
    
std::cout << "\n";
    
std::cout << "Programmierer--------------------------  -----------------------";
    
std::cout << "\n";
    
std::cout << "                                                                     ©FrameGame ";
    
std::cout << "\n";
    
std::cout << "Um die Credits zu verlassen dr\x81\cken sie eine Taste und dann Enter:"std::cin >> Eingabe;
    
system("Cls");
}

int main(int argcchar **argv)
{
    
int tmp;
    
char Auswahl;
    
bool running true;

    do
    {

        
std::cout << "================================================================================";
        
std::cout << "==============================|Super Mario Land II|=============================";
        
std::cout << "================================================================================";
        
std::cout << "=======================       [S]piel Starten" << "        ===========================";
        
std::cout << "=======================       [A]nleitung" << "            ===========================";
        
std::cout << "=======================       [C]redits" << "              ===========================";
        
std::cout << "=======================       [V]erlassen" << "            ===========================";
        
std::cout << "================================================================================";
        
std::cout << "================================================================================";
        
std::cout << "\n";
        
std::cout << "Herzlich Willkommen zu unserem Projekt, welches wir heute vorstellen m\x94\chten.   ";
        
std::cout << "Diese Anwendung die ihr hier sieht, ist ein mit C++ geschriebenes Men\x81 welches  ";
        
std::cout << "folgende Funkionen besitzt:" << std::endl;
        
std::cout << "\n";
        
std::cout << "|[S]piel Starten|-- Bei dieser Funktion wird das Spiel gestartet.                ";
        
std::cout << "\n";
        
std::cout << "|[A]nleitung|-- Bei der Funktion bekommt ihr eine genauere Beschreibung des     ";
        
std::cout << "Spielablaufes und der Steuerung." << std::endl;
        
std::cout << "\n";
        
std::cout << "|[C]redits|-- Hier werden alle Mitwirkende, die an diesem Projekt mitgearbeitet ";
        
std::cout << "haben, aufgelistet." << std::endl;
        
std::cout << "\n";
        
std::cout << "|[V]erlassen|-- Das (Konsolen)fenster wird geschlossen; Sie verlassen das Spiel ";
        
std::cout << "\n";
        
std::cout << "Deine Eingabe:"std::cin >> Auswahl;

        switch (
Auswahl)
        {
        case (
's') : case('S') :
            
std::cout << "\n";
            
Start_Spiel();
            break;

        case (
'a') : case ('A') :
            
std::cout << "\n";
            
Anleitung();
            break;

        case (
'c') : case ('C') :
            
std::cout << "\n";
            
Credits();
            break;

        case (
'v') : case ('V') :
            return 
0;
            break;

        default:
            
std::cout << "\n";
            
std::cout << "Ungueltige Eingabe\n";
            
std::cout << "\n";
            
std::cout << "Bitte geben sie den vorgegebenen Buchstaben ein um eine Funktion nutzten\n" << "zu k\x94nnen!\n";
            
system("pause");
            
system("Cls");
        }

    } while (
running == true);

    
std::cin >> tmp;
    return 
0;