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
octan3
Jul 10, 2004
DoNt dO DrUgs

hihifellow posted:

...
Even though the program I wrote this for is a colossal mess this bit of code wasn't terrible; I'll post it if you want but it's written in c# for XNA so I don't know how much help it would be.

Not to budge in but I would love to see this if you posted it.

Adbot
ADBOT LOVES YOU

hihifellow
Jun 17, 2005

seriously where the fuck did this genre come from

octan3 posted:

Not to budge in but I would love to see this if you posted it.

Okay, a bit of background. I had all my background tiles on one big image, and would then section it off into rectangles and just draw whats inside the rectangle. If you've seen old sprite sheets it's the same thing, and in here I had both the drawn tile and its black & white counterpart all on the same sheet.

Excuse whatever ugliness is still here, my schooling with C# does not go beyond a couple web tutorials. This probably belongs in the terrible code thread, really. I think the only variables here that are not defined in the function is mplayercoords, which is a Vector2 of where the mouse was clicked in tile coordinates, and mcoords, which is another Vector2 of where the mouse click happened in screen coordinates. The whole idea behind this function is to adjust the mplayercoords variable so it has the right coordinate.

Keep in mind every example I found on the internet of how to do this was pages and pages long.

code:
        /// <summary>
        /// Checks an imagemap of the tile clicked on and the tiles around it to ensure
        /// we clicked on the right tile.
        /// </summary>
        /// <param name="mcoords">Mouse coordinates on the screen</param>
        protected void CheckTile(Vector2 mcoords)
        {
            Rectangle tile = new Rectangle(0, 128, 128, 128); //default tile on the tilemap

            bool foundtile = false;

            int tilenum = 1; //default tile number

            float mx, my, tmx, tmy;

            Vector2 pcoords = pchar.Position(); //X, Y of the player on the map
            Vector2 location = Vector2.Zero; //X, Y on the screen to "draw" the imagemap
            Vector2 center = Vector2.Zero; //X, Y of the new center basis for our imagemaps

            // Get the new center to "draw" the imagemaps from the tile that was clicked on
            center.X = centerX - ((mplayercoords.Y - pcoords.Y) * 128 / 2) + 
                ((mplayercoords.X - pcoords.X) * 128 / 2) - (128 / 2) + 64; //X is offset by 64 in our screen locs 
            center.Y = centerY + ((mplayercoords.Y - pcoords.Y) * 64 / 2) + 
                ((mplayercoords.X - pcoords.X) * 64 / 2);

            mx = mcoords.X;
            my = mcoords.Y;

            // Start from the lower right, work our way left and up
            // Height never goes above 16 so we don't need to check the whole screen
            for (int y = 7; y >= -7; y--)
            {
                for (int x = 7; x >= -7; x--)
                {
                    // Location of the imagemap drawn from the new center
                    location.X = center.X - (y * 128 / 2) + (x * 128 / 2) - (128 / 2);
                    location.Y = center.Y + (y * 64 / 2) + (x * 64 / 2) -
                        ((MapCont.ReturnHeight(new Vector2(mplayercoords.X + x, mplayercoords.Y + y)) - 
                        pchar.ReturnHeight()) * 80);

                    // The tile number of the tile we're checking
                    tilenum = MapCont.ReturnTile(new Vector2(mplayercoords.X + x, mplayercoords.Y + y));

                    // Check to see if we clicked on a pixel in this imagemap
                    if (mx - location.X >= 0 && mx - location.X <= 127 &&
                        my - location.Y >= 0 && my - location.Y <= 127)
                    {
                        tmx = mx - location.X;
                        tmy = my - location.Y;

                        // Define the loc of the pixel on the map tilesheet
                        switch (tilenum)
                        {
                            // bunch of cases to determine which black/white imagemap to use for each tile
			    // all this does is change tile to a new rectangle
                        }

                        // Get the data of the pixel itself
                        uint[] PixelData = new uint[1];
                        isobackground.GetData<uint>(0, tile, PixelData, 0, 1);

                        // If the pixel is white, we found our tile
                        if (PixelData[0] == 4294967295)
                        {
                            mplayercoords.X += x;
                            mplayercoords.Y += y;
                            foundtile = true;
                        }
                    }
                }
                if (foundtile) // No need to keep going if we found our tile
                    break;
            }            
        }

Vinlaen
Feb 19, 2008

Thanks for posting the code.

Could you also use a special mousemap? I found this one gamedev: http://www.gamedev.net/reference/articles/article2026.asp

hihifellow
Jun 17, 2005

seriously where the fuck did this genre come from

Vinlaen posted:

Thanks for posting the code.

Could you also use a special mousemap? I found this one gamedev: http://www.gamedev.net/reference/articles/article2026.asp

That's actually one of the first articles I read about this. I'm sure it works great, I just could never wrap my head around HOW to do it. It's the same idea, generating an imagemap so the engine has a better idea of where you clicked.

newsomnuke
Feb 25, 2007

hihifellow posted:

That's actually one of the first articles I read about this. I'm sure it works great, I just could never wrap my head around HOW to do it. It's the same idea, generating an imagemap so the engine has a better idea of where you clicked.
I wrote an isometric engine some time ago, and I assigned each tile and game object a unique colour, and then rendered the scene to texture using a pixel shader. Gives pixel-perfect picking (assuming your render texture is big enough). The main issue is that reading the render texture stalls the GPU pipeline, but there are ways around this.

Kennedy
Aug 1, 2006


hard to breathe?
Here's a collision detection / C# List issue I'm kinda stuck on.

I'm making an asteroids clone, and when the lasers are fired from the ship, it's only performing collision on the last entry into my BeamList.

See here http://ie.youtube.com/watch?v=xQTgsnQ5AGo&fmt=18

As a beam is fired, it's added to a List of type Beam. I then call
code:
foreach (Beam beam in Beam.BeamList)
     collisionManager.ProcessCollision(beam)
which, for debug purposes, highlights the cell in which the beam is currently travelling through. The problem resides in the fact that it only detects the last beam fired from the ship (i.e. the last entry into the BeamList). You would think that it would iterate through each beam existing in the list, but obviously it doesn't. What am I doing wrong?

I should note - I had collision detection working fine, but it was very computationally expensive (check every beam on screen with every asteroid - when I deployed it to my 360 it nearly shat itself), so now I'm only checking beams against asteroids in the same cell.


PS - this post was made because I usually solve the problem within an hour of posting myself, so here's hoping!
gently caress me, i was just setting the cellShowCollision to false in the wrong spot. Told you i'd fix it after posting!

Kennedy fucked around with this message at 17:40 on Jan 25, 2009

Vinlaen
Feb 19, 2008

Ok, what about isometric tile sizes?

Most tutorials online are using 64x32 but I can't seem to draw a perfect diamond inside that size. I've also tried 32x16 but that doesn't work either. However, 32x15 works perfectly.

How are people using 64x32 and drawing perfect diamonds inside of them?

terminatusx
Jan 27, 2009

:megaman:Indie Game Dev and Bringer of the Apocalypse
here's my attempt at 64x32 isometric tiles:





e:

here's a magnification and grid for clarity

terminatusx fucked around with this message at 03:21 on Jan 28, 2009

heeen
May 14, 2005

CAT NEVER STOPS
Can someone share insights in developing an entity system?
As in what properties, how extendable, parent-child relationship, spawning, management etc.
Is duck-typing practicable? Or a mixture of static typing and dynamic properties?

newsomnuke
Feb 25, 2007

heeen posted:

Can someone share insights in developing an entity system?
As in what properties, how extendable, parent-child relationship, spawning, management etc.
Is duck-typing practicable? Or a mixture of static typing and dynamic properties?
The answer to all these questions is "it depends on what kind of game you're developing". In the past 6 months I've written a shmup, a roguelike and a Diablo-style isometric game, and they all used very different entity systems.

Shmup: the main concern here was managing thousands of bullets, with potentially hundreds created or destroyed each frame. To this end I developed a somewhat complex system which used two static 'buffers' and swapped bullets between them as they were created and destroyed. The bullet class itself was lightweight, designed to fit into 128 bits for maximum efficiency. The other main class was Ship, which was designed to be subclassed to extend functionality.

