Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

160 Neutral

About giordi

  • Rank
  1. Thank you, the thing is that I am not making a 2D engine, I am trying to be general so I can add 3D element "easily" later on, like replace a sprite with a 3D char which still moves in 2D fashion etc, might be a bad idea overall but for now is the kind of approach I am taking. Which forces me to try to support different collision shapes or at least have the facility to extend to that fairly easily. Which this lead me to the second question, I am trying design a way in which I can support different shapes without recurring in RTTI and mem cast in order to access the specific resources defining the bounding box. What I was thinking for now was to have a series of vectors that would allow me to register bounding box pointers in it etc, which are still strongly typed. then in a smaller structure I will save an ID an a type, (so I can register this structure in a grid or similar for limiting amount of collision tests etc). This is all good an dandy but I will have to have a switch case inside my component filtering for the type but then I can call an overloaded function for the typed kind of collision, this ensure type safety and not RTTI. A bit of pseudo code to make my explanation clearer:   BBox_storage { vector<BBox2D> boxes; vector<sphereC> spheres; capsules<Capsule> capsules; ... } CmpBBox2D { resolve_collision(obj ) { vector<CollsionStruct> coll_struct; get_collision_from_grid(obj, coll_struct) for (auto coll: coll_struct) { switch (coll.type) { case BBox::BBox2D: collsion_BBox2D_BBox2D(obj, box_storage.boxes[coll]); break; case BBox::Sphere: collsion_BBox2D_Sphere(obj,box_storage.sphere[coll]); .... } } } Something on those line, how bad would it be? If I wanted to be super uber generic but with an higher level of indirection probably I could have  a map of function pointers resolving specific collision types and then compose the key of the map by merging the two types (which would be probably strings) and then access the function pointer in the map and call it. Not sure how that would be better, might have to think about it and evaluate the cost of such indirection which require string concatenation etc
  2. Hi thank you, for now I don't plan any kind of dynamics just simple collision for crating a platform style game.   Your answer is most interesting, I hope to not say a pile of crap, if I do please let me know. I am reasoning about what you said, if I have two separated structures at one point I will need to sync right? that s how I see my  update_game() loop.   1) update_position() 2) resolve_collision() (which will move the char back if collision happens to avoid interpenetration) 3) render()   so between step 1 and 2 I might need some kind of sync if they don't work on the same data? Anyway I would also like to know if usually it s common to have objects that have different volume representation to collide with each other. If so my component will need to become more bulky and to now a lot more on volume representation , aka spheres, capsules etc.
  3. Hi guys, I am currently working on a simple dummy engine to improve my programming skill and learn more about game development. I am  implementing simple 2D collision based on bounding boxes aligned with world X and Y.  I am building my overall structure  on components, so my game entity class has a pointer to a "move" and "render" component. Now I introduced  a bounding box structure and a 2D bounding box collision components. I implemented it and looks working fine but I have a couple of questions about it. First of all my components only knows about 2D bbox because that is the  one should solve, what happens if I have other shapes for collision? Like convex shapes, spheres and capsules etc. I would guess is fairly normal in a game to have to deal with different kind of collision shapes right?   If it so does it mean my components will also need to be able to solve different combinations and means knowing about all the kind of collisions shapes? ex : 2dbbox with circle, 2dbbox with convex polygon etc.   My second question is about how to organize the data  for handling the different kind of bounding boxes etc, but one step at the time, I would like to address the first question first.   Thanks guys!   PS: here what I currently have, I know looks simple but there is already a basic engine pipeline running.  
  4. giordi

    Why 2D?

    Completely agree, 2D rotation is one of the many obvious example where adding a dimension adds a lot more complexity. Or for example the difference between a sprite character and a full 3d character,  rendering and animation is much more simple in 2D (just handling sprite) then a full 3d character. This allow to limit the amount of stuff you need in place before being able to be in an iterative loop.
  5. the Hull program looks quite interesting!
  6. giordi

    GLSL frag shader position not set

    that s how i did, I generated two triangles (in yellow), i did it in clock wise order starting from bottom left. so using vertices (0,1,2), (3,4,5). You will need to repeat the matching vertices since you are not using an index buffer.  Anyway then you build a similar data structure but for the uv (in red). where i start again from bottom left, and I follow the exact same order  i did for the vertex data, after all you need to specify a uv coordinate for each vertex so make sense to follow the same order so opengl will know how to loop the data.
  7. giordi

    GLSL frag shader position not set

    naa you don't need fixed pipeline, it s legacy, buffers are perfectly fine, here check my sprite renderer component CmpSprite::CmpSprite(const string path, const uint32_t u_reps, const uint32_t v_reps) : m_path(path), m_texture(0, path.c_str()), m_u_reps(u_reps), m_v_reps(v_reps) { ANIM_RATE = Constants::TICKS_PER_SEC/12; action_counter =0; int w = m_texture.get_width(); int h = m_texture.get_height(); w /= m_u_reps; h /= m_v_reps; float hh = float(h / 2); float wh = float(w / 2); //TODO (giordi) : remove magic number and give a default from constants float z = -13; //generating the quad data float data[18]{ -wh, -hh, z, -wh, hh, z, wh , hh, z, -wh, -hh, z, wh, hh, z, wh, -hh, z}; //generating the uv data float max_u = 1.0f / m_u_reps; float max_v = 1.0f / m_v_reps; float uvs[12] = { 0.0f, 0.0f, 0.0f,max_v, max_u,max_v, 0.0f,0.0f, max_u,max_v, max_u,0.0f}; //uploading data on the buffer m_vtx.set_data(data, 18); m_uvs.set_data(uvs, 12); } so  as you can see I generate the rectangly in a similar way as you do, but I also generate  values for the uv map where basically the bottom left corner is 0,0 uv coordinates and the top right is 1,1. Then you can upload the data in the same way you normally upload buffers, of course you will need a different attribute for texture coordinates in the shaders.
  8. giordi

    GLSL frag shader position not set

    ok sorry, I don't want to throw you off road, I need to understand better your setup. By doing a quick googling looks like shader maker is a shader editor, which in your case I am guessing provides you a "plane" (2 triangles) on which you can draw with your fragment shader, in a similar fashion shader toy does correct? What is your "program" ? Are you handling everything yourself? If so I would have to have a buffer with your mesh and a buffer with the uv coordinates for each vertex. Do you have this kind of setup?   did not see @MarkS, but yeah that s basically what I am trying to figure out if you sent properly data on the gpu
  9. Hi so I  had a friend of mine grabbing the texture and drop it in game maker to make it move left and right in my same way, same exact effect on my and his machine, so I guess I can put my mind at rest and classify it as hardware problem, well guess who is gonna buy a gaming monitor soon!
  10. giordi

    GLSL frag shader position not set

    mmmm how are you uploading your texture coordinates?
  11. giordi

    GLSL frag shader position not set

    why dont you remove vec4 position = gl_TexCoord[0]; and don't use directly your coordinates? anyway I would move the above line in the main function? I am just guessing never used shader maker etc, but maybe shader maker is doing some extra step for you that in your stand alone case doesn't happen? I have a feeling that your position get set once and never computed again, thus the uniform  color
  12. so in order to make the spiral bigger or smaller you just need to scale the initial vector size, to scale a vector you multiply each vector member for a scalar, in your case your initial vector is v = [p ,0] so you actually just need to multiply p  by a factor. in this way   http://jsfiddle.net/wb1jm8xt/5/
  13. @ankhd: I have implemented two methods , I abstracted it in a "event loop" class, which allows me to run as fast as possible and/or lock to a specific frame rate, by making the thread wait a specific amount of time using a high resolution clock. Also I am using glfw that if you want you can enable vsycn and let it cap the game for you at 60 fps. I tried every combination  like glfw lock + fast render , glfw no lock + fast render , glfw no lock + event loop lock etc. All the same result no exception. I tried on different monitor, but i think the overall quality of those is the same, and also different os (linux and windows)  still same result. @hodgman, mmm unluckily I don't own an high fps camera. I will have a look if any of my colleagues got one and I will let you know.
  14. Hi i fixed your code, (this is a simplified version just to give you an idea. var element = document.getElementById('background'); var ctx = element.getContext("2d"); var flash = true; var a = 3; var numArms = 3; var num = 100; var twist = 20 var stars = 5; var start = new Date().getTime(); var button = document.getElementById('i'); button.addEventListener('click',refresh,false); function refresh(){ draw(); } function randFloat(min, max, places) { if(places > 0){ return parseFloat((Math.random() * (max - min) + min).toFixed(places)); }else{ return Math.random() * (max - min) + min; } } function draw(){ ctx.fillStyle = "white"; ctx.clearRect(0,0,element.width,element.height); for (var arm = 0; arm < numArms; arm++) { for (var p = 0; p < num; p++) { var armt = Math.PI*2/numArms *(arm); console.log(armt); var pX = (p * Math.cos((p/twist) + (armt)) - Math.sin((p/twist) + armt)); //+ var pY = (p* Math.sin((p/twist) +(armt)) + Math.cos((p/twist) +armt)); //+ ctx.fillRect(pX+element.width/2,pY+element.height/2,1,1); } } } draw(); Sorry I was not able to save directly a runnable version (maybe I need to be registered). So what you want to do is basically a 2d rotation where you start rotating more the further you get. First you might want to have a uniform distribution of the "arms" means you want to rotate each arm in equal amount to distribute it in the circle, that s why I get a ration based on numbers of arms: var armt = Math.PI*2/numArms *(arm); If you apply this to all your points you will get straight line rotated , then what you want to do is add an extra rotation based on the distance, so since I gave as assumpion we started with a flat vector pointing X so like  vec2 = [p,0], p actually represent your vector length, and I use that as a factor to add rotation, I divide it by a twist factor in order to reduce or augument the aumount of tiwst, in this case reduce otherwise was going to spin like crazy. So now you can start building on top of this example and ad back in the clouds of points for each arm etc. The drawing propbably is not the fasted option, there might be a  path line you can use to draw, or you might want to go with webgl buffer. I am not a javascript programmer so not sure what facility the browser provide you with, i would just use webgl.  Hope it helps http://postimg.org/image/mvu452hrx/
  15. HI there, I started trying to build a simple engine, the main goal for now is to get a nice structure to the code and flow in the game loop, the first milestone would be to get a character (sprite) jumping and moving in a "fake" 2D environment. Development was moving forward and fairly smoothly, I got a sprite on screen, I was flipping the different "frame" of the animation by offsetting uvs in a sprite sheet etc , all good. As soon as I added the movement component I started noticing this weird behaviour,  the texture looks slightly blurred during movement, or anyway not super sharp as when it s steady. I can see a small ghosting 2-3px behind. I recorded the screen using shadow play (60fps recording) and playing the video I get the same effect, but stepping frame by frame each frame is nice, clean and sharp. That kinda made my heart a bit at ease, thinking that it must be a refreshing issue of the monitor. But there is still something that bothers me and it is ... why so far on my monitor I did not notice any ghosting while playing? I play mostly 3d games (bf4, witcher etc ) but I play also some platform game like Ori etc ... and as far as a I can remember I don't remember those ghosting problem. Which make me think is it there anything that can be done software wise to ease this hardware problem? Or maybe is just my case of a single sprite with uniform light grey background a particularly bad case?  
  • Advertisement

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!