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 - UchihaKite

Pages: [1]
1
Window / [Q] "glcontext.cpp not found" when closing window
« on: August 27, 2018, 11:09:21 pm »
Hey guys!

So, I tried doing some digging on my own, but unless I missed something, I don't think this issue has been posted before. I apologize if I did miss something, but after trying to figure this out for a few hours, I figured it was time to reach out for help :P

It might sound odd, but when I try to close my projects window (be it by clicking the "x" or pressing "ESC"), I get a crash or something. I've attached an image of what pops up. I've set up my SFML project as I always have, using the same version of SFML. I've never had this issue before.

Thanks for all the help!

Edit:
- Confirmed that I am using the correct Libraries
- Disabled my Anti Virus didn't help
- Tried upgrading the project to 2.5.1 and now Visual Studio's is asking me to "Find Source: glcontext.cpp"
- My project is linked statically

2
General / [Q] A Fog of War/Flashlight Type Question
« on: June 29, 2017, 08:26:16 pm »
Good afternoon Fellow Programmers,

So, I have this idea of a game that involves having the player escape from a maze that is completely blacked-out other than a small area around the player, and wherever this flashlight is pointing. This issue I am having is I literally have no idea how to do something like this. I was hoping someone could give me some ideas, so I can look into it, study up on some concepts and figure out how to do it. Thank you to anyone that reads this and decides to help me out!

3
SFML projects / My First Game - A Simple Asteroids Game
« on: September 27, 2016, 11:04:33 pm »
Good Afternoon SFML Community!

Once again UchihaKite has started a new thread in this fine forum, but alas it is not to ask the community for its help again! This time, I present to you all my first game! Now now now do not get too excited. It is just your basic asteroids game, however, it did take me a great deal of time to complete it, and it took me quite a bit of help as some of you already know. However, I am very proud of myself for finally completing this game! Can't even begin to express how excited I am to share this with all of you!

You use "A" to rotate counter clockwise and "D" to rotate clockwise. "W" is to actually move the player. "SPACE" is to fire a single bullet and "LEFT CTRL" is to fire 3 at once. Clicking "TAB" will bring up your current score and your high score to compare it with on a separate window. If you beat the high score and you die, your score gets saved, and becomes the new high score to beat! Attached to this thread is a picture of the game :D

Here is the link to the Source Code:
https://github.com/UchihaKite/SFML_Asteroids

I would really be thankful if some of you would take the time to play my game, analyze my code, and provide me with as much feedback, criticism, comments, advice, tips (etc), as possible. Having some input about my code, organization, style and what not would help me greatly in improving my skills. Thank you all for taking the time to read this!

I would also like to take this time to thank Draugr for his thread:
http://en.sfml-dev.org/forums/index.php?topic=12713.0
Along with those who helped him, eXpl0it3r, Ixrec, and Nexus.

I came up with a similar method to creating a Star filled background for my asteroids game, however, Draugr's method proved to be a lot more flexable, and was extremely educational to me.

4
General / [Q] Issues with Rotation and Movement: Super Simple AI
« on: September 20, 2016, 05:15:45 am »
Good evening once again fellow programmers!

Kite is here once again hoping to get some more education from the SFML community. Don't worry! This time it does have to do with SFML, at least more so than my usual questions.

Anyway! So, I am trying to develop a simple AI for my Asteroids Game. Basically, he is just going to fly around and follow the player, shoot at him when he is a certain distance away. The issue I am having though, is he will not rotate to face the player, and he just keeps moving forward.

Please believe me when I say this, I really did try to Google a solution to this, I did find a lot of great examples, however none of them helped me to solve this issue. This website:
http://www.pushbuttonreceivecode.com/blog/top-down-shoot-em-up-mechanics-part-1
Got me pretty close, however, it seems the AI just rotates like 45 degrees to the right, then to the left, repeatedly well moving upward. Attached to this are some pictures of my code, thought it might be a little easier to read thank typing it out here.

Thank you to anyone who checks out my code, and for anyone who helps me out. I am really excited to not only show this project to my teacher, but to post it up in the forums for everyone to check out!

