1
Graphics / missing functions
« on: June 20, 2022, 01:54:21 pm »#include <SFML/Graphics.hpp>
#include <SFML/OpenGL.hpp>
#include "main.h"
int main()
{
sf::ContextSettings settings;
settings.antialiasingLevel = 8;
sf::Window window(sf::VideoMode(800, 600), "The Game", sf::Style::Default, settings);
glEnable(GL_TEXTURE_2D);
window.setFramerateLimit(165);
float x = 100;
float y = 100;
float offset = 0;
//Get window width and height
sf::Vector2u size = window.getSize();
unsigned int width = size.x;
unsigned int height = size.y;
sf::CircleShape dude(15.f);
dude.setFillColor(sf::Color(0, 255, 0));
dude.setOutlineThickness(3.f);
dude.setOutlineColor(sf::Color(250, 150, 100));
dude.setPosition(x, y);
bool running = true;
while (running)
{
window.setActive(true);
sf::Event event;
while (window.pollEvent(event)) {
switch (event.type) {
case sf::Event::Closed:
running = false;
break;
case sf::Event::Resized:
// adjust the viewport when the window is resized
glViewport(0, 0, event.size.width, event.size.height);
width = event.size.width;
height = event.size.height;
default:
break;
}
}
//Game Loop
if (event.type == sf::Event::KeyPressed) {
switch (event.key.code) {
case sf::Keyboard::Right:
++offset;
break;
case sf::Keyboard::Left:
--offset;
break;
case sf::Keyboard::Down:
++offset;
break;
case sf::Keyboard::Up:
--offset;
break;
}
}
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
dude.move(x + offset, y + offset);
//end the current frame
window.clear();
window.draw(dude);
window.display();
window.setActive(false);
}
return 0;
}
#include <SFML/OpenGL.hpp>
#include "main.h"
int main()
{
sf::ContextSettings settings;
settings.antialiasingLevel = 8;
sf::Window window(sf::VideoMode(800, 600), "The Game", sf::Style::Default, settings);
glEnable(GL_TEXTURE_2D);
window.setFramerateLimit(165);
float x = 100;
float y = 100;
float offset = 0;
//Get window width and height
sf::Vector2u size = window.getSize();
unsigned int width = size.x;
unsigned int height = size.y;
sf::CircleShape dude(15.f);
dude.setFillColor(sf::Color(0, 255, 0));
dude.setOutlineThickness(3.f);
dude.setOutlineColor(sf::Color(250, 150, 100));
dude.setPosition(x, y);
bool running = true;
while (running)
{
window.setActive(true);
sf::Event event;
while (window.pollEvent(event)) {
switch (event.type) {
case sf::Event::Closed:
running = false;
break;
case sf::Event::Resized:
// adjust the viewport when the window is resized
glViewport(0, 0, event.size.width, event.size.height);
width = event.size.width;
height = event.size.height;
default:
break;
}
}
//Game Loop
if (event.type == sf::Event::KeyPressed) {
switch (event.key.code) {
case sf::Keyboard::Right:
++offset;
break;
case sf::Keyboard::Left:
--offset;
break;
case sf::Keyboard::Down:
++offset;
break;
case sf::Keyboard::Up:
--offset;
break;
}
}
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
dude.move(x + offset, y + offset);
//end the current frame
window.clear();
window.draw(dude);
window.display();
window.setActive(false);
}
return 0;
}
saying that there's no member called draw and no member called clear in window