DeliciousThaiCosine

Members
  • Content count

    6
  • Joined

  • Last visited

Community Reputation

134 Neutral

About DeliciousThaiCosine

  • Rank
    Newbie
  1. Z-Layer change

    In a 2D isometric game, the player can be either behind a tree or in front of the tree. I understand that in order to implement something like that, I need to draw the objects that are furthest away first and the objects that are closest to the screen last, but I don't know how to express that in C++.   How do I change the draw order of the objects during run time? Like, when the player starts out behind the tree and then walks in front of the tree then I need to change "draw tree before player" to "draw tree after player" I don't know how to write that at all.   Please help   (I'm using SFML and C++)
  2. Basic Game Loop Crash

    I didn't try touching it so I can't say.  My CPU was pretty high during the time though, so yeah. I'll also try cleaning the inside later when I my family stops using it just to be extra safe.   I'm more interested in seeing what's wrong with my code though, assuming it doesn't work properly for anyone else.
  3. Basic Game Loop Crash

      By crashed I meant my computer shut down. It still works perfectly fine. Yeah all my drivers are up to date and everything.   I assume it was the program that did it because that's when it shut down. Also my computer hasn't really had any problems before that I know of.
  4. Basic Game Loop Crash

    Basically, I crashed my computer when I ran my code. My friend told me the reason was probably due to something about overheating my comp somehow. Later on I ran this code on my laptop and when I opened my task manager my CPU Usage was at 100%. So I know I'm doing something horrifically wrong, but I don't know what.   Originally the code was all in the main function and it worked fine, but only when I rewrote the code in the game class did the program became problematic. Please help #include <SFML/System.hpp> #include <SFML/Window.hpp> #include <SFML/Graphics.hpp> #include <iostream> #include <fstream> #include <vector> #include <cmath> #include <cctype> class Game { private: sf::RenderWindow m_window; sf::Vector2u m_windowSize; sf::View m_mainView; sf::Event m_event; sf::Clock m_clock; sf::CircleShape m_Player; public: Game(); void run(); private: void getImput(); void updateLogic(); void renderGraphics(); }; Game::Game() :m_windowSize(1024, 640) ,m_window(sf::VideoMode(m_windowSize.x, m_windowSize.y), "Title") { m_window.setFramerateLimit(100); m_Player.setRadius(40.f); m_Player.setPosition(30.f, 30.f); m_Player.setFillColor(sf::Color::Cyan); } void Game::run(){ while(m_window.isOpen()){ getImput(); sf::sleep(sf::milliseconds(5)); updateLogic(); renderGraphics(); } } void Game::getImput(){ while(m_window.pollEvent(m_event)){ switch (m_event.type){ case sf::Event::Closed: m_window.close(); break; case sf::Event::KeyPressed: if(m_event.key.code == sf::Keyboard::F4){ //Resize Window m_windowSize.x = 800; m_windowSize.y = 600; // Apply possible size changes m_window.setSize(sf::Vector2u(m_windowSize.x, m_windowSize.y)); m_mainView = sf::View(sf::FloatRect(0.f, 0.f, m_windowSize.x, m_windowSize.y)); m_window.setView(m_mainView); } break; default: //idk break; } } } void Game::updateLogic(){ //Update the Logic here } void Game::renderGraphics(){ m_window.clear(); m_window.draw(m_Player); m_window.display(); } int main() { //Game Game game; game.run(); return 0; }
  5. Error is illogical

      Thank you! I never knew you couldn't assign things globally, I just assumed it was bad practice, not knowing why.
  6. Error is illogical

    I started working on this project and I don't know what happened. I tried to create an object and then use a simple setUp function, but it refused to work. The object was created, however when I attempted to use the function it came up with the error: 'X' does not name a type. After this I tried something much simpler. int i; i=10; It came up with the error: 'i' does not name a type. If I just say instead that int i=10; then the error disappears. Up to this point in time I've been self-taught so I've never heard of this before and I don't know what to call it. How do I fix this and how did this even occur?