Im doing this simple project where you can control and make the character jump, but whenever I do
if (event.type == Event::KeyPressed) it wont execute the code in it when I press a key. Though this worked fine a while ago for some reason and my unfinished code is this:
#include "pch.h"
#include <iostream>
#include <SFML/Graphics.hpp>
#include "player.h"
using namespace std;
using namespace sf;
int main()
{
float gravity = 1;
Vector2f window_size(800, 600);
RenderWindow window(VideoMode(window_size.x, window_size.y), "simulation");
Vector2f starting_pos(385, 550);
Player plr(starting_pos);
while (window.isOpen())
{
Event event;
while (window.pollEvent(event))
{
if (event.type = Event::Closed)
{
window.close();
}
if (event.type == Event::KeyPressed)
{
cout << "activated" << endl;
if (event.key.code == Keyboard::E)
{
cout << "pressed" << endl;
}
}
}
window.clear();
window.draw(plr.get_character());
window.display();
}
return 0;
}