Edit(Update:

I managed to fix the rotation issue, instead of using SetAngle(angle + 180 * dt), I used m_sprite.setRotation(toDegree(angle) + 90.f). And that seemed to solve it :D

The only issue I am having now is getting the enemy ship to actually move toward the player :/

Also, I noticed in my picture the if statement got cut off, so this is the full statement:

        if (m_sprite.getPosition().y >= playerLocation.y && m_sprite.getPosition().y < playerLocation.y + 720
                && m_sprite.getPosition().x >= playerLocation.x && m_sprite.getPosition().x < playerLocation.x + 720)
 

Edit(Update):
Whenever a Mod gets a chance, please remove this thread. I completely forgot when I was working on my AI that I already had methods to handle the movement and angles of all objects. So I was basically making a few calculations twice, and in two different ways. Which were all being executed lol Don't want to take up space for people who actually need help, I got it figured out. I posted a picture of the revised update function.

5
General / [Q] A way to protect my Save File :D
« on: September 19, 2016, 05:36:09 am »
Good Evening Fellow Programmers!

If I come off a little loops, I apologize. It's finals week, so I am hard at work on my final for my programming class. After about 12 hours of programming, I thought to myself, hey, this might be a good time to call it a day :D

Anyway! So, I managed to figure out a way to save the highscore of my Asteroids game, which if you reopen the program, it shows the score to beat! However, I don't want people to just go into the txt file and edit the high score.

I stumbled across a cipher and XOR, but it doesn't seem like I am able to get it to work with my txt file. I'm saving numbers to my txt file, so, I don't know if that has something to do with it?

I was just wondering if their is a way to encrypt the contents of my txt file, and/or if their is a way to hide the file? So maybe the only way it can be accessed is through Visual Studios?

Thanks for taking the time to read this, hopefully someone knows of a good way to protect my save file. All the best!

6
General / [Question/Request(?)] Modular Spaceship
« on: September 06, 2016, 03:00:52 pm »
Good morning SFML community! As I approach the end of my third C++ class and it is about time to customize my game to make it stand out from the rest! Since the game is asteroids, the idea came up to get a sprite sheet of a modular space ship, and allow the user to customize the space ship they are going to use in the game. Now, I've never done anything like this before, so I am used to having a single sprite, a single origin point, and thus allowing for easy manipulation of the "player". Does anyone have any ideas on how I should approach creating a modular space ship?

Thank you to anyone who takes the time to read this and to reply, I hope you all have a nice day!

7
General / [Q] Bouncing a Ball & Dot Products
« on: July 14, 2016, 07:38:52 pm »
Good Afternoon SFML Community!

First off, thank you all for your welcoming nature and helping me to not only understand SFML better, but to also expand my C++ knowledge.

However, I've run into a huge issue. Over Summer break, my teacher gave me some things that I could study to have a general understanding for our next class. Sadly, this has to do with Math, in High School I didn't think I would go to College, so I only took basic Algebra (11 years ago lol).

I was hoping that someone could kind of, point me in the right direction, in reference to this stuff? This is what he wanted me to look into:

Reflecting a Projectile Off a Wall at an Odd Angle (Dot Products)

Detect Whether Something is in your Field of View (Dot Products)

Fire a Projectile at any Angle (Like Geometry Wars, Sin/Cos/Tan)

Rotate a Point by some Angle, Around Another Point (Rotation Formula, Sin/Cos)

I apologize if I posted this in the wrong area, and I also apologize if this was wrong of me to ask in general. I really want to learn how to do this stuff, and I couldn't really find any examples online. Thank you for taking the time to read this, and any help in figuring out how to do this, and maybe being pointed to a good resource for C++ Math Stuff, would be greatly treasured. Again, I am sorry for having to ask for this type of help.

8
General / [Q] Traverse a Binary Tree
« on: June 30, 2016, 01:49:15 am »
Hello SFML Community!

First off, I apologize if this is in the incorrect location, secondly, if their is a better forum for C++ questions, feel free to direct me to it. I think I am just used to how awesome this community is, thus, I keep coming back here lol

So, currently I am on my second C++ class in college, and I decided to ask my teacher what I could look into over the break to get ahead a little. He told me that when I come back from Summer Break, he would like an example of Traversing a Binary Tree.

My question is, if anyone has a good resource on learning how to do this? I, of course, searched Google and Youtube. However, I found that most videos were either about Binary Search Trees, or were just very poor videos. My results on Google just left me completely confused. Like, I understand what a Binary Tree is, and how to Traverse a Binary Tree, on paper. Coding it, is something that is going well over my head. Any and all help would be great!

9
General / [Q] Something having to do with Anomalies and REX Prefix?
« on: June 13, 2016, 12:15:22 am »
Good Afternoon fellow C++ homies!

So, here is a random question for you all. Apart of my final is creating Pong with our own twist to it. Such as, I added an ability to the left paddle, when the ball hits the paddle three times, you can revert the ball back to the exact location it was at 3 seconds prior.
However I have seemed to come up with a weird message I have never seen before, and would love your guys thoughts on what it could be?

Anomaly: meaningless REX prefix used

My code is pretty damn long, so if you guys would rather me not post it up, if someone could just explain how that message comes up, I can look through my code and figure it out :) Thanks guys!

