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
POKEMAN SAM
Jul 8, 2004
Collision Detection questions:

Okay, so I have a 2D game (Pygame) that I wrote for one of my classes, and I was wondering what the next step to improving my collision detection system would be.

My constraint is that I have up to three collision rectangles (all axis-aligned to the world) per object (different objects have different sized rectangles and may not have all three,) plus one encapsulating rectangle that I use for primary collision detection. The three collision rectangles are a Hitbox (chest) a Walkbox (feet) and a selection rectangle (for UI stuff mainly.)

Right now I use a plane-sweep algorithm where I sweep across and keep track of all of the potential collisions based on the encapsulating bounding box, at which point I pass each pair into the collision handler, which based on the type of the two objects in collision, determines the behavior, specifically things such as whether or not two characters are colliding at their Walkbox (if not, ignore the collision) and handle the collisions.

The system works fine for up to around 100 objects on screen, but after I start getting around 150 objects, it slows down quite a bit, which is why I'm wondering what the next logical step would be. I'd like to drop the plane-sweep method and go for something more robust, but I don't know what direction to look at this point. The constraints should remain the same throughout the project, the only thing really changing is the number of objects handled by the detection algorithm.

Adbot
ADBOT LOVES YOU

POKEMAN SAM
Jul 8, 2004

Subotai posted:

Does anyone know how to render a billboard using screen-space coordinates instead of world space in D3D? I want to put a billboard at x,y screen space coordinates.

You'll want to use the inverse of your World-To-Screen Matrix to find a Screen-To-World Matrix to transform your points with. Then you can just draw your billboards there.

POKEMAN SAM
Jul 8, 2004

gra posted:

I'm working in DirectX/C++ just now. At the moment, I move things along the x and y axis and rotate them around the z axis - but I want to move the object "forward" along the heading it's been rotated to (I'm thinking asteroids - where the ship moves along the direction it's heading). Any idea/tutorials on how to do this?

Just some simple vector math, really. Instead of moving the ship 1 unit in the Y direction, to move it forward just move it cos(angle) in the X direction and sin(angle) in the Y direction. If you're not keeping an angle, and your direction is in the form of a vector, just normalize that vector (let's call it V) and move Vx * speed in the X direction and Vy * speed in the Y direction.

POKEMAN SAM
Jul 8, 2004

pianoSpleen posted:

It might seem like that's just as slow because you need to work out which sector they're in, but if you look at the heart of the problem you'll realise there's a combinatorial explosion happening (eg, the number of comparisons is always n!;

That's not true with a plane sweep algorithm. It runs across the X direction and pushes objects onto a stack, as it leaves that object's collision it pops them off. If one is pushed on there when there are already others in the stack, it adds those combinations to a list of potential collisions. Same is done in the Y direction.

I'm not naively comparing each object to every other object to determine if they're colliding or not (which would be O(N^2))

Also, how did you get a factorial number of comparisons? The most I can think of is N^2, if each object is compared to every other object.

POKEMAN SAM
Jul 8, 2004

vanjalolz posted:

Here's a question for you though. After making Pong, snake and tetris, what's next step to 3D Game Programming Mecca? Jump from the low level up to the top and work your way down again (ala pre-built game engine) or continue on the same path (build all the ground work on my own).

What I would do, in retrospect, is grab something like XNA (2.0 beta is out ;-)) and make a game in it. It handles most of the model loading (though you can extend it pretty easily to add functionality to it) and a lot of the tedious stuff that goes into making a game engine (it handles all the DX stuff for you, for example.) Basically, it's a very extensible 3D engine that gives you a few bits and pieces of what a game engine needs. You'll still have to design all your classes, figure out what to draw when, figure out all of the camera code, matrices, etc.


gra posted:

