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.


Messages - Ionut

Pages: [1] 2 3 4
1
Graphics / Re: Debug output is graphically different from Relese output
« on: December 23, 2017, 12:47:28 pm »
Can you post the code ? That would really help. What are you using ? (Visual Studio,Code::Blocks, etc.. )
The result may be different in the release mode, because it tries to optimize things.

2
Graphics / Re: Problem with adding texture (_imp___ZN2...)
« on: June 17, 2017, 01:32:32 pm »
Delete that project and make another one ;), be very careful how you link the libraries

3
Quote
P.S.: setColor is deprecated, the new version is setFillColor
I was a little sleepy + I wasn't writing in C::B or VS, I was writing it here, so I didn't know what was the correct way.
I'm glad,I helped you ;)

4
Well,you could improve your code like this:
-You should use a gameloop and events
while(1)
{
....
}
WRONG
while(window.isOpen()))
    {
        Event event;
        while(window.pollEvent(event))
    {
        if(event.type == Event::Closed)
        {
            window.close();
        }
    }
...
 
CORRECT
Now the error I think you have is that you used window.display(),and everything in the wrong order,the order it should be:
//Outside the gameloop,alongside variables
Font font;
font.loadFromFile("dotty.ttf");
Text text;
text.setFont(font);
text.setString("Hello World");
text.setColor(Color::Red); //Maybe a color
text.setCharacterSize(24);
//Inside the gameloop
//Your events and all that
text.setPosition(250,250);
window.clear(Color::White);
window.draw(text);
window.display();
 
Note:My time is 23:31 now so I am a little sleepy, but the code should be fine.

5
Graphics / Re: Colliding problem...
« on: June 15, 2017, 08:16:38 pm »
The collision check :
if(upkey == false && !SAdventurer.getGlobalBounds().intersects(STileGrass.getGlobalBounds()))
        {
        pos.y += 2;
        }
The "Loop through them and test each one" :
for(int i = 0;i<43;i++)
    {
        for(int j = 0; j<5;j++)
    {
        if(mapArray[i][j] == 1)
        {
            STileGrass.setPosition(i * 70, (j * 70) + offsety);
        if(upkey == false && !SAdventurer.getGlobalBounds().intersects(STileGrass.getGlobalBounds()))
        {
        pos.y += 2;
        }
        }
    }
    }
Well you see,the problem is that it isn't working(and I know I'm not doing it right,but I don't know what am I doing wrong),if the "up" key isn't pressed and the player doesn't touches the ground, the gravitation will come in,and it really goes like this...just not like I want,it amplifies(what the for loop is for),but it only is going right with the last piece of the map.
Another problem is that I don't really know if it is really a tile map,because a tile map is something like this: http://imgur.com/htqx9tZ
,while my "map" is something like:
http://imgur.com/a/xtIGP
Note:This are not screenshots,these are from google.

6
Graphics / Re: Colliding problem...
« on: June 14, 2017, 07:13:10 pm »
I don't really get it...what do you mean when saying:"Loop through them and test each one."Sorry if I sound like a noob :-[ .

7
Graphics / Re: Colliding problem...
« on: June 13, 2017, 10:18:02 pm »
Ok,so how to make all the pieces collideble ?

8
Graphics / Colliding problem...
« on: June 13, 2017, 09:03:19 pm »
Hello!I have a real bad time with this for a long time.The only last piece of that "map" is collideble and this is making me a lot of problems.If I solve this a lot of things will run out nicely.
The minimal Code:
int mapArray[45][5] =
{
        {1,0,0,0,0},
        {1,0,0,0,0},
        {1,0,0,0,0},
        {1,0,0,0,0},
        {1,0,0,0,0},
...//and so
{1,0,0,0,0},
    };
//In the game loop
    if(Keyboard::isKeyPressed(Keyboard::Up))
    {
       upkey = true;
       upkeytimer.restart().asSeconds();
    }
    else if(!Keyboard::isKeyPressed(Keyboard::Up))
    {
       upkey = false;
    }
    if(upkey == true)
    {
    for(float up = upkeytimer.getElapsedTime().asSeconds();up < 2;up++) //Longer it's pressed longer it jumps
     {
        pos.y -=up;
     }
    }
    if(upkey == false && !SAdventurer.getGlobalBounds().intersects(STileGrass.getGlobalBounds())) //It collides only with the last piece,why?
    {
        pos.y += 2;
    }
//After window.clear()
for(int i = 0;i<43;i++)
    {
        for(int j = 0; j<5;j++)
    {
        if(mapArray[i][j] == 1)
        {
            STileGrass.setPosition(i * 70, (j * 70) + offsety);     //The "map" builder
            window.draw(STileGrass);
        }
    }
    }
window.display();
 

9
Graphics / Re: A More Realistic Jump
« on: June 11, 2017, 11:53:07 am »
FRex,I've made it so if the player presses up the character will jump.The longer it's pressed the longer it jumps,but not longer than 2 seconds(because I don't want the character to be at the same position with the sun).If the 2 seconds passed the player will start to fall,till it touches the tile.

10
Graphics / Re: A More Realistic Jump
« on: June 11, 2017, 11:37:08 am »
Thanks Elias ;).I made my own "formula" for the jump,but now the BIG problem is that the only last tile is collideble with the player.
THE MINIMAL CODE :
#include <SFML/Graphics.hpp>
using namespace sf;

int main()
{
    //Variables
    bool upkey = false;
    int offsety = 530;
    int velocity = 20;
    int acceleration = 1;
    double gravity = 0.5;
    int DisplayFrame = 0;            //Frames for animations
    float CurrentFrame = 0;
    Clock upkeytimer;               //Clock
    upkeytimer.restart().asSeconds();
    int mapArray[45][5] =           //The tile map.Now I have a little question,how to put it horizontally,because it consumes a lot of lines  
    {
        {1,0,0,0,0},
        {1,0,0,0,0},
        {1,0,0,0,0},
        {1,0,0,0,0},
        {1,0,0,0,0},
        {1,0,0,0,0},
        {1,0,0,0,0},
        {1,0,0,0,0},
        {1,0,0,0,0},
        {1,0,0,0,0},
        {1,0,0,0,0},
        {1,0,0,0,0},
        {1,0,0,0,0},
        {1,0,0,0,0},
        {1,0,0,0,0},
        {1,0,0,0,0},
        {1,0,0,0,0},
        {1,0,0,0,0},
        {1,0,0,0,0},
        {1,0,0,0,0},
        {1,0,0,0,0},
        {1,0,0,0,0},
        {1,0,0,0,0},
        {1,0,0,0,0},
        {1,0,0,0,0},
        {1,0,0,0,0},
        {1,0,0,0,0},
        {1,0,0,0,0},
        {1,0,0,0,0},
        {1,0,0,0,0},
        {1,0,0,0,0},
        {1,0,0,0,0},
        {1,0,0,0,0},
        {1,0,0,0,0},
        {1,0,0,0,0},
        {1,0,0,0,0},
        {1,0,0,0,0},
        {1,0,0,0,0},
        {1,0,0,0,0},
        {1,0,0,0,0},
        {1,0,0,0,0},
        {1,0,0,0,0},
        {1,0,0,0,0},
        {1,0,0,0,0},
        {1,0,0,0,0},
    };
    //In the game loop
    if(Keyboard::isKeyPressed(Keyboard::Up))
    {
       upkey = true;
       upkeytimer.restart().asSeconds();
    }
    else if(!Keyboard::isKeyPressed(Keyboard::Up))
    {
       upkey = false;
    }
    if(upkey == true)
    {
    for(float up = upkeytimer.getElapsedTime().asSeconds();up < 2;up++) //Longer it's pressed longer it jumps
     {
        pos.y -=up;
     }
    }
    if(upkey == false && !SAdventurer.getGlobalBounds().intersects(STileGrass.getGlobalBounds()))  //The Problem
    {
        pos.y += 2;
    }
    if(Keyboard::isKeyPressed(Keyboard::Right))
    {
        SAdventurer.setTextureRect(IntRect(80 * DisplayFrame,111,80,110));
        pos.x += 2.5;
        view.move(2.5,0);
    }
    CurrentFrame += 0.12;
    if(CurrentFrame >= 2) CurrentFrame = 0;       //The animation
    DisplayFrame = (int)CurrentFrame;
    window.clear(Color::White);    //Clearing the window
    SAdventurer.setPosition(pos.x,pos.y);
    window.setView(view);      //Setting the view
    for(int i = 0;i<43;i++)
    {
        for(int j = 0; j<5;j++)
    {
        if(mapArray[i][j] == 1)
        {
            STileGrass.setPosition(i * 70, (j * 70) + offsety);     //The tilemap builder
            window.draw(STileGrass);
        }
    }
    }
    window.draw(SAdventurer);  //Drawing the Player
    window.display();  //Displaying
    }
 
PS:That's the #50th post,so I'm not anymore a Newbie,I'm a Jr.!

11
Graphics / Re: Rectangle Object collides with Text object
« on: June 06, 2017, 07:59:11 pm »
Ok,I'm glad you figured it all by yourself ;D

12
Graphics / Re: Rectangle Object collides with Text object
« on: June 06, 2017, 07:29:49 pm »
That's weird...can you show us the code?

13
Graphics / Re: Failed Loading Texture - Reason Out of Memory
« on: June 06, 2017, 06:28:47 pm »
Hmm...that's a BIG image,don't you think?However you could divide the image into multiple spritesheets to use it.But I'm curious what game do you want to make?(Because that spritesheet contains more sprites that I know to count)

14
Graphics / Re: A More Realistic Jump
« on: June 05, 2017, 12:17:01 pm »
Oh sorry, my expression was wrong(again!),I don't want a "realistic jump",all I want is a jump that is a little bit more than a teleportation,I will try do make the jump with the help with the velocity,acceleration and the gravity.Thanks for the help. ;D

15
Graphics / A More Realistic Jump
« on: June 04, 2017, 02:56:50 pm »
Hello,I have a question,I want to make the player to jump a little bit realistically.I did a jump,but it is a little too simple I mean...the player simply teleports here an then goes down.I don't think you need any code from me,so I wont post the code.

Pages: [1] 2 3 4
anything