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

Pages: [1] 2 3
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!

- 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

General / Re: [Q] A Fog of War/Flashlight Type Question
« on: July 08, 2017, 11:59:04 pm »
FRex. My dude. Thank you for taking the time to whip something up for me like that. I'm going to further analyze this code to make sure I understand it and then play around with it to see if I can expand it :P
Curious though, did you come up with this on your own, or is there something I can go to study up on stuff like this?

General / Re: [Q] A Fog of War/Flashlight Type Question
« on: July 06, 2017, 12:37:24 am »
2. Draw your (potentially colorful) lights to a render texture using additive blending.
3. Draw that render texture on top of the scene using multiplicative blending.
I'm still new to Game Development, so I am not entirely sure what Additive Blending and Multiplicative Blending is, but I am sure that is something I can figure out with a Google Search. :D

If you want your lights to cast shadows or be soft it might be a bit more difficult.

You might look into LTBL (Let There Be Light) library that is floating around here (I'm not 100% sure of its current status).
I experimented with lighting years ago (the code sucks by now though and using clipper lib might be an overkill): https://github.com/FRex/HardLight
This is also a good reading resource (this approach should work well for a maze with well defined walls I'd think, it doesn't work for intersecting lines though so be careful around that): http://ncase.me/sight-and-light/

Yeah, I assumed that this would be hard. Putting aside the fact I have never done this before, the concept of having the Player be the Light Source with a small "cone" of light in front to represent the light of the flashlight, is something that excites me to try to program, but freaks me out because I'm not entirely sure how to do that. Not to mention that when the Light hits, an object, not only is that object now visible but produces shadow....almost makes me feel like I am a little in over my head, but I gotta try and see if I can do it :P

For simple soft lights, you could try this shader (when applying step 2 of FRex's solution):
This look super interesting, I am going to play around with that code asap so I have a better idea on how it works :D

Thank you both for taking the time to reply to my thread! I'm still not entirely sure of what to do, but at least now I have some stuff to look into and try to figure out a gameplan. If I run into any more issues, I will be sure to come to you guys ^_^

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!

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:

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:
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.

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:
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!


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)

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.

General / Re: [Q] A way to protect my Save File :D
« on: September 19, 2016, 04:44:30 pm »
Thanks guys! I will look into all of these things and report back to you :D

PD: This is the SFML forums, for discuss SFML related things.

For game-dev/ general C++ questions there are a lot dedicated forums for this topic.

Sorry about that! Typically programming forums are all welcoming to noobs like me, but I find that people here explain things a lot better and less chance of getting the "get gewd" reply from people. I'll take general C++ questions elsewhere from now on though! I just didn't know if SFML had some security features or something, so I thought I would ask here :D

Thanks again for all of your help! I think those methods are a little above me right now, but I am going to look into those to educate myself. I decided to just go the route of making the file a binary file, and making it hidden. Not the best method, but it should be good enough to turn in as my final assignment.

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!

General / Re: AW: [Question/Request(?)] Modular Spaceship
« on: September 14, 2016, 04:05:20 am »
You could go with predefined origin or calculate a center point at ship creation. Additionally you'll want to write a function that either returns the bounds of the ship or checks collision with the ship's shape.

As for modules, you could just provide base ships with various slots that can be filled with different modules and once that works maybe allow slots on modules themselves. Just make sure that modules have actually some meaning otherwise it becomes a bit pointless. Additionally you could add module requirements for a ship, e.g. you need to have an engine module and a controll module or something like that.

Last but not least don't forget that suvh a module system can get very complex. So it's best to pick the smallest thing you could think of first and try to implement that. Don't try to get "the" system done. ;)

A draw a ship "with added modules", you can simply use multiple sprites (one for each "part" - the ship and each module), each with different origins to "push" them to their position on the ship. Then, if you apply the same transformations to all the "parts", they will move and rotate together. To simplify this, you can create a class that stores all of these sprites and provide transformation functions that just "pass through" and duplicate onto all of those sprites. That way, you only need to transform the one class.

Taking this further, you may consider using a vertex array, which allows multiple primitives (triangles or more likely quads in this case) to be drawn to the screen buffer at one time. If you have very many sprites (hundreds) on screen at once, this may be necessary but for an Asteroids-style game, using a few extra sprites - as mentioned in the paragraph above - should be just fine. Plus, it is the simplest way!

Thank you both so much for replying to my topic, I know I sometimes ask the most random things, but it truly means a lot that you both take the time to reply to my questions. Because it seems whenever I have a question you two are one of the first to reply lol

After my class on Saturday and I get the AI worked in, I am going to work on this. I will be sure to let you guys know how it goes and if I have more questions.

I was hoping to create some type of menu for the selection of parts, like IMGUI or something, but I'm not entirely sure which GUI would be the simplest to use @_@

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!

General / Re: [Q] Bouncing a Ball & Dot Products
« on: July 17, 2016, 03:50:44 pm »
Hmmmm I don't think I have ever looked at Java examples and adapted it to C++, but that should be an interesting process!

Thank you so much for taking the time to provide this stuff to mean! It really means a lot man :D

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.

General / Re: [Q] Traverse a Binary Tree
« on: July 02, 2016, 02:07:43 am »
I've never worked with threads before, so, this would be useful to preserve how much work you put the computer through? Kind of like.......optimization? Thanks again for helping me man! You broke this down for me, and I don't know how to repay you!

No problem. The computer actually would be doing the same amount or slightly more work, but it could potentially do the work faster because it has broken the problem down into smaller parts, and can do each of these smaller parts at the same time (any threads you create can be run a different non-busy processor core, if available). Creating and joining threads does incur a small performance overhead though, so this is more likely to be faster the larger the tree is. I just thought it was worth mentioning, because in the past decade processors haven't gotten that much faster, but they are more capable of running things (eg threads) in parallel, as a consequence of having more cores.

Some problems lend themselves to parallelization, while others do not. Parallelization requires steps to be independent because threads can start in any order and run at the same time. For example, traversing binary tree subtrees can be considered independent. If you were to traverse the right subtree before the left one, or do them both at the same time, it wouldn't make a difference, because there are by definition no dependencies between the two subtrees.

Here's a famous article about concurrency and why it is increasingly relevant:

Oh I am defiantly going to have to look into that. That sounds really important!

Alright, so, I am checking out your code, and have a few questions and then I should be good to go.

The TreeNode struct I understand, but this part "   TreeNode() : leftChild{ nullptr }, rightChild{ nullptr } {}  // Change to ctor style initialization if you're not using c++11"

I'm assuming because my teacher has never mentioned ctor to us, that I don't have to use that style of initialization? Also, is that line of code just putting a null value into the left and right child?

As for the traverse function, that's just identifying if a left and/or right child exists? So if I wanted to do preorder traversal, I believe that prints out all the values in the left side of the tree first, and then the right, right? So, if I had, lets say, five nodes on the right side of the tree, and four on the right, would I just need a variable to keep track of the amount of nodes on each side of the tree, and then just loop the traversal by that value?

As for the main function, I've never actually put anything in the "(" ")" before, could you explain that to me?

Thanks again for your help and support man. Seriously means a lot to me! Sorry again for posting a general C++ question on these forums, I promise I will keep to SFML after this!

General / Re: [Q] Traverse a Binary Tree
« on: July 01, 2016, 03:05:04 am »
Also worth considering that DFS can easily be done in parallel (manually unrolled first stage for readability, although it would be more extensible if done programmatically based on detected hardware parallelism, also this example doesn't account for all possible corner cases).
Code: [Select]
void beginParallelTraversal(TreeNode * pNode) {
if (pNode->leftChild) {
std::cout << "Found left child" << std::endl;
std::thread worker(traverse, pNode->leftChild); // Do half the work on a separate thread
if (pNode->rightChild) {
worker.join(); // Wait for the other thread to finish
} else {

I've never worked with threads before, so, this would be useful to preserve how much work you put the computer through? Kind of like.......optimization? Thanks again for helping me man! You broke this down for me, and I don't know how to repay you!

General / Re: [Q] Traverse a Binary Tree
« on: June 30, 2016, 03:59:07 pm »
Binary trees are fairly simple, in this case even simpler since your structure doesn't need to fulfill the search tree property. They're really just a collection of nodes where each node has at most two children.

So for example, a tree node:
Code: [Select]
struct TreeNode {
TreeNode * leftChild, * rightChild;
TreeNode() : leftChild{nullptr}, rightChild{nullptr} {}  // Change to ctor style initialization if you're not using c++11

Then to traverse, you could simply start at the root (the initial node), and explore it's non-null children, children of children, etc.

You might want to look into existing graph traversal algorithms, Breadth First and Depth First traversal are fairly simple.

Of course, an easy recursive solution is fine if your tree is reasonably shallow.
Code: [Select]
void traverse(TreeNode * pNode) {
if (pNode->leftChild) {
std::cout << "Found left child" << std::endl;

if (pNode->rightChild) {
std::cout << "Found right child" << std::endl;

int main(int argc, char ** argv) {
TreeNode node1, node2, node3;
node1.leftChild = &node2;
node1.leftChild->rightChild = &node3;

The above is a variant of depth first search (adapted for binary trees).

Arrays can be a more compact way of storing a binary tree, especially if tree nodes contain only numerical values, but methods of traversing them when stored this way are not immediately obvious (require math), so I showed it with structs.

Man! This is exactly what I needed! I KNEW I was over complicating this! It makes so much more sense with your example! Every other example I found was using Classes, Stacks or Queues, and I haven't learned those yet. So, having this as a foundation is going to make it a lot easier to build upon it, to more advanced methods of doing this. I'm going to play around with this when I get to work and let you know how it goes, thank you so much for your time and help Evan!

Pages: [1] 2 3