That's great, thanks! I've almost got this working with vectors (it's OK when I'm at the origin, but not when I move about, so I think I'm forgetting to multiply something somewhere). My next question then is - is there any way to get the angle you've rotated from a rotation matrix?

For the vector, you want to keep an orientation vector, not just use your vector from your position to the origin. Every time you rotate the ship, do it by multiplying the orientation vector by a rotation matrix, then that vector is your new orientation vector. Use that orientation vector to determine how to rotate the actual sprite/model, and that orientation vector (should always be a unit vector) will be the one you move along.

POKEMAN SAM
Jul 8, 2004

duck monster posted:

If you want a really basic 3D engine to play around with Panda3D is dead easy. Its very basic, and I wouldn't expect to be able to create anything remotely professional, but its a good little learning tool and its dead easy. Its a shame it doesn't seem so maintained however.

I don't see how it's so basic, I mean, it supports Cg shaders, has integrated Physics support, pretty solid model/animation support, and many other features.

POKEMAN SAM
Jul 8, 2004

PerOlus posted:

Anyone have experience, comments, about XNA? I'm interested in using it. Do I have to use C# for it?

Pretty much. There are hackish ways of using it in other .NET languages, but you're pretty much stuck using C#.

If you have any other questions about XNA, I'd be glad to help.

POKEMAN SAM
Jul 8, 2004

IcePotato posted:

Sweet, thanks.

I'm assuming the normal track is to create an engine, create editing tools, and then make levels using the tools?

Probably more likely that you'll create the engine, create some content manually, and then make the content editing tools.

POKEMAN SAM
Jul 8, 2004
Anyone familiar with the XNA XML Content Importer? I know you can read in an XML file into a standard type (like String) very easily and stick it in a variable of the corresponding type, but is there an easy way to do it with user-defined classes without writing a ContentReader/Writer? I really just want to have a class that has a few strings, a few booleans, etc. and have the Content Processor load a simple XML file into an object of the class. The problem I'm running into right now, though (without a Content Processor Extension Library) is that the Content Importer cannot find the type, e.g. in the XML:

code:
<Asset Type="GameSettings"><Title>Game Name</Title></Asset>
The Content Importer throws an error that it "Content\GameSettings.xml(3,10): error : There was an error while deserializing intermediate XML. Cannot find type "GameSettings".". I guess I just don't know where it's looking for the GameSettings type; I've tried adding the namespace to the beginning but it didn't help.

This is for something that's supposed to be lightweight, and I thought I could get away with importing an XML file into a custom class without writing a special Reader/Writer for it.


Edit: I got a simple enough system working for my needs. Thanks.

POKEMAN SAM fucked around with this message at 05:14 on Dec 29, 2007

POKEMAN SAM
Jul 8, 2004

cronio posted:

Strange -- I looked it up a few months ago to make sure, and I could've sworn it explicitly mentioned Sleep(0) as only yielding time to other threads in your own process.

Eh, looking at MSDN's paper on scheduling priorities, all scheduling is based strictly on threads, not on processes at all, except that a thread is by default prioritized based on its process's priority.

http://msdn2.microsoft.com/en-us/library/ms685100(VS.85).aspx

You'd think that if they allocated time to processes and then subdivided that into threads they would've specifically mentioned something like that.

POKEMAN SAM
Jul 8, 2004

Hanpan posted:

Is there a XNA alternative for mac development? I'm really into making simple 2d games and have been dabbling in AS3 and Python, but I'm looking for something a little more powerful.

I'd also prefer something which could be used on both Mac and Windows after being compiled.

Have you looked at the options available for Python? I know there are a couple 3D engines under Python, and those would be cross-platform, generally.

POKEMAN SAM
Jul 8, 2004

Hanpan posted:

When I say 2D game, I mean everything will be sprite / pixel based. I assume Unity is not good for things like that.

Pygame, then, is pretty much exactly what you want.

POKEMAN SAM
Jul 8, 2004

Oae Ui posted:

It also works very well with the Pymunk binding for the Chipmunk physics engine if you want to incorporate physics into your game.

According to the internet you can use Pymunk with Pygame, too.

Edit: As far as AI goes, generally I've seen it important to use lower level languages so that we can allow more "AI frames" per second to be executed. The quicker it goes, the faster it can react.

POKEMAN SAM
Jul 8, 2004

SheriffHippo posted:

(I used a C# class I found on CodeProject.com which uses a system hook to trap all mouse input)
http://www.codeproject.com/KB/cs/globalhook.aspx

Just a warning, but I've noticed some [over-]zealous Anti-Virus applications will freak out at system wide mouse/keyboard hooking because it thinks they might be keyloggers (even if only the mouse is being caught.)

POKEMAN SAM
Jul 8, 2004

MasterSlowPoke posted:

Either that, or you can have a boolean variable on your block objects that indicates whether it needs to be drawn or not.

Or you can keep the 256 objects pre-allocated and use it like a pool. Keep track of an index to the first unused object in the pool. When you create a new item, put it at that index and increment the index. When you delete an item, swap it with the item at the top of the pool and decrement the index. (When you add a new item it'll write over the old one, you don't need to explicitly delete it.) Then, when you want to draw them all, just go through the pool from 0 to index and draw all of those.

POKEMAN SAM
Jul 8, 2004

gibbed posted:

That's probably where your extra block is coming from then, given that you are reading past the end of your array into unknown data.

He already realized his extra block is coming from the 250 blocks in the array that aren't being used.

POKEMAN SAM
Jul 8, 2004

take boat posted:

Here's what I'm considering:
  • Flash: playable online, cross platform, expensive and proprietary dev tools, slow (?)
  • Silverlight: playable online, chance to learn .NET, semi-cross platform, proprietary dev tools, no one has Silverlight installed, slow (?)
  • XNA: requires .NET to play, not cross platform, chance to learn C#, Windows only dev tools, can run games on Xbox (!), fast
  • Python/Pygame: difficult to distribute, cross platform, chance to get better at Python, medium speed (?)
  • Java: Cross platform, easy to distribute, chance to learn Scala or Clojure, fast
I'm leaning towards Java (w/ Clojure), but I'd love to get some input from more experienced game makers.

What kind of 'fast' do you mean? If it's development time then Pygame will be the fastest.

POKEMAN SAM
Jul 8, 2004

Morpheus posted:

So while I was out yesterday I was talking to a friend who proposed the idea of procedural 2d dungeon generation based on a non-directed graph. Each node would be a room, and each path would be a door to another room. This way you could plan a dungeon better than just using the generation algorithms that are just carving out rooms randomly based on simple seeds. What do you guys think? I've been trying to think of how to translate from a graph to a dungeon, without just tunnels everywhere connecting the rooms, which never made sense to me.

I thought this is how it's done traditionally? This is the only way I've seen it done.

Edit: Also spring models to get everything together.

POKEMAN SAM
Jul 8, 2004

Staggy posted:

Thanks for the reply - I understood maybe 70% of the words, but I got the gist of it.

Just let me clear a few things up - would the following be valid?
code:
::file1.h::

class B;
class A
{
public:
 B *bRef;
};

::file2.h::

class B
{
 void foo();
};

Yes.

POKEMAN SAM
Jul 8, 2004

Splinter posted:

What's in vogue for creating browser games (besides Flash)?

AJAX

POKEMAN SAM
Jul 8, 2004

metztli posted:

Would this be the appropriate place to ask about using open source kit like WorldForge and Ember and the like?

If no one knows the answer, no one will reply to your post, so just ask.

POKEMAN SAM
Jul 8, 2004

Sylink posted:

I have graphics and whatnot going but I am trying to figure out collision detection.

Can anyone provide a good link or explain the logic behind it? I can't wrap my head around it easily.

Buy this book: http://realtimecollisiondetection.net/

It's really the only real advice for you.

POKEMAN SAM
Jul 8, 2004

Avenging Dentist posted:

Book owns. Doesn't really talk about collision resolution though, which I think is a lot more challenging.

Ugh, tell me about it. I've had too many problems with bounding boxes getting stuck on each other to count.

POKEMAN SAM
Jul 8, 2004

Pfhreak posted:

I'm using immediate mode currently. I have a '3D' world composed of 2d blocks. It looks something like the code posted before. The problem with textured based sorting is that sometimes I'll want to draw my stone texture first, and other times I'll want to draw my dirt texture first -- even within one cell. It completely changes the way I navigate during my draw.

That wouldn't be a problem, really, except I tested it with only one texture and didn't see any significant improvement. (1-2 fps.)

code:
// Dramatically abbreviated code
class Cell
{
  Blocktype[] blocks;
  int height;
}

class Terrain
{
  Cell[,] cells;
  Draw(Spritebatch batch)
  {
    // Determine which cells overlap the viewport
    for (y = yMinTile; y<yMaxTile; y++)
    {
      for (x = xMinTile; x<xMaxTile; x++)
      {
         // Determine which tiles in this cell are visible
         // and only draw those. Ie, if there is a block
         // above and a block in front of this tile, you will never see it
         // so don't render it.
         batch.Draw(cells[x,y].GetTexture(), cellLocationVector, Color.White);
      }
    }
  }
}

What does cells[x,y].GetTexture() do?

POKEMAN SAM
Jul 8, 2004

Avenging Dentist posted:

Just pick a minimum and maximum angle for the bullet spread and then step through that range and use sin/cos to get the x and y deltas. e.g.

θmin = 240°
θmax = 300°
n = 5
s = 10 m/s
Δθ = (θmax - θmin)/n = (300°-240°)/5 = 12°

for &theta = θmin to θmax step Δθ
    v = s ⋅ (cos θ, sin θ)
    new Bullet(v)

How does this work for one bullet? The bullet wouldn't be pointing at 270° like you'd expect it to from his drawing.

Edit: Don't you want to split the semi-circle (or whatever the arc is between min and max degrees) into n regions, and then in each of those regions fire a bullet toward the center of that region's arc? Then it would work for 1 bullet, it just means that the min and max will never actually have a bullet fired at that angle, though it will tend toward them as n increases...

POKEMAN SAM fucked around with this message at 23:32 on Apr 29, 2009

POKEMAN SAM
Jul 8, 2004

Dijkstracula posted:

If I'm not mistaken, the PS1 releases of Squaresoft SNES RPGs were simply emulated. That was probably just an attempt to cash in on existing games with a minimal amount of work on their part, though.

Chrono Trigger was also released for the DS, with new features, which is interesting.

POKEMAN SAM
Jul 8, 2004

CHEESE-kun posted:

Back with another question, I've messed around for hours but I just don't get it.

I'm basically porting this game to D3D10 as an exercise. The hills are billboards; 256 color textures that have had their mask color converted to {0,0,0,0} and are then alpha tested in the pixel shader. I calculate the texture coordinates in the exact same way as the Unreal OpenGL renderer.

However, as is clear in the picture, sometimes it seems the sampling slightly wraps around, resulting in a 1px line where the high mountains on the opposite side of the texture start. Does D3D10 just sample differently? Is there a trick I can use to catch this? I've tried shifting the texture coordinates by one texel but this results in way worse artifacts as the texture's obviously really magnified.

If I understand correctly this problem is to be expected with MSAA enabled (as the sampling kernel would wrap around), by why does it happen here, with no MSAA at all?

There was a post about this on the XNA forums last year. Unfortunately I don't remember the name of the topic, and I don't really know what to look for.

POKEMAN SAM
Jul 8, 2004

Rupert Buttermilk posted:

I'm a sound/music guy working on a mac. I really, really want to get into working with game developers in programming sound. What's my best approach? Should I learn programming, and if so, what language? Is there any way to test my work, say if I were working in something like FMOD? I have a bit of experience and understanding of Xact. I get how it works, and what sort of things it can do, albeit not completely.

I guess I mean that I'm stuck in a place where I want to help with/do sound programming, but I don't have anyone with a game that needs it, so how can I practice and hone my skills on my own?

My experience working as a programmer on a game audio tool is that you have two completely mutually exclusive choices: be an audio programmer and have no say into anything about the actual sound design, other than steering the sound designers towards using the features you want, or be a sound designer and have absolutely zero programming tasks (except maybe a scripting task or two) and be all about the sound. It sounds to me like you want to be a sound designer, and if so, you want to ready some portfolio pieces that you designed the sound for. For example, find some university student who does/did little 3d animations and fill it full of sound. When you get an interview knowing the tools of the trade will be secondary to having good examples of pieces you've designed the sound for.

POKEMAN SAM
Jul 8, 2004
Here's a good paper on how to automatically pack textures into a larger texture, too, while we're on the subject of texture atlases: http://www.blackpawn.com/texts/lightmaps/default.html

POKEMAN SAM
Jul 8, 2004

PnP Bios posted:

If you want to do stuff in .NET but don't like XNA for whatever reason, and can't stand Tao.NET, there is OpenTK, which is a quite nice light weight toolkit.

http://www.opentk.com/

This one is nice because it's actively being developed. It also works hard to be more than just a managed API wrapper. Works great in mono and .net!

If you just want the DirectX wrappings, there's SlimDX, too.

POKEMAN SAM
Jul 8, 2004

systran posted:

On the sprite sheet should I just put every frame into a 73 x 76 pixel box so that I can set one texture size and call everything up from the position on the sprite sheet?

Just do it this way (i.e. the simplest way) until/unless it's a problem. For those of you who want to pack frames in without "wasting" space, I recommend checking this out: http://www.blackpawn.com/texts/lightmaps/default.html

POKEMAN SAM
Jul 8, 2004

Vinlaen posted:

Are there any browser game engines (ie. Flash or plug-in based engines like Unity3D, etc) that are primarily 2D and support UDP?

Basically I'd like to create a multiplayer 2D game that can be played in a browser...

If you don't care about making people install a plugin, go with Unity, IMO.

POKEMAN SAM
Jul 8, 2004

Vinlaen posted:

Aves Engine looks nice... too bad it's not out yet and won't be available to indie developers.

Unity3D looks nice. Unless you pay the $1000 (or is it more?) price for the professional version you don't have direct access to sockets but instead but use their built-in networking layer. I'm not sure how well it works though. Also, how well does it handle 2D? It seems like it's built for 3D (hence the "3D" in the title, heh).

At the very least you can just write a thin wrapper for 2D that just billboards stuff.

POKEMAN SAM
Jul 8, 2004

Hubis posted:

What's wrong with RTTI?

There are better solutions most of the time that don't involve bloating the hell out of your executable ;)

POKEMAN SAM
Jul 8, 2004

gibbed posted:

Mono works pretty decently but you would have to avoid any platform specific libraries (like WinForms, though I have not kept up to date with Mono and if they have any WinForms stuff working).

quote:

System.Windows.Forms (aka Managed.Windows.Forms, MWF, Winforms) is one of the many GUI Toolkits for use with Mono and is compatible with Microsoft's System.Windows.Forms. Support for Winforms 1.1 and 2.0 has been completed, and is now in a maintenance/bug fixing state.

http://www.mono-project.com/Winforms

POKEMAN SAM
Jul 8, 2004

dogmaan posted:

I'm worried about portability because, this is going to be my project for the next six years, I use windows now, I may not some day, also when I finally go back into education this year, I wouldn't mind trying to bring some other people on board.

Let me guess, your first goal is to make an engine, then you'll figure out all the gameplay stuff afterwards!

POKEMAN SAM
Jul 8, 2004

Yakattak posted:

How do you guys find the artists for your games?

Ah, the age old question for wannabe independent game developers :) There are some posts on the XNA forums about this (like where to hunt for artists, etc.) but since you're a goon you probably just want to try stalking goon artists. Either way, if you're not paying they'll probably flake out, if you don't flake out first. Additionally, it's always a million times better to bring a lovely looking (but functional) prototype to the table when trying to find an artist.

POKEMAN SAM
Jul 8, 2004

Nev posted:

except for XNA, but that's mostly (or exclusively?) used on the indie channel.

Not exclusively, but nearly so.

POKEMAN SAM
Jul 8, 2004

Bob Morales posted:

Let's talk map file formats for a tile-based game for a second (either overhead or side-scroller)

First thought is to make up some sort of binary file spec, with a header for misc stuff then x*y bytes for the map. Would it make more sense to use some sort of text file format? For some reason something like XML makes my toenails curl, but I can see it making sense. What's a good library to use to read/write formats like that?

I'm trying to piece an editor together for maps, because right now I'm just making them in a text editor.

code:
......................i..i....
..............................
....ooooooooo.................
..............................
..............................
....x..x......................
................ooooo.........
..............................
..............................
oooooooooooooooooooooooooooooo
:downs:

There's no reason that you can't/shouldn't write an editor that works with the file format you have already, assuming the same rules are in effect (each thing that can be placed is one tile, etc.) It'd be a good starting point at least.

Adbot
ADBOT LOVES YOU

POKEMAN SAM
Jul 8, 2004

Orzo posted:

I don't have much WPF experience yet but I would guess that getting SlimDX rendered in a WPF panel is not at all esoteric. SlimDX is pretty up-to-date so I assume they'd support that.

http://code.google.com/p/slimdx/source/browse/trunk/samples/Direct3D10/WpfSample10/

Edit: BTW, if you don't have DirectX experience, I'd highly recommend using XNA, especially since their sprite support will get you pretty far without having to even worry about rendering billboards, etc. and will let you work on the fun part of your game quicker. Once you have your game logic and your graphics entities, it wouldn't be too difficult to switch to SlimDX at some point, provided your code is structured well.

POKEMAN SAM fucked around with this message at 16:16 on Nov 1, 2010

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