Isometric: this was a more conventional entity system, with entities designed to be controlled by script and dynamic properties. Properties such as visuals, physics, etc are dynamically added or removed. There are no subclasses, just one base class whose behaviour is defined entirely by script and properties. Dynamic property systems are all the rage right now, but getting them running at a good speed can be a bitch (especially when there are several thousand in the world), and you'll probably have to write your own specialised containers or use a combination of existing ones. An excellent case study is Looking Glass Systems' Dark Engine, which was used for the Thief games and System Shock 2. There's a presentation on it here which, while old, is informative.

Roguelike: I used a base entity class with a very few hardcoded engine properties (position, physics, etc). Entities are extended by script, and all these extended properties exist only in the script system - duck-typing as it seems to be known. It's possible to transparently modify both script and hardcoded variables from script. This is extremely slow because it has to do a container-based lookup every time I access a property in script, but I get away with it because it's turn-based. I'm sure I will hit slowdown later on when I have more entities with more complex logic up and running; I'll cross that bridge when I get to it. All in all, extremely flexible but sloooow. As far as management goes, I don't bother with static pre-allocated arrays. It's turn-based, a little dynamic memory management won't be noticed.

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!

heeen posted:

Can someone share insights in developing an entity system?
As in what properties, how extendable, parent-child relationship, spawning, management etc.
Is duck-typing practicable? Or a mixture of static typing and dynamic properties?
Are you networking this or making a single-player game?

What language are you writing your gamecode in?

heeen
May 14, 2005

CAT NEVER STOPS

OneEightHundred posted:

Are you networking this or making a single-player game?

What language are you writing your gamecode in?

I'm writing the engine in c++ and want to add scripting in js later. For now it is single player only. I think I'm going to use the hybrid method described above:
A few fixed entity classes for things like models, lights, physics, plus a script namespace for dynamic properties to avoid the bottleneck mentioned above.

jonus
Jun 7, 2008

by mons all madden
I want to create a highly accurate colony simulator where the player develops a frozen world using only renewable energy as a power source. A territorial map would be used for placing mines, power plants, rail and power lines over great distances, while a rts/fps view would be used for colony construction. Rather then a series of connected buildings like most rts, each colony would be an arcology, a self-contained city built to minimize heat loss. As much as I want to avoid graphics, being able to walk through the arcology would be the primary pay-off for actually succeeding at the game.

I don't want to rewrite the game twice because I picked the wrong engine the first time. XNA, Orge3d, Irrlicht and Torque seem to be the major SDEs/graphic engines/ game engines recommended for 3d game development. I'll be happy to start with crude 3d graphics and focus on the game mechanics, but at the very end of the development cycle I'd like to significantly improve the graphics without having to redo everything from the start. It doesn't have to look pretty, I just don't want it to look ugly.

I'm well aware how much work this project would be, so I already hate myself for wanting to do it.

jonus fucked around with this message at 22:58 on Feb 3, 2009

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

jonus posted:

I don't want to rewrite the game twice because I picked the wrong engine the first time.

If you actually had to rewrite a game because you changed graphics engines, it would speak way more to your talent (or lack thereof) as a programmer than to your choice in graphics engine.

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!

heeen posted:

I'm writing the engine in c++ and want to add scripting in js later. For now it is single player only. I think I'm going to use the hybrid method described above:
A few fixed entity classes for things like models, lights, physics, plus a script namespace for dynamic properties to avoid the bottleneck mentioned above.
There are a couple different approaches, the big decision is whether you want to composite different specialized parts of an entity into custom objects, or extend generic objects into specialized ones.

The extension/generic approach is used in shooters a lot, it basically means almost everything derives from one main object type, a couple specialized types derive from that (i.e. projectile, vehicle, player), and everything else is an extension of one of those.

The compositing approach basically involves making entities a sort of "command center" for other subsystem instances, i.e. a monster would have references to a renderable to display it, a physics instance to interact with the world, an AI state to decide what to do, a network replication instance, etc.


Compositing is more flexible, extension is easier to work with.


Things that are constantly spawned/destroyed and have limited interactivity, i.e. particles, are generally best separated from everything else so they can be specialized and handled efficiently.

OneEightHundred fucked around with this message at 23:27 on Feb 3, 2009

krysmopompas
Jan 17, 2004
hi

Avenging Dentist posted:

