|
In my latest XNA project, I have a GameStateManager class which encapsulates a list of GameState objects. I use this to switch between the main menu, option screen, etc etc. Currently each state is responsible for drawing itself, but it led to a wonky dependency where spritebatch is being passed to GameStateManager, which then passes it to the state to be drawn. It works the way I intend, but it's spaghetti code. What would be a better way? Edit: Ugh never mind, I just found the relevant tutorial on MSDN. Oddly, I found it while searching for ways to create a GUI. Kibbles n Shits fucked around with this message at 06:03 on Jun 29, 2013 |
# ? Jun 29, 2013 05:46 |
|
|
# ? May 10, 2024 01:52 |
|
Would you mind linking the tutorial you found?
|
# ? Jun 29, 2013 06:23 |
|
BannedNewbie posted:Would you mind linking the tutorial you found? Sure, it's right here. It's not a tutorial in the strictest sense, but the example code is pretty easy to follow.
|
# ? Jun 29, 2013 06:26 |
It appears the chipmunk2d guys are making a port of their physics engine to Unity for use in 2d projects http://www.kickstarter.com/projects/howlingmoonsoftware/chipmunk2d-for-unity I think this is pretty neat. Honestly, I felt that chipmunk was incredibly easy to pick up and use. Really loved it in cocos2d. I'd be great to play around with it in unity for 2d projects
|
|
# ? Jun 29, 2013 08:05 |
|
I'm curious about how one properly does simple networking for a 2 player turn based, browser game. I'm going to be doing something with HMTL5 for the SA Gamedev challenege, and am unsure of what the proper way to sync data or send updates is. Right now I'm going to end up just have gamedata stored in a database with a timestamp, and then have some javascript make an AJAX call every X seconds that gets the latest info's timestamp, compares it to the last one it's seen, and if it's later, requests the whole thing. This should work fine, since it's 2 people alternating turns, there's only going to be an update when somebody's turn ends, but this does feel like a hacky solution making constant pings to the database and inducing potential latency of (if a player submits their move just after the last ping there's going to be a wait for the next ping). Or at the same time maybe this is a decent way to do things since obviously clients have to have some always open communication line.
|
# ? Jun 30, 2013 04:47 |
|
Dr. Dos posted:Right now I'm going to end up just have gamedata stored in a database with a timestamp, and then have some javascript make an AJAX call every X seconds that gets the latest info's timestamp, compares it to the last one it's seen, and if it's later, requests the whole thing. Specifically, the way I do it is to make each player 'subscribe' to a channel of their player-id, and when you make a move the server 'publishes' a message to that channel. You can either make the message contain the move, or just make it an almost blank "ask for an update now" signal, depending on what's more convenient for your implementation. (If you mostly send entire game state anyway then asking for an update makes sense, but if you mostly send single moves then you might as well put the move in the message.) This still involves storing the gamedata in a database on the server, but if your game is intended to be played in its entirety in one sitting then you could eliminate the database and just deal purely in subscribe/publish messages. Edit: "Comet" is another name for this. I wouldn't do it the PHP script way you're likely to find searching for that, since having numerous PHP scripts and associated regular httpd threads hanging around for a long time is probably a terrible idea. It might be fine if you're not planning on having your thing be popular though. http_push_module has an extremely low overhead in comparison. roomforthetuna fucked around with this message at 05:35 on Jun 30, 2013 |
# ? Jun 30, 2013 05:32 |
|
Anyone who's ever had issues with BMFont for rolling their own text rendering should definitely check out Glyph Designer. I was a little disappointed that it was $40 now (old forums posts suggests it was $20 not too long ago), but hey, it worked first try for me. The funny thing is, the data format they output is exactly the same as BMFont (a .fnt file that contains xml), but I think something was fishy about BMFont's numbers.
|
# ? Jun 30, 2013 17:13 |
|
Orzo posted:Anyone who's ever had issues with BMFont for rolling their own text rendering should definitely check out Glyph Designer. I was a little disappointed that it was $40 now (old forums posts suggests it was $20 not too long ago), but hey, it worked first try for me. The funny thing is, the data format they output is exactly the same as BMFont (a .fnt file that contains xml), but I think something was fishy about BMFont's numbers. Glyph Designer is OSX only.
|
# ? Jun 30, 2013 17:23 |
|
poemdexter posted:Glyph Designer is OSX only. I've had some success on windows with using BMFont and then dolling up the text atlas in photoshop.
|
# ? Jun 30, 2013 17:52 |
|
poemdexter posted:Glyph Designer is OSX only.
|
# ? Jun 30, 2013 17:57 |
|
E: Never mind, I'll come back should I find any problems.
DancingPenguin fucked around with this message at 23:17 on Jun 30, 2013 |
# ? Jun 30, 2013 23:14 |
|
If you want a font editor, then FontForge is the poo poo, but if you want it rendered to bitmap then you'll need FreeType and an atlas packer or something.
|
# ? Jul 1, 2013 00:05 |
|
There's also the new Glyphy by a couple of the FreeType engineers at Google.
|
# ? Jul 1, 2013 00:07 |
|
I'm working extremely slowly on a little game idea that's intended to be like KSP's map/navigation view but with proper N-body simulation, so you can get into fun and weird orbits near Lagrange points, and use low-energy transfers and the Interplanetery Transport Network. It's going slowly partly because I'm using C++ and writing everything from scratch but that's half the fun of it. I'm using SFML for input, windowing and audio; I'm using some pretty dumb and naive OpenGL for rendering. Since a YOSPOS thread about NES game development got me in the mood, I modified my prototype to use a bitmap font and render to a smaller texture before upscaling. The resolution and palette used here match what a NES could do, but it's not tile-based so I'm not sure you could achieve this on a real NES. This is just messing around, the final game needs higher resolution because I want a much more crowded Low Earth Orbit, but I like the Elite-ish feel of these. The red dots in the screenshots are the Lagrange points of the Earth-Moon system, but I've not actually managed to get into orbit near them, I am very bad at my own game and need to write some better orbit displays and other tools. Right now the simulation is N-body (N=2) but the orbits are rendered with patched conics ("patched" part not implemented) based on sphere of influence i.e. it switches to an orbit relative to the moon when you get near enough, which you can kinda see in the gallery below. http://imgur.com/a/oRUJr
|
# ? Jul 1, 2013 15:21 |
|
Sup. Hey. Here's a thing I'm workin on: http://imgur.com/a/X7g9w http://i.imgur.com/UHtVc85.gif http://i.imgur.com/YsES10L.gif http://i.imgur.com/EyL3npO.gif Have a bunch of GIFs. We're in the future now, one doesn't simply take screenshots. It has online multiplayer and stuff. It's being coded in *cough* Game maker studio *snort*. I'm using the HTTP DLL 2 extension, and so far it seems pretty decent in Studio. Seems way better then the built in socket wrap they pushed out unfinished a couple weeks ago. I know the graphics aren't wildly clever but I can't draw or animate and I'm too socially awkward to ask for help. But listen. If this actually interests you folks I could tell you more. My friends are pushing me to put it on Greenlight but it looks like poo poo from a distance so I'm not really expecting anything big out of it. Does anybody have experience in net coding a lot? I actually had to restart this project because apparently netcoding goes way deeper then OPEN SOCKET, SEND PACKET, SHOOT GUN.
|
# ? Jul 1, 2013 20:25 |
|
It reminds me of all those brutally violent stick man animations that were so popular all those years ago. Reminds me a bit of soldat too, and that's never a bad thing!
|
# ? Jul 1, 2013 20:32 |
|
Coot posted:
Walk a few pages back.
|
# ? Jul 1, 2013 20:32 |
|
DrMelon posted:It reminds me of all those brutally violent stick man animations that were so popular all those years ago. Reminds me a bit of soldat too, and that's never a bad thing! Yep! Played a lot of soldat in high school. The jet boot concept kind of bugged me and I always thought the combat was a bit slow at times, so I thought a parkour system would be a neat idea. The game features about.. 24 weapons now. 7 of them are grenade (or thrown) types. I want to put in many things soldat has, like a map maker and a script engine for servers. In the old version, I also had some pretty decent bots working and even a server list, but I've had to restart since. https://www.youtube.com/watch?v=ZH4zd1eLMno Here's a video of the old GM8.1 version. It'll end up looking similar, hopefully less chaotic. DancingPenguin posted:Walk a few pages back. Awesome. I know I've seen the Valve article but theres some cool stuff in this Tribes model. Probably the toughest things I've worked on was the delta timing and identifying clients. Wuagrhgh. The delta timing is so worth it though. It's real neat to put a modifier at the end of all movement and timing, because I can implement slow-mo and server wide pausing.
|
# ? Jul 1, 2013 20:50 |
|
Coot posted:
This game actually looks pretty much fun. I like how the shotgun shells "fall"! (Or am I just seeing things?) Yea, timing is pretty much a necessary thing to have. I suppose you have the server as the authority for this timing? Also if you do any calculations by frame (which I suppose you do), stuff might end up really weird if the server is not there and limiting the movement by said modifier. But I suppose you are capping FPS one way or another anyways. I can't really recall what place I read it in, but I think that someone said that 1/10 of a second is a good update-delay, or 1/30 for really fast games. Of course, this source is most likely not to be trusted, but just thought you might want to try it out and see if it's legit. I have not tried it out myself yet.
|
# ? Jul 1, 2013 21:30 |
|
Sorry for the double post. Spent all of my day on getting the map-editor up and running. Also physics. drat I hate it. Got a question for you fine folks, in regular top-down games, where are physics ever used except for collision with water and such objects? Collision with tiles is something I can solve by iteration, but giving the player physics feels kind of stupid, since so far it seems that this means I have to apply a force to the player for movement (which makes them slide in a very disturbing manner).
|
# ? Jul 1, 2013 23:25 |
|
I also spent all day on my level editor. I'm not used to talking to nobody / recording myself, so it felt kinda weird, but whatever. https://www.youtube.com/watch?v=TX_MbNrGWRE&hd=1
|
# ? Jul 1, 2013 23:57 |
|
Orzo posted:I also spent all day on my level editor. I'm not used to talking to nobody / recording myself, so it felt kinda weird, but whatever. This actually looks pretty cool. Can you access the tiles in-engine later or is it just creating a "picture"?
|
# ? Jul 2, 2013 00:05 |
|
Tiles are just an editor convenience--when the level is loaded, it's all entities. So no, it doesn't paint a picture, it just helps at design time.
|
# ? Jul 2, 2013 00:46 |
|
So, I've been adding a bunch of fancy rendering features and my framerate has crept below a consistent 60 FPS. So, I'm profiling with valgrind, but unexpectedly it seems to be showing a negligible amount of time doing actual rendering stuff. Of course, I don't expect valgrind to tell me what's going on in my OpenGL calls or anything. But I had hoped it would at least accurately reflect the amount of time spent making each OpenGL call at a high level. Now, it's certainly possible that what I'm seeing really is the case and my OpenGL calls take basically no time. But is it possible that, when my program is waiting for OpenGL to finish rendering, valgrind sees it as essentially sleeping (or something, I'm not sure exactly how the boundary between the CPU and GPU works), and so doesn't bother recording any samples at all?
|
# ? Jul 2, 2013 11:55 |
|
It's possible that valgrind is just so slow that it's hiding the rendering overhead. Your own code is being valground but the GPU is running as fast as ever. I usually use platform-specific timing calls to profile game code. I wrote a small timer class that wraps gettimeofday()/QueryPerformanceTimer() and then a scoped RAII thingy that prints nested timing results on shutdown. https://github.com/cswetenham/orbitalspace/blob/master/include/timer.h https://github.com/cswetenham/orbitalspace/blob/master/src/timer.cpp https://github.com/cswetenham/orbitalspace/blob/master/include/orProfile/perftimer.h https://github.com/cswetenham/orbitalspace/blob/master/src/orProfile/perftimer.cpp You have to call PerfTimer::StaticInit() at some point when you're starting up and then PerfTimer::StaticShutdown() when you're done and it'll print the results. code:
There are probably also tools that let you actually profile what's going on on the GPU. All I know of is PIX for DirectX but I found a blog post that suggests some OpenGL profiling tools for AMD and NVidia on Linux: http://blog.wolfire.com/2010/01/DirectX-vs-OpenGL-revisited
|
# ? Jul 2, 2013 13:10 |
|
DancingPenguin posted:Sorry for the double post. In 90% of the games I have ever made, physics actually overkill. In a 2d tile based game some trig will be all you ever need.
|
# ? Jul 2, 2013 15:04 |
|
seiken posted:Now, it's certainly possible that what I'm seeing really is the case and my OpenGL calls take basically no time. Yes, OpenGL calls take no time at all. You're not actually rendering in most cases, you're simply batching up commands to send to the GPU. There's really only one few place in modern GL where synchronization is required: The winsys's SwapBuffers equivalent (wglSwapBuffers/aglSwapBuffers/glxSwapBuffers/eglSwapBuffers). (There's also driver-specific swap events like INTEL_swap_event that modify how SwapBuffers timing works, but I'm assuming you don't have those enabled)
|
# ? Jul 2, 2013 18:47 |
|
Here's a consistent problem I'm having. I want two spheres, when they collide, to form into one larger sphere. So what I have is a script like this:JavaScript code:
|
# ? Jul 2, 2013 21:55 |
|
Could you just kill both of them and create a new one with the desired properties where the collision occurs? e: also are the gameObject names unique? if they're both sphereBlue then they'll both be destroyed by that code as far as I can tell
|
# ? Jul 2, 2013 21:58 |
|
Yodzilla posted:Could you just kill both of them and create a new one with the desired properties where the collision occurs? I'm not sure how to do the first, and yes, they are the same which is my problem. I was thinking of doing something like "If the object you collide with has more velocity than you, then you destroy yourself if not, then grow larger." Would that work?
|
# ? Jul 2, 2013 22:02 |
|
the posted:The problem is that 50% of the time it just annihilates both spheres. How do I have the script choose somehow which one to keep? It really doesn't matter to me, I just want it to choose one of them. Something like code:
Note, this assumes that the script is only running on "sphereBlue" objects, otherwise you'd get funky results. Edit: yes, your version that makes the decision based on the object velocity would work too, provided they would never have the same velocity. I'd go with comparing the x, y and z components of the velocity, sorting by whichever doesn't match first, rather than its magnitude, since that way it's guaranteed that the results won't be identical (because if they are then your objects wouldn't collide).
|
# ? Jul 2, 2013 22:07 |
|
It's not. I have red and blue spheres. I want red to bounce off blue, but grow/destroy with red. Same thing for blue.
|
# ? Jul 2, 2013 22:08 |
|
the posted:It's not. I have red and blue spheres. I want red to bounce off blue, but grow/destroy with red. Same thing for blue. Edit: you could also use getInstanceID(), destroy if this.gameObject.GetIntanceID() is higher than col.gameObject.GetInstanceID(), and grow if it's smaller. Those are guaranteed to not be identical. Doing by velocity has the advantage that the result is predictable to the player though. Alternatively, if you make the surviving sphere end up the same regardless (eg. by making its velocity and position the mean of the velocity and position of both spheres) then it doesn't matter which one you destroy so long as you have a way of deciding. roomforthetuna fucked around with this message at 22:15 on Jul 2, 2013 |
# ? Jul 2, 2013 22:12 |
|
Thanks for your help. I'll mess around with it and see what happens. Was that code you gave in js?
|
# ? Jul 2, 2013 22:15 |
|
the posted:Thanks for your help. I'll mess around with it and see what happens. Was that code you gave in js?
|
# ? Jul 2, 2013 22:16 |
|
Why is it only 50% of the time that both spheres get destroyed? It seems like it should be 100%, if both spheres are blue, and Unity consistently messages both game objects during collision.
|
# ? Jul 2, 2013 22:49 |
|
Yeah that part I really don't understand.
|
# ? Jul 2, 2013 22:56 |
|
I'm not sure, but there definitely are some bigger ones floating around. My knowledge on this subject isn't the best :-/
|
# ? Jul 2, 2013 22:58 |
|
Wait, what does the scene look like? Is it a whole bunch of both red and blue spheres bouncing everywhere and colliding with each other or just one of each? The original code you provided would kill both spheres if they were each blue based on that code but only one of them if the colliding spheres were blue and red.
|
# ? Jul 2, 2013 23:02 |
|
|
# ? May 10, 2024 01:52 |
|
Yodzilla posted:Wait, what does the scene look like? Is it a whole bunch of both red and blue spheres bouncing everywhere and colliding with each other or just one of each? The original code you provided would kill both spheres if they were each blue based on that code but only one of them if the colliding spheres were blue and red. It's basically 6 planes set up as walls of a cube. I have 100 red spheres and 100 blue spheres that spawn in random locations with random velocities and bounce around inside. I'm trying to simulate them colliding and clumping up to form larger objects. I originally had them sticking to each other, but the physics was so unrealistic (no conservation of angular momentum). Orzo posted:Why is it only 50% of the time that both spheres get destroyed? It seems like it should be 100%, if both spheres are blue, and Unity consistently messages both game objects during collision. I think one happens is that occasionally one of them gets destroyed before it can send the message to destroy the other, kind of like a duel. the fucked around with this message at 23:11 on Jul 2, 2013 |
# ? Jul 2, 2013 23:08 |