|
quote:My problem is that I'm absolutely terrible with (OO) design and I usually either A great design is great and all, but at some point you just have to suck it up and work with/around the flaws that turn up in your design as you go. The art is in corectly determining when that point is. I've found that, for me, the design 'pattern' that works best is to structure everything like a tree - I have a "game" object that contains everything else related to the game contents, and an "engine" object that contains all the DX/whatever functions and object management. Within 'game' I have a 'screen' that contains all the features of a menu screen or game screen (the screen pointer changes to a new object, kind of like you might do with creating a new window in normal Windows programming). Also like Windows I have lists of button objects and such contained within the menu 'windows', almost as if I was reimplementing all of the Windows GUI from scratch. The reason I say it's like a tree is that you can basically get to *anything* game-data-related from the single 'game' pointer. Ideally you don't want to have to tunnel down like that, it's bad like global variables, but what it means is that when you come to write something later and realise you don't have a good interface for it, and you only want to do it in one little case anyway, you can always bodge out the data you want. Also it means you can pass groups of data to functions, eg. my current project has a 'room' object within 'game', and a list of 'things' within 'room', where 'things' are either players, exits or objects. It makes it easier to write functions that act on stuff within the room, such as a collision detection functions - you can pass the room pointer, rather than the list. And then when you later realise you also want a room map that isn't made up of 'things', like a heightmap or whatever, your collision detection function doesn't have to have its prototype changed to take more parameters. As I said in the first place, this isn't perfect and tends to make the code a little tanglier than necessary, but it's the balance between the sins of "messy" or "too neat to be usable" that works for me. Edit: another advantage of this structure is that it makes it relatively easy to back-access stuff from plugin DLLs and the like. roomforthetuna fucked around with this message at 01:24 on Aug 26, 2010 |
# ? Aug 26, 2010 01:18 |
|
|
# ? May 11, 2024 17:12 |
|
Okay, here's a potentially interesting problem. I'm working on a 2d game that uses a tile engine and makes use of torches to light your way. to match the aesthetic I'm going for, the torches will illuminate a 7 square diameter circle. Now, that's easy enough, it's just some tweaking of the inverse square law. However, the player will also have a lantern he can use that has the same illumination level as the torches but moves with the player. Because of the look I'm going for, I never want the light to be on half of a square but rather the entire square. Confused? Yeah, it's a bit weird to explain. Basically what I want to do is take the player's position and then gradually increase the light level on individual squares as the player approaches them and decreases as the player moves away from them. Instead of lighting half a square, I want to take the amount of light that would be hitting the dead center of the square and use that to determine the lighting of the square itself. My only problem is... uh... how the gently caress do I pull this off? edit: Right now what I'm planning is to use inverse square from the player position to the middle of the blocks within a certain radius of the player so I'm not checking against every block in the scene like a poorly optimised retard. Unexpected EOF fucked around with this message at 20:08 on Aug 26, 2010 |
# ? Aug 26, 2010 19:44 |
|
I'm not really sure what your question is, because it looks like you've already come up with a viable solution!
|
# ? Aug 26, 2010 20:46 |
|
Orzo posted:I'm not really sure what your question is, because it looks like you've already come up with a viable solution! It's more that I haven't coded for years and I plan to run this on limited (well, iPad/iPhone) hardware so I'm not sure if that's terribly efficient.
|
# ? Aug 26, 2010 20:47 |
|
If it's tile based and you're really only doing a handful of calculations (one for your lantern and one for each nearby torch) per tile, you should be fine. That's a very, very small amount of processing. Your optimization seems simple and rational as well.
|
# ? Aug 26, 2010 20:49 |
|
Orzo posted:If it's tile based and you're really only doing a handful of calculations (one for your lantern and one for each nearby torch) per tile, you should be fine. That's a very, very small amount of processing. Your optimization seems simple and rational as well. Plus being tile based like that I assume there will be a movement animation? So you have the entire movement to calculate the new lights and they won't change until the next movement...
|
# ? Aug 26, 2010 20:52 |
|
Yeah, but I wouldn't recommend doing that, it introduces complexity when honestly it isn't needed.
|
# ? Aug 26, 2010 20:58 |
|
If the lantern is basically just a constant circle of illumination centered on the player, couldn't you precalculate a "mask", representing the light added to tiles? Off the top of my head, I'm imagining something like this:code:
Internet Janitor fucked around with this message at 14:32 on Aug 28, 2010 |
# ? Aug 28, 2010 14:06 |
|
Internet Janitor posted:If the lantern is basically just a constant circle of illumination centered on the player, couldn't you precalculate a "mask", representing the light added to tiles?
|
# ? Aug 28, 2010 16:06 |
|
Generally in OpenGL can I index materials? I never ran into anything like that when I was manually doing OpenGL stuff awhile back, and messing with Irrlicht it doesn't seem to be obvious either. It looks like I have to go out of my way to change the material whenever I want, which means breaking up processing on something that could otherwise by a huge dump command to the GPU if I could give it all the materials up front.
|
# ? Aug 28, 2010 19:16 |
|
roomforthetuna: Sure, or just do a simple tween from whatever the background illumination level is to the sum of the mask and the background.
|
# ? Aug 28, 2010 19:50 |
|
Internet Janitor posted:roomforthetuna: Sure, or just do a simple tween from whatever the background illumination level is to the sum of the mask and the background. Just a single tile-based lighting mask wouldn't be enough to cope with those 32x32 possible lighting states per tile. But you could do it as a small lookup table of lighting masks. (All of which is still moot because what he wanted was simple enough that it almost certainly wouldn't be worth precalculating anyway, even if your processor is from 1982.)
|
# ? Aug 28, 2010 20:14 |
|
Take another look at my code-code:
If I was raytracing to take obstacles and shadows into account, it's true that a single lookup table would be insufficient.
|
# ? Aug 28, 2010 21:18 |
|
Internet Janitor posted:Take another look at my code- So I was saying that in order to duplicate the effect he currently has, but using precalculated values, he'd need a lookup table of precalculated masks that chooses an appropriate mask based on the light's position within the tile it's on. (None of this is true if his movement method resembles Nethack, with no steps smaller than a tile.)
|
# ? Aug 28, 2010 23:04 |
|
Ok, I see where you're coming from. I read his description as nethack-style tile-by-tile movement, or at least only calculating lighting to reflect that.
|
# ? Aug 28, 2010 23:35 |
|
I am trying to figure out what's going on with the viewing matrix that Irrlicht is using by default with it's absolute transformation (paraphrasing here). I put a camera at 0, 0, 30 looking at (0, 0, 0). I am finding that positive X values move leftwards. The Y and Z components look ok; positive Y moves up, and positive Z approaches the camera. At least I can understand that, but the X side kind of baffles me. How could I transform that matrix to make X move positive to the right? Or is the convention to have it go leftwards?
|
# ? Aug 29, 2010 04:49 |
|
I'm getting closer to completing work on my game and I was wondering what you guys do as far as distributing your projects? Is getting my own hosting the only realistic option?
|
# ? Aug 29, 2010 17:08 |
|
Mr.Success posted:I'm getting closer to completing work on my game and I was wondering what you guys do as far as distributing your projects? Is getting my own hosting the only realistic option? Is it open source? The usual suspects then (sf.net, code.google.com, etc.). If it's closed source you might want to try something like https://www.moddb.com. You can also try just getting a domain name and pointing it to a service like Google Sites (they brand every page at the bottom though). Getting your own hosting can be surprisingly cheap and easy though, especially if you're not expecting massive traffic (hopefully your game isn't multiple gigs). Even those stupid "Dreamhost" deals and their imitators (where they claim it's unlimited storage and bandwidth but yank your account the second it starts drawing decent levels of traffic) are workable as long as you're not expecting huge bursts.
|
# ? Aug 30, 2010 05:15 |
|
Anyone remember a website that was a place for people to suggest games that should be written? It went from incredibly detailed to increidbly vague 1 line suggestions? I think it had a tree navigation like: Front page: Simulation Sports Puzzle Action RPG Fighting FPS Then under FPS: Team based Squad based solo online only etc... Been meaning to poke through things to find something to work on lately... EDIT: It was on reddit not here that I read it and the site is http://www.halfbakery.com/category/Computer Hughlander fucked around with this message at 04:48 on Sep 1, 2010 |
# ? Sep 1, 2010 01:53 |
|
Updated my '2D Mac Game Programing' page with rotating sprites and keyboard control. Included code ends up build this program where you can fly a spaceship around the screen using the keyboard. http://www.isovega.net/macgameprog/index.php?itemid=31 Just started out playing around with SDL and Xcode so I figured I'd see if anyone else was dinking around with it.
|
# ? Sep 1, 2010 03:27 |
|
I don't know what to think of what I'm doing here so I thought I'd post here since I think the people on the Irrlicht forums are just confused. My mind has wandered from doing some kind of tile-based level editor especially since I don't really care about tiles too much and the kind of game I want to do doesn't particularly care about them other than their ability to represent level data. A decade ago (I freaked out thinking about that) I used to do a lot of Quake 2/Half-Life level editing with Radiant. Irrlicht can slurp up Quake 3 .BSP files so I went bonkers getting GtkRadiant building and made some stuff up. If you don't know how level editing works in that format, the world geometry is made up of convex surfaces that have to be fully-enclosed. Lights are explicitly given, and then a light map is generated for all the surfaces in post-processing that gives all that eerie shadowing you'd expect. Of course I neither want a fully-enclosed world nor all that shadowing, so I created two different maps that were enclosed in transparent surfaces, and skipped the lighting step so everything was totally bright. I found I could slurp both into Irrlicht and position next to each other such that they were seamless. I don't know if I'd collide at the transparent boundaries or not, but at least zooming around they could be glued together. My idea was to be able to represent my game world by linking up little sublevels together like this. Radiant isn't perfect but I know how to use it and I don't have to write a level editor if I go with it, so I thought I could try it. Does this sound completely stupid? I need to figure out if I can do lighting using Irrlicht after all despite doing no light map post-processing. I assume so but I don't know yet. If it insists on going full bright no matter what lights I decide to use, then... ehhh...
|
# ? Sep 5, 2010 07:09 |
|
Are there any actionscript 3 gurus around? I'm running into a strange issue with my swarms. Right now I can have ~300 boids flying around, and my update call takes 20ms to complete. It's hardly optimized, but that's not really the issue I want to tackle. My update function looks like: code:
Second Question: All of my boids use the same appearance (a circle with a line from the center to the edge indicating direction). The constructor for the class looks something like: code:
TL;DR: I suffer from apparently random methods taking 4-10 times as long to run. Could it be the garbage collector? How can I know? TL;DR2: I define my boid's appearance in every instance of the class, is that wrong? How can I do it better?
|
# ? Sep 14, 2010 19:47 |
|
Your Computer posted:My problem is that I'm absolutely terrible with (OO) design and I usually either Honestly I think this happens to everyone. With large projects there's no magic way to design things from the start to ensure that the entire process goes smoothly. The art of it is trying to strike a balance between these two extremes you've described. Think up a basic plan and go with it. Once you've got something workable, refactor the code until it's nicer. Then move forward, refactoring as needed. Stick to basic OOP principals such as encapsulation as they will make future refactoring easier. A rule of thumb I've been using is to refactor code after I add a new feature. This keeps me interested in the game because I'm making progress, but keeps the code from getting unmanageable. Try to anticipate what you will need later, but don't go overboard writing classes with no functionality because you'll "need them later." Instead keep the design such that you can add those classes when you need them. This isn't the best example but I'm writing a turn based strategy game that involves units. Obviously there are different types of units, so I would need classes for both the units themselves (location, hitpoints remaining, etc), and the unit types (movement points, models for display, etc). However when first creating the Unit class I didn't make the UnitType class until I already had a basic Unit class functional (I did keep it in mind however). Then I was able to focus my efforts on the UnitType class until that was working. Afterwords I refactored things to tidy them up, then moved on to the next part of the game. One last thing I would suggest is to avoid the temptation to start again "from scratch" when your code gets ugly. The code may be ugly, but it represents a lot of time and effort that you put into fixing issues that came up. Hundreds of little bugs that you've solved, edge cases that you've worked out. If you start again from scratch you'll likely run into the same issues and have to spend all your time working through them again, only to end up with code that's just as ugly. Better to just refactor the code the best you can, and accept that not all solutions are elegant. HappyHippo fucked around with this message at 17:03 on Sep 15, 2010 |
# ? Sep 14, 2010 23:12 |
|
Pfhreak posted:TL;DR: I suffer from apparently random methods taking 4-10 times as long to run. Could it be the garbage collector? How can I know? You say you're creating a 2d array every frame, but then that you're suprised that you're GC'ing every few frames. Perhaps instead of recalculating your buckets every frame you should update positions instead, so when a boid moves across boundaries, it removes itself from its bucket and adds itself to its new bucket. That should most definitely be faster. Secondly, if you're in Flash10 you can do graphics.copyFrom(source) to make a duplicate of your boid sprite from a master Shape/Graphic and just rotate the Sprite/Shape around its origin for rotation.
|
# ? Sep 15, 2010 01:14 |
|
iopred posted:You say you're creating a 2d array every frame, but then that you're suprised that you're GC'ing every few frames. Perhaps instead of recalculating your buckets every frame you should update positions instead, so when a boid moves across boundaries, it removes itself from its bucket and adds itself to its new bucket. That should most definitely be faster. Sorry, I'm not creating a new 2D array every frame, I'm clearing the contents and placing the boids in the appropriate bucket. No usage of the new keyword here, just adding and removing references to the vectors. It's actually one of the smaller operations in the set, which surprised me. You are right though, I could add a bunch of logic to determine only the boids which had changed buckets and I might get a speed upgrade. I'll have to look into it. For the second one, that's interesting. I might have to play around with this. Doesn't seem to be a performance enhancer, more of a convenience.
|
# ? Sep 15, 2010 02:12 |
|
Your Computer posted:My problem is that I'm absolutely terrible with (OO) design and I usually either Once you try and fail a few times you'll likely learn how to start structuring things for easy refactoring. Follow Single Responsibility Principle, make things as self contained as is reasonable. I'm working on a fairly 'robust' project for 1 dude, and the only thing keeping my code sane is how I break things up as I go along, perhaps a screenshot of my file structure will illustrate this. The more you make all these systems able to operate, like a previous poster mentioned, as a tree (ie: you can pick any node on the tree of your project and the rest of that branch should be able to function independently), the better time you'll have changing things as you run into problems. Simply put; isolate things. Image of my project structure, not entirely useful/informative on it's own but it might give you an idea of how a project can evolve successfully
|
# ? Sep 16, 2010 07:32 |
|
What's a better way to lock my game to a certain frequency other than SDL_Delay()? It seems like my keypresses are getting dropped if you're in a delay call.
|
# ? Sep 17, 2010 19:20 |
|
Bob Morales posted:What's a better way to lock my game to a certain frequency other than SDL_Delay()?
|
# ? Sep 17, 2010 20:31 |
|
SDL uses an event queue, not a keyboard state poll, so that shouldn't be blocking keystrokes. How are you retrieving input?
|
# ? Sep 17, 2010 20:55 |
|
code:
I need to re-do my input code because it sucks. Bob Morales fucked around with this message at 21:39 on Sep 17, 2010 |
# ? Sep 17, 2010 21:36 |
|
Problem I see there - if you pressed "left, left, left, left" within one frame, only one of them would do anything. Or if you pressed "left, left, left, right" you'd come out of the PollEvent loop with just "direction==BZ_MOVE_RIGHT" and all the lefts would be lost. And if you pressed "left" and then unpressed "left" in one frame, you come out with "direction==BZ_MOVE_NONE". Your treatment of pressing up appears to be alright though.
|
# ? Sep 17, 2010 21:54 |
|
Yeah, do the same thing for the movement options as you do for the rotation. Call another function that moves the piece and pass in the direction as a parameter.
|
# ? Sep 17, 2010 22:07 |
|
roomforthetuna posted:Problem I see there - if you pressed "left, left, left, left" within one frame, only one of them would do anything. Or if you pressed "left, left, left, right" you'd come out of the PollEvent loop with just "direction==BZ_MOVE_RIGHT" and all the lefts would be lost. And if you pressed "left" and then unpressed "left" in one frame, you come out with "direction==BZ_MOVE_NONE". I haven't looked at it in a while, I'm not sure why I split it up to handle 'up' differently. I'll try putting the movepiece() in for left/right/down and see what happens. That is what's happening, though. You can hit left a bunch of times and nothing happens, or hold it for say 1/10th of a second and nothing happens. So basically I just hold the key down until I'm as far left as I want to be.
|
# ? Sep 17, 2010 22:07 |
|
Bob Morales posted:I haven't looked at it in a while, I'm not sure why I split it up to handle 'up' differently.
|
# ? Sep 17, 2010 22:25 |
|
Probably a terrible solution, but why don't you break the poll loop whenever a keydown occurs.
|
# ? Sep 17, 2010 22:33 |
|
Let's say I want to write an Animal Crossing clone, what game engine/framework would you recommend me ? Obviously this is just a small project for fun, but this is my first 3D project (or 2.5D in that case, right?) and not having to write the core from scratch would be a nice jumpstart, especially since I wouldn'T know where to start. The language doesn't matter to me, all I reallt want is a nice game engine/framework with 2.5D support, and if it can support multiplayer (not locally, via a server) it would be awesome. This will be for PC. Any suggestions ?
|
# ? Sep 18, 2010 17:59 |
|
XNA supports both 2D and 3D and is free, is based off C#, and runs on PCs. The new 4.0 version was recently released, it is somewhat confusingly packaged as part of the Windows 7 Phone development kit, but you can just ignore the phone stuff and use the Windows Game 4.0 project template to automatically generate a base project with a timing loop and DirectX window and then code your own stuff from there. They have a 2D tutorial that was written for the 3.0 version, but it should give you an idea of what XNA 4.0 can do. There is some network support but I haven't really messed around with that part much.
|
# ? Sep 18, 2010 19:54 |
|
Alex007 posted:Let's say I want to write an Animal Crossing clone, what game engine/framework would you recommend me ? If you don't mind a proprietary framework I'd give Unity3D a look. For quick development in 3D it's one of the better solutions out there. The free version should have everything you need (though it does add a startup splash screen).
|
# ? Sep 18, 2010 22:40 |
|
Two really good suggestions guys, many thanks, I'm giving both a try right now. Took some time to get Unity running but everything is fine now that I found that it requires a DEP exclusion. Runs fine now. Unity looks like what I was looking for, it really is a game editor (with visual editor) while XNA is more of a game framework (which is fine and gives me more flexibility). Thanks !
|
# ? Sep 20, 2010 13:49 |
|
|
# ? May 11, 2024 17:12 |
|
I'm having trouble using two different textures in OpenGL (using SDL)code:
Whichever texture I load last, is the active one. Earlier in the program I have a title screen of sorts, where I load a different picture, draw it right away, and do the whole 'press any key' deal. That works fine. It's just this loop where I can't switch. If I un-comment the glBindTexture lines, I just get a blank white window. The game still plays, however (I can hear it) Click here for the full 960x502 image. Any tips? All the tutorials I have seen online just show: code:
Update: I threw glGetError()'s everywhere, not getting any (well, I was, but I got rid of them ) I inserted some glColor() calls in there, to draw the border red, sprites blue, etc, they all draw the right color but they aren't textured. It's as if everything is being drawn in all white, like when you don't have a texture selected. And it only happens when I un-comment the glBindTexture lines (works fine if I just use the texture I loaded last) Something has to be goofing up the first texture when I load the second. Although, earlier in the game I have a 'title screen' which loads through the same function, and is drawn once. After that I do the function to read the next two files from disk and make textures from them. Bob Morales fucked around with this message at 17:14 on Sep 21, 2010 |
# ? Sep 21, 2010 03:20 |