Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Kibbles n Shits
Apr 8, 2006

burgerpug.png


Fun Shoe
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

Adbot
ADBOT LOVES YOU

BannedNewbie
Apr 22, 2003

HOW ARE YOU? -> YOSHI?
FINE, THANK YOU. -> YOSHI.
Would you mind linking the tutorial you found?

Kibbles n Shits
Apr 8, 2006

burgerpug.png


Fun Shoe

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.

Coldrice
Jan 20, 2006


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

Dr. Dos
Aug 5, 2005

YAAAAAAAY!
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.

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!

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.
That works reasonably for an html5 turn based game. If you want to remove the wasted requests and latency then you'd want to use either a websockets (if you're willing to limit browser compatibility) or http-push solution. I use nginx and its http_push_module which works pretty well, I'm not sure what the recommended Apache solution is for http-push. This way the browser only makes one request which just waits a long time for a response, rather than pinging, and when there is a response it is sent immediately.

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

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!
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.

poemdexter
Feb 18, 2005

Hooray Indie Games!

College Slice

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. :smith:

HelixFox
Dec 20, 2004

Heed the words of this ancient spirit.

poemdexter posted:

Glyph Designer is OSX only. :smith:

:argh:

I've had some success on windows with using BMFont and then dolling up the text atlas in photoshop.

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!

poemdexter posted:

Glyph Designer is OSX only. :smith:
I don't have a mac either, but I borrowed someone's for like an hour and that was enough to get things going.

DancingPenguin
Nov 27, 2012

I ish kakadu.
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

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!
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.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
There's also the new Glyphy by a couple of the FreeType engineers at Google.

pseudopresence
Mar 3, 2005

I want to get online...
I need a computer!
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

Spasman
Nov 9, 2009

now i'm a jerk and everybody loves me
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. :3:

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.

DrMelon
Oct 9, 2010

You can find me in the produce aisle of the hospital.
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!

DancingPenguin
Nov 27, 2012

I ish kakadu.

Coot posted:



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.

Walk a few pages back.

Spasman
Nov 9, 2009

now i'm a jerk and everybody loves me

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.

DancingPenguin
Nov 27, 2012

I ish kakadu.

Coot posted:


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.

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.

DancingPenguin
Nov 27, 2012

I ish kakadu.
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).

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!
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

DancingPenguin
Nov 27, 2012

I ish kakadu.

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.

https://www.youtube.com/watch?v=TX_MbNrGWRE&hd=1

This actually looks pretty cool.
Can you access the tiles in-engine later or is it just creating a "picture"?

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!
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.

seiken
Feb 7, 2005

hah ha ha
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?

pseudopresence
Mar 3, 2005

I want to get online...
I need a computer!
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:
PERFTIMER("Render");
{
  PERFTIMER("RenderSheep");
  RenderSheep(renderContext);
}
{
  PERFTIMER("RenderMoons");
  RenderMoons(renderContext);
}
There's probably something better out there but I just wanted to write some bad easy code quickly.

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

superh
Oct 10, 2007

Touching every treasure

DancingPenguin posted:

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).

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.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

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)

the
Jul 18, 2004

by Cowcaster
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:
function OnCollisionEnter (col : Collision)
{
    if(col.gameObject.name == "sphereBlue")
    {
        Destroy(col.gameObject);
        transform.localScale += Vector3(.1,.1,.1);		
    }
}
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.

Yodzilla
Apr 29, 2005

Now who looks even dumber?

Beef Witch
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

the
Jul 18, 2004

by Cowcaster

Yodzilla posted:

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

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?

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!

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.
Both objects in a collision get the message, one after the other - the simple thing to do would be to set a flag of some kind during the first message. Probably best to add your own variable for it.

Something like
code:
protected var destroyed=false;

function OnCollisionEnter (col : Collision)
{
  if(col.gameObject.name == "sphereBlue")
  {
    if (col.gameObject.getComponent("ThisScript").destroyed) { //if the other object has been destroyed
      transform.localScale+=Vector3(.1,.1,.1); //scale this one up
    } else {
      destroyed=true; //otherwise destroy this one
      Destroy(this.gameObject);
    }
  }
}
This way the first object to receive the message is destroyed, and the second is scaled up. (Destroy doesn't actually happen until the next update, so the variable will still be around to be checked after the Destroy call.)

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).

the
Jul 18, 2004

by Cowcaster
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.

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!

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.
Eh, that would be okay too. Daft to hard-code the object name in the script if that's your goal, you could share the script and make it do "if (this.gameObject.name==col.gameObject.name)" for that result.

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

the
Jul 18, 2004

by Cowcaster
Thanks for your help. I'll mess around with it and see what happens. Was that code you gave in js?

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!

the posted:

Thanks for your help. I'll mess around with it and see what happens. Was that code you gave in js?
Ehhh, loosely. The GetComponent would need casting before you could use the variable. I was more explaining the idea than providing the code for you.

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!
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.

Yodzilla
Apr 29, 2005

Now who looks even dumber?

Beef Witch
Yeah that part I really don't understand.

the
Jul 18, 2004

by Cowcaster
I'm not sure, but there definitely are some bigger ones floating around. My knowledge on this subject isn't the best :-/

Yodzilla
Apr 29, 2005

Now who looks even dumber?

Beef Witch
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.

Adbot
ADBOT LOVES YOU

the
Jul 18, 2004

by Cowcaster

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

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply