MainMenu.h
#pragma once
#include <SFML/Graphics.hpp>
class MainMenu
{
public:
MainMenu(sf::Image &MainImage, sf::RenderWindow &Window, float x1, float y1, float x2, float y2);
void Update(sf::RenderWindow &Window);
void Draw(sf::RenderWindow &Window);
bool GetIsPlaying();
private:
bool IsPlaying;
sf::Sprite MainSprite;
sf::Image MainImage;
sf::FloatRect PlayGame;
sf::Event MainEvent;
};
MainMenu.cpp
#include "stdafx.h"
#include <SFML/Graphics.hpp>
#include "MainMenu.h"
MainMenu::MainMenu(sf::Image &MainImage, sf::RenderWindow &Window, float x1, float y1, float x2, float y2)
{
this->MainImage = MainImage;
MainSprite.SetImage(this->MainImage);
PlayGame.Left = x1;
PlayGame.Top = y1;
PlayGame.Right = x2;
PlayGame.Bottom = y2;
IsPlaying = false;
}
void MainMenu::Update(sf::RenderWindow &Window)
{
if ((MainEvent.Type == sf::Event::KeyPressed) && (MainEvent.Key.Code == sf::Key::Up))
IsPlaying = true;
}
void MainMenu::Draw(sf::RenderWindow &Window)
{
Window.Draw(MainSprite);
}
bool MainMenu::GetIsPlaying()
{
return IsPlaying;
}
Can someone tell me how to make a mainmenu. I made it so that the up button played it. I tried to program it myself but I'm kind of lost, and even with looking at the sfml documentation I'm not sure how to do this. (The Up Button didn't work either