Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

118 Neutral

About babaliaris

  • Rank

Personal Information


  • Github
  • Steam

Recent Profile Visitors

1154 profile views
  1. The scene contains a reference to the game object (I call it Core).
  2. LOL yes this is perfect, but I would like to make things more generic just for learning purposes. I mean, how does Unity3D succeeds that? I have years to use unity, but I remember that i had that problem and unity would had a way of dealing with this. Hmm that seems really interesting. If i understood correctly, this is going to be like a general purpose script runner that the Client can use to add scripts in there that are going to be independent from scene or sprite objects? In other words, these scripts are going to be alive until the entire application shuts down? Actually this is the solution of my problem lol! I just learned something new after a long time! Thank you!
  3. Hello! I'm creating a 2D game engine for a game I wan to make for the Game Off jam. I'm trying to figure out the best way to keep data when loading a new scene. In order to make you understand exactly what I mean, I must explain to you briefly how my engine works. A game is being constructed by Scenes. Each scene contains an std::vector(Sprite *), containing all the sprite objects of the scene. Each Sprite object has an std::vector(Brain *) , where each brain object is just a script, or you can name them components. When a new scene is getting loaded, the old scene get's destroyed which means that all the sprite objects are getting destroy including their brain objects. This made me find a problem. If I have a brain script for the inventory system of the player, when loading a new scene, the brain object inside the player which describe's the inventory system will get destroyed, so I will loose all the data about items etc. One way of solving this is to mark sprite objects as scene_independed, which means that after these objects have been created, every time you call the LoadScene() , first add all the scene_independed sprites from the old scene to the new scene and then destroy the old scene. Something like this: void LoadScene(Scene *new_scene) { if (this->scene != NULL) { //Move all scene_independed sprites to the new scene. for (Sprite *sp : this->scene->getSprites()) { if (sp->scene_independed) { //Move sp to the new scene. new_scene->addSprite(sp) //Pop sp from the old scene //to prevent it from getting destroyed //after calling delete this->scene. this->scene->popSprite(sp) } } //Delete the old scene. delete this->scene; } this->scene = new_scene; } The reason I created this thread was to take Advises. This is the first time I'm doing something like that and i want to know if there are better solutions.
  4. babaliaris

    How to rotate a cube properly?

    So this is what quaternions do in game engines like unity3D? Oh i didn't know that, so actually I'm not there yet. So in other words I'm rushing to things I haven't seen yet. I searched it a little and I found out that quaternions are actually mathematics (extension of the complex numbers to 4 dimensions). Well I have a really good background in mathematics but never new that quaternions are actual maths. It seem like I have to study and learn them
  5. babaliaris

    How to rotate a cube properly?

    Yes now it works! But still when I rotate the cube in all axis using the code below: //Initialization m_rotation.x = 0.0f; m_rotation.y = 0.0f; m_rotation.z = 0.0f; //Is getting called every frame MainGameLoop() { m_rotation.x += delta_time; m_rotation.y += delta_time; m_rotation.z += delta_time; } I get this behavior: Is this behavior what I should expected? When you rotate in all axis is difficult to understand what is the total rotation... It seems like the cube change directions and then start's to rotate backwards that it did in the beginning.
  6. babaliaris

    How to rotate a cube properly?

    I don't understand what do you mean with that. If you mean the order of rotations, first I rotate on the X axis then Y and finally Z.
  7. babaliaris

    How to rotate a cube properly?

    Video One: //Initialization m_rotation.x = 0.0f; m_rotation.y = 0.0f; m_rotation.z = 0.0f; //Is getting called every frame MainGameLoop() { m_rotation.y += delta_time; } Video Two: //Initialization m_rotation.x = 90.0f; m_rotation.y = 0.0f; m_rotation.z = 0.0f; //Is getting called every frame MainGameLoop() { m_rotation.y += delta_time; } So actually what you are saying is that what I see on the second video is the expected behavior? There's nothing wrong?
  8. So, I've noticed that when you rotate a cube in local coordinates you somehow rotate the axis as well. If you try to rotate a cube 90 degrees on the x axis and then try constantly rotating it on the y axis, you will see the cube rotating on the z axis instead of y. In order to give you a better understanding for my problem, check the following: Rotating the cube on the Y axis with initial rotation (0,0,0) Rotating the cube on the y Axis with initial rotation (90,0,0) In the second video, I was expecting to see the cube rotating around the Y axis, not the Z. This is exactly the effect that you get if with the initial rotation (90,0,0) the Y axis rotates as well (and now lying on the floor ) becoming the Z axis. Is this what is actually happening? So how can I rotate the cube without rotating the actual local Axis (Just rotating the cube around the Axis in local space)? This is how I rotate the cube before I draw: //Initialize the mvp transformations. glm::mat4 model = glm::mat4(1.0f); glm::mat4 view = glm::mat4(1.0f); glm::mat4 proj = glm::mat4(1.0f); //Translate. model = glm::translate(model, m_pos); //Rotate the model. model = glm::rotate(model, glm::radians(m_rotation.x), glm::vec3(1.0f, 0.0f, 0.0f)); model = glm::rotate(model, glm::radians(m_rotation.y), glm::vec3(0.0f, 1.0f, 0.0f)); model = glm::rotate(model, glm::radians(m_rotation.z), glm::vec3(0.0f, 0.0f, 1.0f)); //Scale. model = glm::scale(model, m_scale); //View. view = m_core->m_cam->GetView(); //Projection. proj = glm::perspective(glm::radians(m_core->m_cam->m_fov), (float)m_core->m_width / m_core->m_height, 0.1f, 100.0f); //Set the tranformation matrices on the shader. m_program->SetUniformMat4f("model", model); m_program->SetUniformMat4f("view", view); m_program->SetUniformMat4f("proj", proj); //Draw Call. glDrawArrays(GL_TRIANGLES, 0, 36); And inside the vertex shader you can guess what I'm doing: gl_Position = proj * view * model * vec4(aPos, 1.0f); My mind goes to the same technique I learned about the camera system. There, I learned that I had to create 3 vectors (up, left and front) which actually are going to define a new coordinate system with origin the center of the camera. Do I have to do the same thing here? Each cube will have 3 vectors which they define a new coordinate system with origin the center of the cube (this will be the local coordinate system of the cube) and then use somehow these vectors to rotate the cube accordingly. Can you give me some examples? Thank you!
  9. I'm reading this tutorial and trying to understand how the depth testing works but I'm not sure I understood it correctly. Lets say that we have the default comparison method (LESS). Then what is the algorithm that determines if a fragment will be discarded or get draw? Is it something like this?: bool DepthTest() { //Depth Testing Passes. if ( depth_buffer[i] < currentFragment[i].z ) { depth_buffer[i] = currentFragment[i].z; return true; } //Fails. else return false; } Also I have a hard time figuring out how does openGL for each fragment know's with what value of the depth buffer to compare with (as you can see i used an i index but I didn't determined what this i is). Does it compare each fragment's z value with all the values inside the depth buffer? The tutorial which I'm reading does not make this enough clear for me.
  10. babaliaris

    How to sample a random sprite texture?

    Thank you guys! This is more complicated than I thought. I will stick with existing tools first to understand how they work and I'll see what's next.
  11. babaliaris

    How to sample a random sprite texture?

    So there are places on the web where you can find textures with the meta data too? If I understood correctly, your way of automating them is somehow to have an algorithm that finds the texture coordinates using pixel calculations? This sounds difficult
  12. babaliaris

    How to sample a random sprite texture?

    Only one texture will be loaded into the GPU (the sprite sheet texture). Then inside the fragment shader i want to use the appropriate texture coordinates to take only the part of the texture (some figure) which I'm interesting in. Actually the system will display each figure separately and let you decide which goes to which sprite object. To not confuse you more, If I know the texture coordinates for each figure into the sprite sheet then i have enough information to know what to do next. So is there a way to know these coordinates?
  13. Let's say you have a random sprite sheet like this: How can you sample from it? I want to create a sprite system which you give it a sprite texture sheet and automatically samples from it and creates different textures. I really don't have a clue how to do this. The only think i can do now, is to manually try different texture coordinates for each figure i see on the texture (somehow to guess the texture coordinates for each figure) and then try them to see if I'm getting the correct part from the sprite sheet and if not depending on the output, i adjust the texture coordinates (a little to the left, or right or bottom or top) in order to get the part of the texture i want. This is cumbersome and does not allow me to create an automatic system for that. If only I knew the texture coordinates for each figure that would be easy. So am I missing something? Just downloading images from google is not enough? Do i need to find a special sprite sheet format or something which the creator already includes the texture coordinates too? Thank you.
  14. babaliaris

    How to start for newbie?

    First of all you must know at least the basics of programming. Then your best option like @Rutin said, is to start with unity and c# . Unity is great and has amazing tutorials and support for you to learn. You just need to be a little familiar with object oriented programming and you are good to go! A very dissent video series for c#: The New Boston C# Series (Of course it's always better to buy a good book to read. Books are always better for learning). You can find some books here. To start learning with unity visit this page and you are good to go! Don't forget to navigate more on the unity web site, they have awesome stuff to teach you! I think this is the easiest way to start with game development.
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!