Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - terrifiedobama

Pages: [1]
1
General / Hello guys I've some Errors no clue where the problem is.
« on: July 26, 2019, 02:36:20 pm »
So basically its hard for me to understand here is the video where I speak about the problem
i'll be very happy if you could help me.  :)
https://www.youtube.com/watch?v=UV7MZIxSxIc&feature=youtu.be

2
General / Fixed
« on: June 28, 2019, 01:39:12 pm »
So basically in the following picture there is an visual explanation for the problem which is occuring right when the action takes place.

((((The Code))))


#include "GameScreen.h"
#include "Collision.h"
#include <iostream>



GameScreen::GameScreen()
{
   
}


GameScreen::~GameScreen()
{

}

void GameScreen::LoadContent() {

   if (!font.loadFromFile("Font4.ttf"))
      std::cout << " no font found" << std::endl;

   text.setString("Press F1 To go to back");
   text.setFont(font);

   PlayerTexture.loadFromFile("player.png");
   PlayerSprite.setTexture(PlayerTexture);
   PlayerSprite.setPosition(sf::Vector2f(500, 275));
   PlayerSprite.setScale(sf::Vector2f(2, 2));


   //camera ?
   //sf::View Camera(sf::Vector2f(400.f, 300.f), sf::Vector2f(400.f, 300.f));
   //sf::Sprite* follow = &PlayerSprite;


   




   Tile001Texture.loadFromFile("tile001.png");
   //Tile001Sprite.setTextureRect(sf::IntRect(33, 30, 30, 30));
   Tile001Sprite.setTexture(Tile001Texture);
   
   //Tile001Rect.intersects
   Tile001Sprite.setPosition(sf::Vector2f(445,600));
   Tile001Sprite.setScale(sf::Vector2f(2,2));
   

   if (playpos == true) {
      PlayerSprite.setPosition(sf::Vector2f(33, 33));

   }
   
   
      
   
   


   
   
   

}



void GameScreen::UnloadContent() {

}

void GameScreen::Update() {
   if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right))
   {
      // left key is pressed: move our character
      //std::cout << "Player right" << std::endl;

      PlayerSprite.setTextureRect(sf::IntRect(52, 0, -53, 98));
      PlayerSprite.move(3.1, 0.0);
   }
   if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left))
   {
      // left key is pressed: move our character
      //std::cout << "Player  left" << std::endl;

      PlayerSprite.setTextureRect(sf::IntRect(0, 0, 53, 98));
      PlayerSprite.move(-3.1, 0.0);
   }

   

      if (sf::Keyboard::isKeyPressed(sf::Keyboard::LAlt))
      {
         //playpos = true;
         //PlayerSprite.setTextureRect(sf::IntRect(0, 0, 53, 98));
         //if (playpos == true)

            PlayerSprite.move(sf::Vector2f(0, -10));

         

         

         //comment teleport
         //if (PlayerSprite.getPosition().y) {
         //   PlayerSprite.setPosition(0, 0);
         //   PlayerSprite.move(sf::Vector2f(0,-1));
         //  }
         //comment no out fly y+
         //else PlayerSprite.move(sf::Vector2f(0, 1));
         //if (PlayerSprite.getPosition().y) {
            //PlayerSprite.setPosition(PlayerSprite);
               //}



      }
   
      // gravity
   for (int t = 0;t <= 5;t++) {

      PlayerSprite.move(sf::Vector2f(0,0.3));
      
      
   }

   xposplayer = PlayerSprite.getPosition().x;
   yposplayer = PlayerSprite.getPosition().y;
   xpostile001 = Tile001Sprite.getPosition().x;
   ypostile001 = Tile001Sprite.getPosition().y;
   while (xsetposplayer == true) {

      PlayerSprite.setPosition(PlayerSprite.getPosition());
      
   }

   if (PlayerSprite.getGlobalBounds().intersects(Tile001Sprite.getGlobalBounds())) {
      std::cout << "good job fool" << std::endl;
      
      
      


      if (xpostile001&&xposplayer) {
      //   PlayerSprite.move() = Tile001Sprite.move();
         std::cout << "1" << std::endl;
         xsetposplayer = true;
         if (sf::Keyboard::isKeyPressed(sf::Keyboard::End)) {
            //xposplayer = 66;

         }
      }
      else if (!xpostile001 && xposplayer) {
         xsetposplayer = false;
         std::cout << "2" << std::endl;
         
      }
   }
   else
   {
      std::cout << "no" << std::endl;
   }


   
   
   
   


}

void GameScreen::Draw(sf::RenderWindow& Window) {
   Window.draw(text);
   Window.draw(PlayerSprite);
   Window.draw(Tile001Sprite);
   Window.setFramerateLimit(60);

   
   
   
}

---------------------------------------------------------------------------------------------------------------------------


The point of this code is that im trying to get my playersprite to collide with the tilesprite
and move jump go to all following directions.
but i cant even continue because it crashes.


i know its a stupid way to make this happen but im trying hard to do it alone & my way u know what i mean.

im new to coding forgive me for the dumb coding mechanism.

3
General / Pointer error [Fixed] by : Hapax
« on: June 26, 2019, 10:15:52 pm »
i need help, i've been stuggling since 1 day figure this out
◘◘◘◘Halp plox, i've been Stuggling for (3) {days} trying to figure this out◘◘◘◘

whenever i try to write 
for (int t = 0;t <= 5;t++) {
      PlayerSprite.move(sf::Vector2f(0,0.1));
      if (PlayerSprite.getGlobalBounds().intersects(Tile001Sprite.getGlobalBounds)) {
         std::cout << "tes" << std::endl;
      }

   }
the following error is : Severity   Code   Description   Project   File   Line   Suppression State
Error   C3867    'sf::Sprite::getGlobalBounds': non-standard syntax; use '&' to create a pointer to member   


ive been stuggling alot if someone can help me i will apriciate it alot  :-[


i cant write the PlayerSprite i dont understand what does this pointer & mean like where should i put it like i dont understand im mega confused im really confused.

Pages: [1]