10
General / [Q] Adding Gravity to My Code
« on: May 16, 2016, 02:20:27 am »
Good Evening!

I'm back with another question that hopefully someone can help me out with. This week I was required to create a ball that would be launched from the bottom left corner of the screen, and continuously bounce off the surfaces of the screen. The longer I hold Spacebar, the faster the ball would get. I managed to complete my assignment a lot quicker than I thought I would, so I thought I would contact my teacher and see if I can't do something extra. He told me to add Gravity to my code. This is all he gave me.

Implement gravity into your ball movement:
- This will apply acceleration to your physics now.
- Remember, Velocity is the change in position per second, while acceleration is the change in Velocity per second.
- Gravity in our "Game" should be between 500 - 1500 Pixels/s^2

I have been trying to do this for a couple of days now, however I have been unable to implement it into my code. I know their are multiple ways of doing everything in coding, but from everything I have seen online and on tutorial videos, none of the methods have been working. So, I was hoping someone here has run into the same problems as me, and will be able to help me out.

Thank you all in advance for taking the time to look at my code, and helping me out!

// Engine.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <SFML/Graphics.hpp>

using namespace std;

void applyGravity(float, float);

float yVelocity;

int main()
{
        float Power = 0.0f;
        bool toMove = false;

        float Time;

        sf::RenderWindow window(sf::VideoMode(1024, 512), "Welcome to SDVA 203!");
        sf::CircleShape shape(25);
        shape.setPosition(0, 486);
        shape.setOrigin(shape.getRadius(), shape.getRadius());
        shape.setFillColor(sf::Color::White);

        sf::Clock clock;
        float angleInDegrees = 225;
        float angleInRadians = angleInDegrees * 2 * 3.1415 / 360;
        float xVelocity = cos(angleInRadians) * 100;
        yVelocity = sin(angleInRadians) * 100;
        while (window.isOpen())
        {
                sf::Time dt = clock.restart();
                sf::Event event;
                while (window.pollEvent(event))
                {
                        if (event.type == sf::Event::Closed)
                                window.close();

                        if (event.type == sf::Event::KeyReleased)
                        {
                                if (event.key.code == sf::Keyboard::Space)
                                {
                                        toMove = true;
                                }
                        }

                        if (event.type == sf::Event::KeyPressed)
                        {
                                if (event.key.code == sf::Keyboard::Num1)
                                {

                                        xVelocity = cos(angleInRadians) * 100;
                                        yVelocity = sin(angleInRadians) * 100;
                                }
                                if (event.key.code == sf::Keyboard::Num2)
                                {

                                        xVelocity = cos(angleInRadians) * 300;
                                        yVelocity = sin(angleInRadians) * 300;
                                }
                                if (event.key.code == sf::Keyboard::Num3)
                                {

                                        xVelocity = cos(angleInRadians) * 600;
                                        yVelocity = sin(angleInRadians) * 600;
                                }
                                if (event.key.code == sf::Keyboard::Num4)
                                {

                                        xVelocity = cos(angleInRadians) * 1200;
                                        yVelocity = sin(angleInRadians) * 1200;
                                }
                                if (event.key.code == sf::Keyboard::Space)
                                {
                                        toMove = false;
                                }
                        }
                }

                if (sf::Keyboard::isKeyPressed(sf::Keyboard::Space))
                {
                        Power += dt.asSeconds();

                        if (Power > 2.0f)
                        {
                                xVelocity = cos(angleInRadians) * 100;
                                yVelocity = sin(angleInRadians) * 100;
                                std::cout << "Power Level is at 100!" << std::endl;
                        }
                        if (Power > 4.0f)
                        {
                                xVelocity = cos(angleInRadians) * 300;
                                yVelocity = sin(angleInRadians) * 300;
                                std::cout << "Power Level is at 300!" << std::endl;
                        }
                        if (Power > 6.0f)
                        {
                                xVelocity = cos(angleInRadians) * 600;
                                yVelocity = sin(angleInRadians) * 600;
                                std::cout << "Power Level is at 600!" << std::endl;
                        }
                        if (Power > 8.0f)
                        {
                                xVelocity = cos(angleInRadians) * 1200;
                                yVelocity = sin(angleInRadians) * 1200;
                                std::cout << "Power Level is at 1200!" << std::endl;
                        }
                        if (Power > 10.0f)
                        {
                                xVelocity = cos(angleInRadians) * 9001;
                                yVelocity = sin(angleInRadians) * 9001;
                                std::cout << "Power Level Over 9000!" << std::endl;
                        }
                }

                if (toMove == true)
                {
                        shape.move(xVelocity * dt.asSeconds(), yVelocity * dt.asSeconds());
                        cout << xVelocity << yVelocity << endl;

                        applyGravity(500.0, 500.0);
                }

                sf::Vector2f position = shape.getPosition();
               
                if (position.y <= shape.getRadius())
                {
                        yVelocity *= -1;
                        shape.setPosition(position.x, shape.getRadius());
                }

                if (shape.getRadius() + position.y >= 512)
                {
                        yVelocity *= -1;
                        shape.setPosition(position.x, 512 - shape.getRadius());
                }
                if (position.x <= shape.getRadius())
                {
                        xVelocity *= -1;
                        shape.setPosition(shape.getRadius(), position.y);
                }
                if (shape.getRadius() + position.x >= 1024)
                {
                        xVelocity *= -1;
                        shape.setPosition(1024 - shape.getRadius(), position.y);
                }

                if (shape.getRadius() + position.y >= 512)
                {
                        yVelocity = yVelocity / 2.0f;
                }

                //std::cout << "Ball position is " << position.x <<","<<position.y << std::endl;

                window.clear();
                window.draw(shape);
                window.display();
        }
        return 0;
}

