lawnjelly

Members
  • Content count

    221
  • Joined

  • Last visited

  • Days Won

    1

lawnjelly last won the day on July 25

lawnjelly had the most liked content!

Community Reputation

1251 Excellent

1 Follower

About lawnjelly

  • Rank
    Member

Personal Information

  • Interests
    |programmer|
  1. Only had a very brief look, but wild guess, off by one error? i.e. to make a fence 10 metres long with fenceposts every 1 metre, you need 11 fenceposts, not 10... Edit .. Ah no I think I see it ... you are using triangle strip, are you using an index buffer too? You need to reset the triangle strip after each row with a degenerate triangle or something like that.
  2. It does! Ha good bit of lateral thinking lol. Just shows there is usually a way around these problems, but it always seems a bit of shoehorning a solution. As matt77hias says, the anonymous struct doesn't seem to be technically allowed in c++, but lots of people use them.. and hence the different results on different compilers I guess. Alignment sounds like it isn't likely to be a problem with casting, but aliasing bugs is a good call it sounds something to watch for.
  3. Ah, thanks for the info on the different compilers guys! I'm using gcc on linux, and it has to compile on android compiler too and probably iOS and windows. Come to think of it, if the goal is simply to reduce verbosity for access, then I could use an accessor to get to the union: struct Rect { Point2 &pos {return ps.pos;} Point2 &size {return ps.size;} union { struct { int x, y, w, h; }; struct { Point2 pos; Point2 size; } ps; }; }; I have found this doc on unions: http://en.cppreference.com/w/cpp/language/union I had no idea about the conventions of calling all the constructors / destructors as the 'lifetime' of the members changes, sounds like a nightmare lol. It almost sounds like simply casting rather than using a union is the most explicit way to do it (treat the data as binary compatible with another struct), or sticking to POD and using Hodgman's technique. Are there any gotchas (alignment etc) to avoiding the union altogether and simply casting data members to another type, out of interest? i.e. struct Rect { Point2 &pos() {return *((Point2 *)&x);} Point2 &size() {return *((Point2 *)&w);} int x, y, w, h; };
  4. Problem is not completely solved (except by Hodgman's method).. This still causes a problem: struct Rect { union { struct { int x, y, w, h; }; struct { Point2 pos; Point2 size; }; }; }; Giving : error: member 'Point2 Rect::<anonymous union>::<anonymous struct>::pos' with constructor not allowed in anonymous aggregate Point2 pos; Whereas: struct Rect { union { struct { int x, y, w, h; }; struct { Point2 pos; Point2 size; } ps; }; }; *does* compile, but it means you would have to refer to pos and size through ps.pos and ps.size. The only other way of doing this that springs to mind is a bit more hacky: struct Rect { Point2 &pos() {return *((Point2 *)&x);} Point2 &size() {return *((Point2 *)&w);} int x, y, w, h; };
  5. Just tested the c++11 unrestricted union mentioned in the article, and it does work! Just one caveat the original code: struct Point3 { union { struct { int x, y, z; }; struct { Point2 xy; // access a Point3 as either a Point3 or a Point2 }; }; }; fails to compile with error: member 'Point2 Point3::<anonymous union>::<anonymous struct>::xy' with constructor not allowed in anonymous aggregate. However this works: struct Point3 { union { struct { int x, y, z; }; Point2 xy; }; }; Hooray for c++11!
  6. Fantastico! Can't believe I didn't know that worked lol! Edit - Just tested it and my gcc compiler does suggest 'extended initializer lists needs c++11 flag'. So it is available. Out of interest, what would have been a good solution prior to c++11? I also just found this article: http://cpp11standard.blogspot.co.uk/2012/11/c11-standard-explained-1-unrestricted.html Which does suggest you can use non-POD type in a union in c++11, however in his example there is a need to name the union so you can then give it a constructor, which would seem to make the access needlessly complex, so it doesn't seem an ideal solution... Point3 pt; pt.myunion.xy.x = 1;
  7. I'm sure many of you will have come across this situation before and am wondering the most elegant way of solving it: This is an example, of wanting to create a struct/class that is an extension of a smaller version, and wanting to still be able to access the smaller version via a union. However the compiler seems to want the smaller struct to be a POD type (presumably because which constructors / destructors to call in a union is ambiguous). This is what I want, but it won't compile, complaining about Point2 being non-POD: struct Point2 { Point2() {} // want this to be default Point2(int a, int b) {x = a; y = b;} // extra constructor for ease of use int x, y; }; struct Point3 { union { struct { int x, y, z; }; struct { Point2 xy; // access a Point3 as either a Point3 or a Point2 }; }; }; The only problem is it is sometimes very useful to be able to use the 2nd constructor when passing a Point2 as an argument to a function: DrawLineTo(Point2(10, 20)); void DrawLineTo(const Point2 &pt) { ... } I am understanding there has been some changes to POD types in later c++ (I now have c++11 available), so is there any way of keeping it as a POD type while still having the secondary constructor available? I can also see alternative methods of doing the same kind of thing (perhaps not using a union). What do you guys use?
  8. Critique Vector Top Down

    I went through this exact dilemma being a programmer rather than artist. I made a bunch of animated vector art in anime studio (https://opengameart.org/content/jungle-creatures) then finally made the effort and learned blender. Vector / pixel art seems easier at first, but once you start doing animations and different view angles, and considering the texture memory needed for this, it becomes less efficient. Then when you decide to make a small change to your character you have to redo all the animations etc. Plus how are you planning to have the depth of your assets interact? How will a character get hidden by a car for example? Blender on the other hand (or maya, 3d studio etc) was difficult to learn especially the weird user interface, but after sticking with it over some tutorials I found I could make assets almost as fast as 2d art. Once you have a 3d animated model you can then either render it out in all directions, or go full-3d in game, using an off the shelf engine if you don't want to write your own.
  9. Sept 2017 Update

    Lots of improvements since moving my development to Linux. All the software has been working great, just as a recap I am using mainly QT Creator, Blender, Geany, Gimp, and Audacity. Shared Textures One of the big changes I made was to the export toolchain for static 3d models - buildings etc. Originally each model had its own texture (which got put in a texture atlas). This allows things like baked ambient occlusion, but was not very efficient with texture memory once you had lots of objects, and made it more difficult to get uniform looks, and easily change the texture 'palette'. So I improved my blender python export script to handle multiple models in the same scene, and detect shared textures. A second converter reads in the txt export and builds the binary model file to be used in game - builds texture atlases, modifies texture coords and packs the data into game friendly format. This has worked very well and I've modelled a number of new buildings, boxes, barrels etc. Map Generation I've finally improved the map generator. Initially I had been using just simple random positions of map objects, which usually resulted in a mess with buildings on top of each other etc. I have replaced this with a similar physics based spacing system I used in the old version of the game. Another snag is that buildings would often get placed on sloping ground. This looks bad in game because you get half the building underground, and half suspended in thin air. To improve this I add a flattening stage to the terrain, where the area around objects that are in a 'flattening group' gets flattened. This leads to problems of its own, like terrain 'cliffs' which are smoothed afterwards. This is still being tweaked. Actor Movement I've made some improvements to the physics - the movement speed takes account of the gradient of the land now so you no longer get fast moves up and down cliffs. The handling of elevation and altitude is also now more sensible, making the jumping and flying better. The physics is all now currently cylinder based, and you can jump (and sit) on top of other objects and actors, and pass below them. Still being tweaked .. and I need to come up with a solution for non-cylindrical buildings - I will perhaps have have some solution made with 1 or 2 orientated bounding boxes. The movement controllers for yaw, pitch and roll are also improved, now storing a velocity for each, which helps prevent yo-yoing artefacts. The bats look much better with some roll, and they also pitch in comical ways, I might have to turn that down lol. Animation Notes The animation toolchain now supports notes in the animation, to mark the frames where footsteps, attack noises etc should be. Here is a video of everything working so far: https://www.youtube.com/watch?v=ZoxT6jvvWts What is next? Next on my todo list is modelling more animals, and adding realtime bones animation for the main player. I figured bones animation was probably too expensive on mobiles for the animals, so I pre-render out their bones animation to vertex tweening animation. The same is currently true of the player but if possible I want to use bones in realtime so I can get responsive animation blending and more flexibility. The downside is I will probably have to write 3 codepaths : software skinning, and 2 versions of the skinning shader as I have read articles suggesting that not all OpenGL ES 2.0 hardware supports a standard way of skinning.
  10. There are various APIs to simplify making sounds play etc but if you want *low level*, then most platforms offer the following scheme: 1) You get from the API some access to a primary sound output buffer (which may again be mixed with other stuff by the OS but you don't need to worry about this). In the case of e.g. a typical 16 bit stereo 44.1khz this might be a sequence of 'tiles' of memory which will be played in order, when it gets to the end it loops back and starts from the first tile again. 2) Your entire job for making audio would then to be to keep this sequence of tiles filled with audio data to play. Most APIs have something like a callback to tell you when need to fill a tile, as it can happen at any time, not just when your game thread is active - if you don't fill a tile on time you will get audio corruption and glitches. As to what sound you want to play into these looping tiles it is up to you. It could be prerecorded music etc. In the usual case of sound effects for a game, you would make your own list of sounds that are currently playing, how far they are through, etc, and copy the relevant sound data across to the primary buffer when required. You can also add audio effects, reverb, delay, chorus etc depending on your audio chops. Note that the size of each tile will determine the latency, smaller tiles there will be less gap between playing a sound in your game and it 'appearing' in the sound output, but means there will be more calls to the callback and more 'housekeeping' code. Having a larger overall primary buffer will mean less chance of starving the tiles and audio glitches. If all this sounds complex, then that is what the various sound 'engine' APIs offer you, perhaps a bit less control but it does all this stuff for you. If you understand how audio works though it is pretty simple stuff (I personally haven't done 3d sound or doppler and a few things like that though), and it makes porting to a different platform a doddle.
  11. I've been making pretty good use of texture atlases in my current game, but as I find myself forced to use another texture (to enable generating tex coords for point sprites), I'm wondering if there may be a better way than currently batching by texture, and calling glBind before each batch. Instead is it more efficient to pre-bind a whole set of textures to all the available active texture slots, then simply only read from the ones I'm interested in in the fragment shaders (or call glUniform to change the active texture used by the frag shader). Is there any performance penalty to have a load of textures bound, but not being used? Is this a practical way to work on GLES 2.0, and are there any typical figures for how many active texture slots should be available on mobiles? I'm getting the impression the minimum is 8. This may make a difference as I'm having to do several render passes on some frames.
  12. First, I would double check whether a navmesh is the best solution in this scenario. They are really cool, but in a really large world, particularly with repeating assets (i.e. lots of clones of similar artwork), there might be other approaches that work well, such as simply bounding volumes around the obstacles. A lot depends on the details of your game though. Is it an RPG with trees to avoid, or a game like grand theft auto with joined buildings etc.. If you want to have such a large world, one options is to think whether you can devise a hierarchical system of navigation / pathfinding. As an example, with a building with multiple rooms, you can only travel between the rooms via doors, so you can have one system for finding the way between rooms (via doors) and one system for finding your way *within* the room, via a navmesh or whatever. If you apply this to a big world, you have a compact and fast way for doing the high level pathfinding, then you can load local navmeshes as required, presolve local navmesh A stars etc. For the sizes, you can 'push' the navmesh walls at runtime and take into account agent size in the connections, but most people seem to recommend just keeping several navmeshes at several preset agent sizes. Obviously with a huge navmesh the first option could potentially become more attractive.
  13. How do I Script NPC's? (C++)

    Firstly I'd question whether you need to be running AI updates at 60 ticks per second.. fix your timestep, and frames are irrelevant, and you can run at something far more reasonable like 10 AI ticks / second. The key thing I think you are missing, is that you probably want some AI commands to 'pause' your virtual machine until they are complete. So a command like 'walk to BLAH' could for example enter a walking state in a state machine for that NPC, and perhaps return a value to the script and resume it when complete, maybe whether it had reached the destination or not etc. Others commands like play a sound, simple maths might have no pause / resume. You might want to have a 'wait' command too. There are umpteen million different ways of doing all this of course, and a lot depends on your game and how you want to handle exceptional circumstances, like your script tells an NPC to mine some iron ore, but some time in the middle it gets attacked by a pterodactyl, and has to go into fight or flight mode.
  14. Agree. Maybe tell management that he's been trying to touch you inappropriately. Get creative. Also that idea about cutting losses and take him off active work, maybe have him build a 3d snowman, and when it comes to review time, just say he wouldn't do any work and just spent his time making snowmen etc. However other than blaming external things, maybe look at it as an opportunity for self-improvement. A large part of being responsible for other people, is getting on with them, massaging their egos, psychology, praising them etc, and making them as useful as you can, as you may not be able to hire / fire based on your personal preferences. The best outcome to me would be if you could identify something the guy was (or had potential) to be good at, and get them to concentrate on that particular thing to take work off of others, get some kind of self worth and be productive to the team instead of a drain. Have you thought about asking his advice for the team etc? Tell him you'd appreciate his input because of his greater experience. It is very likely he resents having a boss half his age. Is there any chance you could find out why he is being this way? If not through him then through his friends / coworkers (if he has any)? Is he annoyed at you, or the company, feeling undervalued, something going on in his personal life or what? Finally I'm glad you've recognised your own anger management issues - this can potentially be a massive problem in your role. It can even create exactly this type of situation, where people don't want to work with you, even people you think are 'on your side', (although I'm not suggesting it is responsible in this situation, there could be countless other reasons why he might not be being cooperative).
  15. Medieval Story released

    Awesome achievement.. I think people underestimate how long it takes a single person to make a game of this type, your blog posts over years shows it.