• Content count

  • Joined

  • Last visited

Community Reputation

170 Neutral

About chbrules

  • Rank
  1. Thanks for the info! You guys have given me some things to think about.
  2. [quote name='NightCreature83' timestamp='1351599141' post='4995370'] You can also use render lists, in this way a game object doesn't need to know how to render to screen, it just needs to know what of its data needs to be rendered. This is then collated in a list and that list is then used by the renderer to issue render commands. The benefit of this is that you can do some sorting on the render list before rendering without having to sort the scenegraph or other hierarchy in which you store your renderable data. [/quote] Great idea! Is there an example of this setup you could point me to? I learn well by example :]
  3. So I'm writing a little 2D game for fun in C++ with the SFML API. You don't need to know about it anymore than this fact: to draw a sprite to the screen you have to pass it to the draw member method of the base window class you create. I just called it "App." So basically you go "App.draw(sprite);". My problem comes to the design of the whole shabang. What I've ended up doing is simply passing a reference to "App" in the constructor of all the drawable objects. Every drawable/animated object has a draw member method (inherited from base class), so I just let it handle all the drawing itself in one convenient function I iterate through in a manager class using a pointer array of the base class. Maybe I'm just crazy, but I feel this is rather sloppy. Does anyone have any input on this? Am I being an idiot doing it this way? Thanks! [img][/img]
  4. Engine design questions

    I'm starting to develop a little 2D overhead tile-based game engine. I'm trying to design the engine layout beforehand so I don't just jump in and go in over my head here. In my design, I want to have a cPlayer class that handles all the player's movements, animation, stats, and rendering. Likewise, I want a cMap class that will handle the loading, world shifting with respect to player position, tile image loading, and rendering. My issue being, is this the best way to go about designing something like this? Should I have my classes render their own part of the engine where need be? If so, what are the best ways to share something like player position, entity positions, and the like with cMap? An issue with the design I see is messily having to reference to all the other classes to share data betwixt them. I'm not sure if that's bad design, or just how it's supposed to be. I'm a bit OCD about efficiency and cleanliness :3 Thanks!
  5. Awesome! It works. Thanks! Not really sure why it works, though. Seems kind of illogical.
  6. Consider using <canvas> and jSocket alternatively? It's not as mature as flash yet, but it's on its way to replace flash this decade imo. I'm writing a MP RPG game with it right now and I'm loving the experience. I hated AS3, but that's just my opinion.
  7. I'm using jquery to make it easy for AJAX calls. So I create a class: function cMap(mapID){//vars and stuff} I go and prototype a function: cMap.prototype.loadMap = function(){ //jquery AJAX call } Now in the jquery $.ajax({...}); call, I use an anonymous function on the "success:" call: success: function(data){ this.member = data; } My problem is that inside this anonymous function call I'm trying to call a class member of my cMap class to store the data in from the AJAX call, but it's out of scope. So the JS console in FF/Chrome throws errors about bad value/doesn't exist. How can I access this class member from inside an anonymous function? Or at least what's a good way to go about doing all this? Thanks in advance! :D
  8. I doubt you'd come close to seeing any limiting performance from either PHP's disk-based session system or MySQL querying, unless your game is somehow landing 100+ simultaneous hits on your server. That being said, make it easy and just run requests to the database. No matter what, you're still reading from the disk. Since you're not using a memory-based caching system like Memcached, and PHP's session system storing data in files on disk, the next best thing is using MySQL. Reads from MySQL should be incredibly fast, as you should be indexing all columns you use in WHERE and JOIN queries. MySQL would also scale better if your game grows in popularity.
  9. Basic Collission Detection (2D tile-based world)

    Quote:Original post by efilnukefesin here's a good tutorial (it's in flash, but theory stays the same): Thanks for the great link! Quote:Original post by Captain P How large are your maps? How many monsters/characters do exist in a typical level? Did you get things up and running already, and check if a naive implementation is too slow? Chances are that you're worrying about non-existing problems. Anyway, for visibility, it is indeed easy: you know where the 'camera' is, and how wide and high the screen is, so you can calculate how many rows and collumns to render, and at which row and collumn to start. For the enemies, currently you have to run through a list and compare their positions to the 'visible rectangle'. Sounds fine to me, but if you insist on optimizing this, you could store a grid of pointers to characters, that you update whenever a character moves to a different tile. That would allow you to skip the list, although it adds the burden of updating the pointer-grid. You'll have to test it to see how much of a difference it really makes - and again, for a small game, it's likely not worth the hassle. I haven't gotten too far yet. I have gotten the player and the map to render on the screen now after developing my map file format. I figure my next step is collission detection. Maybe just running through the list is easiest. I figure there will probably only be maybe 100 or so entities in my levels at a time. The levels probably won't be overly huge, maybe like 1000x1000 units (32x32px) max.
  10. Basic Collission Detection (2D tile-based world)

    I haven't tried anything yet, just concocted the manual way of comparing everything in the lists and then read some theory. I say it isn't as easy as it seems because I want to know if there is a better way than just comparing x/y values every loop. That's what I had already thought about doing. But, maybe, in my situation, that is the only way?
  11. My game is a 2D tile-based RPG world, with tiles being 32x32 px. I want to create a simple collission detection system for entities in the world. A player can only be on a single tile at a time. They will walk from tile to tile automatically when the user moves the character (Like the Pokemon games). This, hopefully, will make my collission detection scheme a lot easier since it's already a grid. However, after reading different approaches to the theory I've come to find that optimizing the alogrithm to only compare objects in the area of the player isn't as easy as it seems. I was wondering what the best method for me to scan a list (array) of entities (like monsters and other characters) for their visibility on the user's screen first, then only checking collissions and running their AI/operations if they're on the screen. I'm kind of trying to kill two birds with one stone; save CPU resources by detecting what's visible to the user on the screen and only running their operations. Thanks!
  12. C++ API

    I used to use SDL all the time, but I've found nothing but happiness and my wishlist of features for SDL granted with SFML. I absolutely love the API. Simple, efficient, can work it right into OGL.
  13. Is the core API of OpenGL 3D only? I mean that in comparison with 2D graphical rendering. Does OpenGL only have support for 3D rendering, although it can emulate a 2D environment, such as SDL using a polygonal face as a 2D raster-based display, or that you could simply move polygons on 2 axis and not use depth. Thank you.
  14. I just might. I'm never sure how to setup includes properly. Do includes work in a hierarchy. Say I have a class defined in a header which I include in another common header file inside another header which I finally include in the header I need. So that's nested 4 times of includes that all trace back to the one file. Is that a good way to go about it?
  15. I just put: class CMap; in my scenes.h file. It works now, but I'm still curious as to why it wouldn't find the CMap class even when directly linked to the #include.