If you actually had to rewrite a game because you changed graphics engines, it would speak way more to your talent (or lack thereof) as a programmer than to your choice in graphics engine.
Right, because you can simply compile on XNA or Irrlicht at the flick of a switch if your programmer dick is big enough.

The things he listed are a lot more than just "graphics" engines. They impose a lot of constraints from the asset pipeline all the way to how entities are defined, processed and how they communicate; and there is little, if any, common ground between any of them.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

krysmopompas posted:

Right, because you can simply compile on XNA or Irrlicht at the flick of a switch if your programmer dick is big enough.

The things he listed are a lot more than just "graphics" engines. They impose a lot of constraints from the asset pipeline all the way to how entities are defined, processed and how they communicate; and there is little, if any, common ground between any of them.

I'm more speaking of "what kind of programmer would 99% finish a game and then say hey wait I just spent six months writing code for an engine that I knew was crap and unsuitable to my needs". If you're using a hypothetical awful engine and you get more than 10% of the way through a project before realizing that the engine is crap, then you've got problems. You could probably save a fair amount of the game logic at that point anyway, even if you have to restructure message-passing a little.

Besides that, the question seemed to be "can I make something pretty in engine X?" and really all you need to do is look at a few screenshots to answer that.

Nevertheless, my programmer dick is big enough that all my code compiles under all languages and all APIs at the same time. :2bong:

krysmopompas
Jan 17, 2004
hi

Avenging Dentist posted:

I'm more speaking of "what kind of programmer would 99% finish a game and then say hey wait I just spent six months writing code for an engine that I knew was crap and unsuitable to my needs". If you're using a hypothetical awful engine and you get more than 10% of the way through a project before realizing that the engine is crap, then you've got problems.
Is there a Godwin-like law for invoking 3drealms yet?

I'm not sure how someone new to development is going to be able to tell the difference between an engine being unsuitable, and not knowing what needs to be done or how best to achieve it. Hell, you have tech directors of major companies unable to tell the difference as well.

Anyhow, I think the key thing from his post isn't "pretty graphics" but the combination of the rts and fps view modes. Moving a camera around is an extremely simple task, but most engines do their damnedest to only assume that one way of moving it will work with 99% of the code already written.

p.s. I am glad for your penis.

raditts
Feb 21, 2001

The Kwanzaa Bot is here to protect me.


Sorry if this has been discussed already, but what do you guys think of XNA? I've read that it's a pain in the rear end unless you're trying to develop an Xbox 360 game, because there's lots of poo poo to install and even then it might not work right. I don't suppose they've made it easier to use if any of that was true?

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

I'm not sure DNF can even be counted as a single game anymore. More like several canceled games.

krysmopompas posted:

I'm not sure how someone new to development is going to be able to tell the difference between an engine being unsuitable, and not knowing what needs to be done or how best to achieve it. Hell, you have tech directors of major companies unable to tell the difference as well.

Well, someone new to development in general is probably going to have a hell of a time making a game (except for Pac-Man or something, I guess). But I think it depends a lot on the type of project. If you're trying to make a game with bleeding-edge graphics, you're under a lot harsher restrictions, since you need to be aware of performance at all times. If you're not trying to make the next Crysis, you're afforded a little bit more leniency and can hack things in that an engine might not be well-suited for.

Extreme example: with a simple sidescroller on modern machines, you'd hardly have to worry about performance at all. That's what makes stuff like PyGame possible. Who cares about optimizations when you're already getting 1000 FPS? :)

krysmopompas posted:

Anyhow, I think the key thing from his post isn't "pretty graphics" but the combination of the rts and fps view modes. Moving a camera around is an extremely simple task, but most engines do their damnedest to only assume that one way of moving it will work with 99% of the code already written.

I'd hope that you could resolve stuff like that in the prototyping stage, which is an especially important step if you aren't 100% sure what engine you want. Besides, I was responding primarily to this:

quote:

I'll be happy to start with crude 3d graphics and focus on the game mechanics, but at the very end of the development cycle I'd like to significantly improve the graphics without having to redo everything from the start.

krysmopompas posted:

p.s. I am glad for your penis.

So am I. Compile times are pretty long though since it's an NP-hard problem. :quagmire:



tl;dr: if your game doesn't have especially high performance requirements, it probably doesn't matter too much what engine you use if you get past prototyping, since that's probably where you'll find the big problems.

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.

raditts posted:

Sorry if this has been discussed already, but what do you guys think of XNA? I've read that it's a pain in the rear end unless you're trying to develop an Xbox 360 game, because there's lots of poo poo to install and even then it might not work right. I don't suppose they've made it easier to use if any of that was true?
The latest XNA seems to have fixed most of the problems that people had with deployment in the earlier versions.

terminatusx
Jan 27, 2009

:megaman:Indie Game Dev and Bringer of the Apocalypse

Mustach posted:

The latest XNA seems to have fixed most of the problems that people had with deployment in the earlier versions.

As an intermediately-skilled programmer I set out one day to learn C# and the XNA framework. Weeks later I had a pretty sweet little prototype of a game. The ONLY issues I had that caused an immense amount of frustration was deploying it into an installer. It never seemed to work on other people's machines, regardless of what version of .NET framework they had installed. If what you said is true in that they've fixed the deployment problems in the past version, then XNA and C# gets 2 thumbs up from me, and should be no problem for an experience programmer to tackle. There's also a ton of tutorials from the XNA community to help you on your way.

Vinlaen
Feb 19, 2008

Here is the exact type of map that I'm trying to obtain: http://www.tangerinepop.com/experiments/AS2/YCollision/

Right now I have a very simple, very flat, isometric map that is rendered like this:

code:
For x = 0 to 50
  For y = 0 to 50
    tilePosition.X = x
    tilePosition.Y =y

    m_tile.position = Isometric.Math.MapToPixelPosition(tilePosition, m_tileSize)    
    m_renderWindow.Draw(m_tile)
  End for
End for
It's about as basic as you can get but it works and I also have a very simple function to translate from a pixel position to a map tile. (without using mouse maps!)

However, I'd really like to make my map a little more interesting to having sloping tiles or various height terrain. (eg. think of Final Fantasy Tactics, or the link I've listed above)

How can this be accomplished? I'm assuming that this involves changes to the rendering, collision detection, mouse picking, etc, etc. :(

Pfhreak
Jan 30, 2004

Frog Blast The Vent Core!

jonus posted:

I want to create a highly accurate colony simulator where the player develops a frozen world using only renewable energy as a power source. A territorial map would be used for placing mines, power plants, rail and power lines over great distances, while a rts/fps view would be used for colony construction. Rather then a series of connected buildings like most rts, each colony would be an arcology, a self-contained city built to minimize heat loss. As much as I want to avoid graphics, being able to walk through the arcology would be the primary pay-off for actually succeeding at the game.