void applyGravity(float gravity, float time)
{
        yVelocity = yVelocity + (gravity * time);
        if (yVelocity < .01)
        {
                yVelocity = 0;
        }
}
 

11
General / [Q] Proper way to slow down a Sprite during movement?
« on: May 08, 2016, 12:03:59 am »
Good Afternoon,
I have experience in C++, however, I am very new with SFML. I managed to get a sprite on the screen, with the ability to not only move, but to go through the proper animations well in movement. My issue though, is the sprite itself isn't move too fast, but the animation of his movement is moving way to quickly. If that makes sense. Provided below is my code. I apologize if I put this up incorrectly, first time posting on here. Normally I am able to figure things out on my own, but I cannot seem to figure this one out.

#include "stdafx.h"
#include <SFML/Graphics.hpp>
#include <iostream>

using namespace std;

int main()
{

        int rLinkX = 0;
        int rLinkY = 3;
        int rIdle = 0;

        int lLinkX = 0;
        int lLinkY = 2;
        int lIdle = 0;

        int upLinkX = 0;
        int upLinkY = 1;
        int upIdle = 0;

        int dwnLinkX = 0;
        int dwnLinkY = 0;
        int dwnIdle = 0;

        sf::RenderWindow window(sf::VideoMode(1024, 512), "Welcome to SDVA 203!");

        sf::CircleShape shape(75.f);
        shape.setPosition(200, 200);

        window.setMouseCursorVisible(false);

        sf::Texture texture;
        if (!texture.loadFromFile("Content/Crosshair.png"))
        {
                cout << "Could not find image." << endl; // error...
        }
        shape.setTexture(&texture);

        sf::Sprite sprite;
       
        sf::Texture linkTexture;
        if (!linkTexture.loadFromFile("Content/zelda.png", sf::IntRect(0 * 40, 0 * 40, 40, 40)))
        {
                cout << "Could not find image." << endl; // error...
        }
        sprite.setTexture(linkTexture);

        while (window.isOpen())
        {
                sf::Event event;
                while (window.pollEvent(event))
                {
               
                        if (event.type == sf::Event::KeyPressed)
                        {
                                if (event.key.code == sf::Keyboard::Escape)
                                {
                                        window.close();
                                }

                                if (event.key.code == sf::Keyboard::Left)
                                {
                                        lIdle = 0;
                                        rIdle = 0;
                                        upIdle = 0;
                                        dwnIdle = 0;
                                        cout << "The Left Arrow Key Was Pressed" << endl;
                                        sprite.setTextureRect(sf::IntRect(lLinkX * 40, lLinkY * 40, 40, 40));
                                        if (!linkTexture.loadFromFile("Content/zelda.png"))
                                        {
                                                // error...
                                        }
                                        sprite.setTexture(linkTexture);
                                        sprite.move(-5, 0);
                                }
                                if (event.key.code == sf::Keyboard::Right)
                                {
                                        lIdle = 0;
                                        rIdle = 0;
                                        upIdle = 0;
                                        dwnIdle = 0;
                                        cout << "The Right Arrow Key Was Pressed" << endl;
                                        sprite.setTextureRect(sf::IntRect(rLinkX * 40, rLinkY * 40, 40, 40));
                                        if (!linkTexture.loadFromFile("Content/zelda.png"))
                                        {
                                                // error...
                                        }
                                        sprite.setTexture(linkTexture);
                                        sprite.move(5, 0);
                                }
                                if (event.key.code == sf::Keyboard::Up)
                                {
                                        lIdle = 0;
                                        rIdle = 0;
                                        upIdle = 0;
                                        dwnIdle = 0;
                                        cout << "The Up Arrow Key Was Pressed" << endl;
                                        sprite.setTextureRect(sf::IntRect(upLinkX * 40, upLinkY * 40, 40, 40));
                                        if (!linkTexture.loadFromFile("Content/zelda.png"))
                                        {
                                                // error...
                                        }
                                        sprite.setTexture(linkTexture);
                                        sprite.move(0, -5);
                                }
                                if (event.key.code == sf::Keyboard::Down)
                                {
                                        lIdle = 0;
                                        rIdle = 0;
                                        upIdle = 0;
                                        dwnIdle = 0;
                                        cout << "The Down Arrow Key Was Pressed" << endl;
                                        sprite.setTextureRect(sf::IntRect(dwnLinkX * 40, dwnLinkY * 40, 40, 40));
                                        if (!linkTexture.loadFromFile("Content/zelda.png"))
                                        {
                                                // error...
                                        }
                                        sprite.setTexture(linkTexture);
                                        sprite.move(0, 5);
                                }

                        }

                        if (event.type == sf::Event::KeyReleased)
                        {
                                if (event.key.code == sf::Keyboard::Right)
                                {
                                        rIdle = 1;
                                }

                                if (event.key.code == sf::Keyboard::Left)
                                {
                                        lIdle = 1;
                                }

                                if (event.key.code == sf::Keyboard::Up)
                                {
                                        upIdle = 1;
                                }

                                if (event.key.code == sf::Keyboard::Down)
                                {
                                        dwnIdle = 1;
                                }
                        }

                                if (event.type == sf::Event::MouseButtonPressed)
                                {
                                        if (event.mouseButton.button == sf::Mouse::Right)
                                        {
                                                std::cout << "the right button was pressed" << std::endl;
                                               
                                        }
                                }
                               

                                if (event.type == sf::Event::MouseWheelScrolled)
                                {
                                        if (event.mouseWheelScroll.wheel == sf::Mouse::VerticalWheel)
                                                std::cout << "wheel type: vertical" << std::endl;
                                        std::cout << "wheel movement: " << event.mouseWheelScroll.delta << std::endl;
                                        std::cout << "mouse x: " << event.mouseWheelScroll.x << std::endl;
                                        std::cout << "mouse y: " << event.mouseWheelScroll.y << std::endl;

                                        if (event.mouseWheelScroll.delta == 1)
                                        {
                                                shape.scale(1.8, 1.8);
                                        }
                                        else if (event.mouseWheelScroll.delta == -1)
                                        {
                                                shape.scale(.8, .8);
                                        }
                                }
                }


                if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left))
                {
                        cout << "Left Arrow" << endl;

                                lLinkX++;
                                if (lLinkX >= 7)
                                {
                                        lLinkX = 0;
                                }
                }

                if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right))
                {
                        cout << "Right Arrow" << endl;
                        rLinkX++;
                        if (rLinkX >= 7)
                        {
                                rLinkX = 0;
                        }
                }

                if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down))
                {
                        cout << "Left Arrow" << endl;
                        dwnLinkX++;
                        if (dwnLinkX >= 7)
                        {
                                dwnLinkX = 0;
                        }
                }

                if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up))
                {
                        cout << "Right Arrow" << endl;
                        upLinkX++;
                        if (upLinkX >= 7)
                        {
                                upLinkX = 0;
                        }
                }

                if (sf::Mouse::isButtonPressed(sf::Mouse::Left))
                {
                        shape.setPosition(sf::Mouse::getPosition(window).x, sf::Mouse::getPosition(window).y);
                }

                if (rIdle == 1)
                {
                        sprite.setTextureRect(sf::IntRect(rLinkX * 40, rLinkY * 40, 40, 40));
                        if (!linkTexture.loadFromFile("Content/zelda.png"))
                        {
                                // error...
                        }
                        sprite.setTexture(linkTexture);
                        rLinkX++;
                        if (rLinkX >= 7)
                        {
                                rLinkX = 0;
                        }
                }

                if (lIdle == 1)
                {
                        sprite.setTextureRect(sf::IntRect(lLinkX * 40, lLinkY * 40, 40, 40));
                        if (!linkTexture.loadFromFile("Content/zelda.png"))
                        {
                                // error...
                        }
                        sprite.setTexture(linkTexture);

                                lLinkX++;
                                if (lLinkX >= 7)
                                {
                                        lLinkX = 0;
                                }

                }

                if (upIdle == 1)
                {
                        sprite.setTextureRect(sf::IntRect(upLinkX * 40, upLinkY * 40, 40, 40));
                        if (!linkTexture.loadFromFile("Content/zelda.png"))
                        {
                                // error...
                        }
                        sprite.setTexture(linkTexture);
                        upLinkX++;
                        if (upLinkX >= 7)
                        {
                                upLinkX = 0;
                        }
                }

                if (dwnIdle == 1)
                {
                        sprite.setTextureRect(sf::IntRect(dwnLinkX * 40, dwnLinkY * 40, 40, 40));
                        if (!linkTexture.loadFromFile("Content/zelda.png"))
                        {
                                // error...
                        }
                        sprite.setTexture(linkTexture);
                        dwnLinkX++;
                        if (dwnLinkX >= 7)
                        {
                                dwnLinkX = 0;
                        }
                }

                shape.setOrigin(75, 75);
                window.clear();
                window.draw(shape);
                window.draw(sprite);
                window.display();

        }

        return 0;
}
 

Pages: [1]
anything