I've always wanted to make this game too, but the design overhead is staggering. Every time I sit down to write this game, I inevitably lose focus, jump iterations, and crash and burn when Ogre or XNA doesn't behave quite right. I've settled for making a much smaller game that I'll actually complete (and I'm nearly at an alpha build after only 2 weeks). What sort of game projects have you completed in the past? Because if the answer is none, or the answer is "a couple, but I can't show them off here..." then there's a strong chance this project is simply too big right now.

Believe me, I want this game as much, or more than you do. I'd love to write it some day, but the amount of work that would go into it, especially if you are doing it in 3D cannot be understated.

diadem
Sep 20, 2003
eet bugz
Question: Is there a good tool for making navigation meshes or waypoints for my game?

Background:
I am making an XNA game for the 360. My game world is currently a model that is attached to the BEPU physics engine.


While the player can drive around the map on his/her own, the world is rather barren. I need to add traffic and pedestrians to my map.


What I'm looking for is a tool that will allow me to create waypoints or navigation meshes for my game so that I may add cars and pedestrians that follow them.

Optimally, the waypoints will be a series of connected points on the surface of my map model. Every connection between points can have a weight (max speed). The ability to put custom attributes on connections or points would be great too (this would allow me to tie traffic lights into connections). I don't care if everything's saved to xml, serialized C# code, or whatever - so long as as it's in a format I can open.

Is there any tool that will let me do this?

diadem fucked around with this message at 02:57 on Feb 9, 2009

diadem
Sep 20, 2003
eet bugz

raditts posted:

Sorry if this has been discussed already, but what do you guys think of XNA? I've read that it's a pain in the rear end unless you're trying to develop an Xbox 360 game, because there's lots of poo poo to install and even then it might not work right. I don't suppose they've made it easier to use if any of that was true?

If you are a .NET coder, XNA is a sinch. The community is amazing and helpful and the tools are great. The XNA developers frequent the forums and people with published games under their belt have no qualms offering great advice.

Check out these video tutorials to see how easy it is.

My only complaint is how floating points are handled. XNA is compiled into CLR code. While X86 CLR code is fine, Power PC CLR code can't handle floating points for poo poo. What this means is that you'll have to be very careful with your physics in the 360.

That's my only complaint, though. Everything else is awesome. Good tools, good community, well supported, and easy to use. I really like the idea of the peer reviews allowing anyone to put their game on the x-box, even if it does let a lot of crap in.

edit: If you are making a windows game, XNA may not be the best, but it is still easy. With Visual Studio 2008 and XNA 3.0, you can simply right click your project and click publish to create an installer.

When a user runs your installer, it will automatically download any missing dependencies (like the latest .net framework). If you want to publish your windows game to the 360, just right click your windows project and select "create a 360 version." There are a few exceptions, but most are obvious. The debugger even works with the 360 - you can put in break points in your code while the 360 is running and they will work seamlessly.

diadem fucked around with this message at 02:55 on Feb 9, 2009

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!

diadem posted:

What I'm looking for is a tool that will allow me to create waypoints or navigation meshes for my game so that I may add cars and pedestrians that follow them.

Optimally, the waypoints will be a series of connected points on the surface of my map model. Every connection between points can have a weight (max speed). The ability to put custom attributes on connections or points would be great too (this would allow me to tie traffic lights into connections). I don't care if everything's saved to xml, serialized C# code, or whatever - so long as as it's in a format I can open.

Is there any tool that will let me do this?
There isn't really a tool for waypoints specifically, but you'd probably want to make an in-game editor for it, simply because you get much better waypoints if you can already confirm a point can be navigated to, and you can get a precise feel of its location.

Editing attributes may be a bit more difficult to get the UI for, but you could probably do the whole thing in-game if you wanted to.

heeen
May 14, 2005

CAT NEVER STOPS
What do you guys think of the Blender game engine?

diadem
Sep 20, 2003
eet bugz

OneEightHundred posted:

There isn't really a tool for waypoints specifically, but you'd probably want to make an in-game editor for it, simply because you get much better waypoints if you can already confirm a point can be navigated to, and you can get a precise feel of its location.

Editing attributes may be a bit more difficult to get the UI for, but you could probably do the whole thing in-game if you wanted to.

This is a very interesting idea. I never even considered this. Thanks :).

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!
Actually another thing to consider with waypoints is autoconnection. Half-Life series games do this and it cuts out a lot of work, just write something that attempts to simulate a walk between any nearby points to get the connections up automatically. Cache the results though, it can be a very slow process. You can always assign attributes to points to control which ones will be navigated, i.e. flag sidewalk points as such so they don't cut through alleys or whatever.

Crazak P
Apr 11, 2003

PUNISHER > SPIDERMAN
Could someone explain calculating wind for 2D projectile motion?

So we start out with projectile motion without wind. The following equations calculate the x,y position of the object, assuming we're using earth gravity.

x = vx * time
y = vy * time - 0.5 * g * time^2

I assume wind is just another force acting on an object. I only want the wind to go in an x direction.

Do I need a drag coefficient? If so, we can use 0.5. Also, if we need mass we can just just 1kg.

I just need this to be a simple model. If someone could give me the equations for x and y, and explain how they got it, I'd be really appreciative. Thanks

Crazak P fucked around with this message at 00:00 on Feb 11, 2009

Freakus
Oct 21, 2000
I've been re-designing multiplayer roleplaying text game I made a few years ago, and wanted some input on an idea I had to get around a problem in my previous game.

The problem is, on the server side, nothing is ran concurrently. This caused issues when we wanted to implement long running commands. So if a player's command takes 3 seconds to run, all players don't have their commands processed for 3 seconds.

We can't just blindly run each command in a separate thread. However, most have relatively limited context. The idea is to force commands to declare their "scope" upfront: what they might write, and what they might read. Then, make a command scheduler of sorts, that will make sure to only run a command if nothing in its scope is in conflict with another currently running command's scope. I'm a bit concerned that having to declare a scope upfront might be cumbersome.

Does this seem reasonable? Is there a better way to go about it?

TSDK
Nov 24, 2003

I got a wooden uploading this one
Unless you're going to go for a complete fluid dynamics simulation, then anything you write is going to be an approximation. As such, you're better off figuring out what sort of motion or effect you're after, and then working towards an equation that describes that.

You could take a very simplistic approach to wind and just say that it's a constant force along X. In which case, it becomes exactly like your equation with gravity. Something like:
code:
x = vx*time + 0.5*a*time^2
Where a=f/m in the usual manner.

You can also add in very simple drag (again, constraining it to the horizontal if you so wish) by having the force vary with some function of vx. Pick a drag function to play with, plug in vx to get out f, divide by m, and plug that in as the acceleration.

Try something simple like:
code:
float speed_difference = vx - wind_speed;
float wind_force = drag_coefficient * powf( speed_difference, 3.0f );
float acceleration = wind_force / projectile_mass;
And play around with different powers and drag coefficients.

terminatusx
Jan 27, 2009

:megaman:Indie Game Dev and Bringer of the Apocalypse

Freakus posted:

I've been re-designing multiplayer roleplaying text game I made a few years ago, and wanted some input on an idea I had to get around a problem in my previous game.

The problem is, on the server side, nothing is ran concurrently. This caused issues when we wanted to implement long running commands. So if a player's command takes 3 seconds to run, all players don't have their commands processed for 3 seconds.

We can't just blindly run each command in a separate thread. However, most have relatively limited context. The idea is to force commands to declare their "scope" upfront: what they might write, and what they might read. Then, make a command scheduler of sorts, that will make sure to only run a command if nothing in its scope is in conflict with another currently running command's scope. I'm a bit concerned that having to declare a scope upfront might be cumbersome.

Does this seem reasonable? Is there a better way to go about it?

If you're willing to recreate your server, Erlang would be a good choice. There are other languages around built with concurrency in mind, but speaking from my experience with it ONLY, I'd say it'd work extremely well for a MUD server. My current game project is similar to MUDs, and Erlang processes are well-suited for message sending between one another, so "player" processes can communicate easily with "room" or "zone" processes, etc. Commands can be processed in parallel in the same manner. There's an Erlang thread around that might help you get some more info on it, too.

MasterSlowPoke
Oct 9, 2005

Our courage will pull us through
I've been doing some work with implementing collision detection in my 3d game, and after some thought it seems that capsule bounding volumes would be a good fit for my character models. I'm not sure exactly how it would work with the ground though. As I understand it, this would be the bounding volume for this crudely drawn man, and where it would rest on the ground:


Clearly he's floating a few feet off the ground. I could see it working if I then test a more accurate geometry collision test but as the characters are almost always on the ground using the bounding volume would be worthless, so that can't be the solution. I'm not really quite sure how to solve this.

MasterSlowPoke fucked around with this message at 11:26 on Feb 14, 2009

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh
Generally bounding volumes are used as an early-exit to avoid more expensive collision-detection.

MasterSlowPoke
Oct 9, 2005

Our courage will pull us through
Yeah, I got that, but how am I supposed to use the bounding volume and keep the guy on the floor.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

MasterSlowPoke posted:

Yeah, I got that, but how am I supposed to use the bounding volume and keep the guy on the floor.

code:
if( intersects(guy.capsule(),ground) )
{
    if( intersects(guy.hull(),ground) )
    {
        guy.walking();
    }
}

MasterSlowPoke
Oct 9, 2005

Our courage will pull us through
But seeing as the guy is almost always on the floor, nearly every frame I'm going to be doing a hull intersection test?

Adbot
ADBOT LOVES YOU

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

MasterSlowPoke posted:

But seeing as the guy is almost always on the floor, nearly every frame I'm going to be doing a hull intersection test?

If the capsule intersects with something, you always do a full intersection test. Using bounding volumes like that is to help you speed things up for when objects aren't near each other.

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