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
Lowen
Mar 16, 2007

Adorable.

Internet Janitor posted:

Lowen: One thing that might at least simplify your project is realizing that the 3d/isometric part of the game is almost entirely visual. Mechanically, laying things out as a straight-on 2d grid is identical, and much easier to put together. Maybe you should first try building a prototype that's based on a simple grid. Keeping in mind that the 'view' for everything could change once basic gameplay is working should lead you toward decoupling game logic from rendering and input, which is a good practice anyway.

Oh, I know. Any recommendations on how to start with this though? I suspect pretty much anything would be easier than trying to do this from scratch with DirectX 9+.

Adbot
ADBOT LOVES YOU

Hobnob
Feb 23, 2006

Ursa Adorandum
Pretty much anything else would be better, but BYOND has built-in isometric support. I guess it wouldn't be too terrible an option if you wanted only sprite-based graphics and placement mostly on a (flat or isometric) grid.

poemdexter
Feb 18, 2005

Hooray Indie Games!

College Slice
XNA? Things are simple enough and then all you'd do is a matrix transformation to jerk your camera 45 degrees for the isometric part.

dereekb
Nov 7, 2010

What do you mean "error"?

Lowen posted:

Oh, I know. Any recommendations on how to start with this though? I suspect pretty much anything would be easier than trying to do this from scratch with DirectX 9+.

It depends on what you're good at programming with. If you've done Java and C++, XNA/C# is a great way to go, especially with a lot of tutorials and guides out there. You'll be working with DirectX/HLSL here. Its not bad at all once you learn the basics.

There is also the Unity SDK/engine which is free and is also recommended by a lot of dev-goons here. It is also C# based with quite a lot of support of its own. That's about all I know about that.

http://unity3d.com/



(Also as for making something "Isometric", you'd just have the camera pointed in a certain direction, and voila-Isometric! If you're making it 3d however, I hope you understand how texturing works, aren't intimidated easily by free programs (I'm looking at you Blender :argh:), or at-least learn fast.)

Paolomania
Apr 26, 2006

Lowen posted:

Oh, I know. Any recommendations on how to start with this though? I suspect pretty much anything would be easier than trying to do this from scratch with DirectX 9+.

I think you are looking for something like GameMaker. If you don't want to be doing framework code you've got to use something that handles everything from graphics engine to content pipeline. GameMaker is more high level than XNA so you will be able to get right in on prototyping. If it proves too high level just drop down to XNA.

Paolomania fucked around with this message at 03:07 on Jun 20, 2011

Woozy
Jan 3, 2006
This is a really odd question so feel free to call me a moron/suggest a much better question to ask:

A year and a half ago, I set to paper a set of rules and mechanics for a PnP RPG/Strategy board game involving robots and guns and wrote some fluff to go along with it for my gaming group and I to gently caress around with. This is about to become the second nerdiest thing I have ever done. Some friends and I have agreed to try to port the mechanics into a 2d, X-Com like turn-based strategy game. The problem is, to I'm surely virtually no one's surprise, that we have plenty of artists, writers, sound designers, and musicians, plus a full blown tested and working system/rules design to serve as proof of concept, and no one with any experience programming. Whoops!

Here's how I thought we'd try to tackle this: since we need to actually learn to program as we go, and we couldn't couldn't possibly even begin work on a big complex project without getting a number of smaller ones under our belt, I was thinking I'd start out slow by proto-proto-typing the game with individual, text-based applications to handle the mechanics one by one. These would be basic "take an input, do some math, poo poo out a result" programs that you could use directly with our physical gameboard, and then over time slowly add and combine features until we have a working, albeit entirely text-based, version of the game. The end result I'm imagining would be similar to those old school RPGs where you'd have an actual gameboard to go along with the software, and from there we'd rebuild the game and add in the sound, interface, and graphics.

Is this even a remotely feasible way to go about learning to program games? Would we have any useable code at the end or would everything have to be re-written once we start prototyping "for real"? I'm really new to software development and I have a feeling I'm misunderstanding a lot of things, but it seems to me that with 2d games you could get away with treating the actual art as essentially a kind of GUI built on top of a text-based system, if that makes sense.

Any input would be greatly appreciated. I'm trying like hell to get through the learning phase on my own--of the five of us I have the "most experience" with "programming", which is a rather charitable way of stating that I designed web pages as a hobby in highschool--but it's really difficult to pick this stuff up at square zero. Mostly I struggled with getting a sense of what the syntax is for as opposed to simply "what it does" (I gather this is just the nature of the beast when learning to code). The plan is to start with Python but I'm looking at C# as well.

In any case I cannot tell you how frustrating it's been to have almost 50% of the game done and ready to go--sprites, rules and mechanics, animations, music, and we're spending the summer working on sound and story--and suddenly hit a wall when you actually try to program the motherfucker.

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
Woozy: I think your idea to go with incremental prototypes is excellent, and a very realistic way to work your way into developing complex games. I'm reminded of this article about Will Wright's prototype for the logic in The Sims.

If you're careful to separate the parts of your code that handle printing output and reading input from functions that carry out game logic it's possible that you could directly reuse code from these prototypes, but I don't think you should focus on that. Any experienced programmer will tell you that rewriting a project from scratch a second time will improve it immeasurably. (So long as you avoid adding new features and you evenually stop rewriting and ship something.) For this reason, I'd say the language you start with should be whatever you're most comfortable diving into. Later on, C# will have some advantages over coding in Python both from an organizational and performance standpoint.

The Saddest Robot
Apr 17, 2007

Woozy posted:

:words:
Any input would be greatly appreciated. I'm trying like hell to get through the learning phase on my own--of the five of us I have the "most experience" with "programming", which is a rather charitable way of stating that I designed web pages as a hobby in highschool--but it's really difficult to pick this stuff up at square zero. Mostly I struggled with getting a sense of what the syntax is for as opposed to simply "what it does" (I gather this is just the nature of the beast when learning to code). The plan is to start with Python but I'm looking at C# as well.

In any case I cannot tell you how frustrating it's been to have almost 50% of the game done and ready to go--sprites, rules and mechanics, animations, music, and we're spending the summer working on sound and story--and suddenly hit a wall when you actually try to program the motherfucker.

I'd say skip Python and pick up C#. Download Visual Studio Express and the XNA/Phone development kit here. There are plenty of XNA tutorials and resources to help you figure out how to draw 2d and 3d scenes in XNA, but it sounds like you are looking for a programming introduction tutorial or class to teach you the basics of the language and programming.

The C# tutorials here looks like they might be a great start. Once you're proficient enough in C# you can start poking around in the examples and tutorials for XNA over here.

Woozy
Jan 3, 2006
Thanks for the input! Downloading C# Express right now. I can't wait to get home and get to work. :dance:

Adraeus
Jan 25, 2008

by Y Kant Ozma Post
Continuing this Q&A from another thread:

Black Eagle posted:

Just a random OO programming question: why is it a bad idea to think of classes as functions of functions (i.e., functions in which there are more functions)?

The Cheshire Cat posted:

Because they aren't.

Programming questions are probably best directed towards this thread, where you'll get a better answer, but I'll do my best to give a quick one here.

Essentially, classes should be thought of as descriptions of an entity of some kind. That particular entity needs members (variables and methods) which describe how it behaves and ONLY that. The difference really is that functions are generic input->output operations that can be applied to anything with the right data types, while class methods should only concern the operation of THAT particular class. Of course, classes do need to relate to each other so you shouldn't drive yourself insane trying to make every class an entirely self-sufficient entity, but in general the less interdependence you have between classes, the better. An OO program is kind of like a machine with replaceable parts: so long as each part reacts in the expected manner to stimuli, the exact nature of that part shouldn't matter. An magnetically driven piston or a hydraulic system both create pressure, but function very differently. In an OO-type machine, they would both be usable as the same part.

In practice, you'll probably find yourself needing some function-like behaviour, which is what static classes (i.e. global classes, or classes with members that can be accessed without needing an instance of that class) can be used for. Things like the Math class that comes built in with most languages and such.

What you might find while designing something using OO is that a lot of classes have similar methods that you feel would be more efficient as a generic function, but this is the wrong way to look at it. Instead, you should look at your classes and consider whether they're similar enough to be consolidated into a single class, or a hierarchy of classes. The end result of this latter approach is that you end up with a more efficient class structure, while in the former approach you still have the same mess of classes as the original as well as a function floating around that doesn't give any indication of the classes with which it's meant to be used.

Black Eagle posted:

See, to me, that just sounds like "classes are functions whose I/O operations can be applied to anything with the right data types within their classes." If that's an unworkable interpretation, I guess I just need more hands-on experience with using classes. (I've been writing procedural PHP, but I'm scheduling some time to learn AS3.)

Paniolo posted:

A class isn't a function. You can't call a class, you can't instantiate a function. Some languages do blur the lines a bit, so there are a lot of caveats. It's pretty offtopic for this thread but stop by the generic game dev thread in CoC if you want a more detailed answer.
I might have an easier time with understanding classes if someone could walk me through their usage. Let's say I wanted to make a game like SimCity. Where would I use classes and why?

Paniolo
Oct 9, 2007

Heads will roll.

Black Eagle posted:

I might have an easier time with understanding classes if someone could walk me through their usage. Let's say I wanted to make a game like SimCity. Where would I use classes and why?

Typically in most languages with classes, 99-100% of the code you write will be in some kind of class or another. Some languages won't even let you define a function outside of a class. So, it's hard to pick out a particular use case.

A class defines a data type. Since it's a type you can't call it like you can a function. In fact you can't really do a whole lot with it except create an instance of it. An instance of a class is called an object. Once you have an object, you can do something with it, like calling its member functions or manipulating its data members.

It's important to realize that a class definition is just a blueprint. If you define a class with an integer variable, for example, that integer variable doesn't actually exist in memory until the class is instantiated. Also, you can have multiple instances of the same class.

As for why classes are useful, there's a lot of reasons. It's significantly easier to organize large programs into classes than simply having thousands of free functions and variables floating around. Classes can also have inheritance relationships, where one class inherits all the functions and data members of the base class. Objects of the child class can then be used in any code that expects an object of the base class, a concept called polymorphism. Classes also simplify designing code modules that distinguish between a public interface and a private implementation, which means you can change the implementation and code which uses the class still works so long as the interface doesn't change.

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
I view a Class as a description of a container for state and functions that manipulate or query that state. Classes operate as a template for the instantiation of Objects, which each possess individual instances of the fields described in the Class. The Class is the description, an Object is a "thing".

The concept of inheritance is not inseparable from Object-Oriented Programming, but it exists in many languages. It allows us to start from a base Class which describes a thing with certain properties and then extend it by adding more specific behaviors.

A building in Sim City is a "thing" so you would probably have a Class called "Building" and then at runtime you'll have many Objects that are instances of Building. A generic Building might only have a notion of taking up a certain footprint on the ground, but there are more specific kinds of Building- (and corresponding subclasses of Building)- such as a hospital or a hot dog stand. Since the Hospital class extends the Building class, we can deal with a hospital on a high level in exactly the same way as any other building.

Games can be a somewhat misleading example, though, since Classes and Objects in a programming environment do not necessarily correspond to "things" as directly. Is a String a "thing"? Does it make sense to write a class that describes a database transaction?

edit: VVV that's a very clear example.

Internet Janitor fucked around with this message at 23:02 on Jun 22, 2011

PalmTreeFun
Apr 25, 2010

*toot*
For a game like SimCity, you could have an object called "Building" with height, type, upkeep cost, build cost, and power usage as variables. Then you could have methods in it to do self-contained, useful operations on the building, like playing an animation or drawing it to the screen.

For an easier example, here's one that I heard when learning OO:

You can make a class "Animal." Say you want to keep track of the number of legs an animal has, the number of eyes it has, and what its name is. We would make variables inside the object for these. We could also have a method inside of class Animal that would change the animal's name. Maybe one that would give it a random name, or one that would let the user type in a name, or even one that changed the animal's name to "Max." You could even make a method that takes in another animal a an argument and gives this one the same name, or maybe a method that takes in another object of class Food that would affect the animal somehow. It's up to you.

Now we can make a bunch of Animal objects, or even an array of them, and give them whatever name, number of legs, or number of eyes we wanted. But what if we want to break these down into more categories. All animals can have a number of legs, even zero. But what about characteristics or methods that are only applicable to one animal but not another? Let's say we want a "bark" method. Now, fish don't bark, but dogs certainly do, and I've seen a video of at least one cat that can.

We could make a class called Dog that inherits from Animal. If we make Dog inherit from Animal, it will also have data for number of legs, eyes, name, and any methods we gave it. However, we can add additional methods and data as we please. Let's add that bark method to dog, and maybe playFetch as well.

Now, why inherit? Why not just add playFetch to all animals? First, it adds clutter to Animal. Second, but more importantly, you can plug a Dog in anywhere an Animal is requested without the need to keep this function around for all Animals. Same with new data added to Dog. Remember the method that takes in another Animal as an argument and copies its name? Well, you can put a Dog object in where Animal should go, as long as the method doesn't specifically request a Cat, just a generic Animal. That's called polymorphism.

So you know, say Dog has a constructor (method named the same as its class so that it runs as soon as you create the object) with either a string or animal as a possible argument. Putting in a string sets the animal's name to that string, and putting in an Animal copies that animal's name and puts it in the new animal.

Dog thingone = new Dog("Max");
Cat thingtwo = new Cat(thingone);

Now the new Cat we just made is named "Max" too. Yes, we put in an object of type Dog into a constructor that requested an object of type Animal, but because Dog inherits from Animal, it works just fine.

Does this make any sense? :)

Adraeus
Jan 25, 2008

by Y Kant Ozma Post
Thanks, you three. Classes are a lot clearer to me. Now, correct me if I'm wrong: a constructor is a single function that executes when the class is instantiated? Methods are functions that act only on data provided to that class? And properties are just variables?

Also, I know the definitions of public, private, and protected, but I don't see how they apply. Are classes private by default? What if a method or property is public in a private class, or vice versa? Can they be mixed that way? Do constructors, properties, and methods inherit the access modifier of their class, if they don't have explicitly defined access modifiers?

Paniolo
Oct 9, 2007

Heads will roll.

Black Eagle posted:

Thanks, you three. Classes are a lot clearer to me. Now, correct me if I'm wrong: a constructor is a single function that executes when the class is instantiated? Methods are functions that act only on data provided to that class? And properties are just variables?

Pretty close. There's no restriction that methods can only access a class's data members, so like any other function they can access data that's declared globally or passed as a parameter.

Black Eagle posted:

Also, I know the definitions of public, private, and protected, but I don't see how they apply. Are classes private by default? What if a method or property is public in a private class, or vice versa? Can they be mixed that way? Do constructors, properties, and methods inherit the access modifier of their class, if they don't have explicitly defined access modifiers?

Public/private/protected don't apply to a class as a whole, they apply to individual members of a class. Most classes will have some public members (the interface) and some private or protected members (the implementation.)

edit for clarification: Some languages like Java allow you to specify public or protected when declaring the class, all this does is specify the default access mode for members which don't explicitly specify otherwise.

second edit: it appears ActionScript works slightly differently and requires you to put 'public' before a class in order for it to be instantiable. I wouldn't worry about it; just declare every class as public.

Paniolo fucked around with this message at 00:12 on Jun 23, 2011

Adraeus
Jan 25, 2008

by Y Kant Ozma Post

Paniolo posted:

Public/private/protected don't apply to a class as a whole, they apply to individual members of a class. Most classes will have some public members (the interface) and some private or protected members (the implementation.)
This example shows a class defined as a "public class." What does that mean?

How do I know when a member should be public, private, or protected?

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
Access modifiers are there for organizational purposes. If something only needs to be used inside a class, make it private. If only subclasses should care about it, make it protected. You'll never technically go wrong by making everything public, but it keeps things clean to separate the internal workings of a class from the methods that are exposed to the world.

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!

PalmTreeFun posted:

Now we can make a bunch of Animal objects, or even an array of them, and give them whatever name, number of legs, or number of eyes we wanted. But what if we want to break these down into more categories. All animals can have a number of legs, even zero. But what about characteristics or methods that are only applicable to one animal but not another? Let's say we want a "bark" method. Now, fish don't bark, but dogs certainly do, and I've seen a video of at least one cat that can.

We could make a class called Dog that inherits from Animal. If we make Dog inherit from Animal, it will also have data for number of legs, eyes, name, and any methods we gave it. However, we can add additional methods and data as we please. Let's add that bark method to dog, and maybe playFetch as well.
Another thing I'd say about this is that if your intent is to have a class for every type of animal then you actually don't want a number of legs value as data, because then every dog contains a number 4, which is totally unnecessary. What you can do instead is have a virtual function eg. "virtual int GetNumberOfLegs() const" which you can override in each animal type so that it returns the appropriate value. A virtual function table exists once per class rather than per object so this way you don't have a shitload of copies of "4" floating around for no reason.

However, if your animals can be mutants or get legs chopped off such that not all dogs have 4 legs, then you would want to have the number of legs as data.

You might also do it with subclasses "quadruped", "biped" etc. so as to not have to define the virtual function for each individual animal, but if you do that then you run into problems with, eg. if you also subclassed "flying", you'd have to use multiple inheritance to allow for both a pegasus (quadruped, flying) and a bird (biped, flying); multiple inheritance is often best avoided. So in general it's better to avoid long inheritance chains and do that sort of thing in some other way (eg. the virtual function is perfectly good enough for the leg count).

Vino
Aug 11, 2010
One thing to note: There's no security restrictions just because something's private or protected. You can still access that memory if you play with pointers. It's just to organize code.

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
Vino: Speak for yourself.

(Assuming the security manager is configured properly. Sun.misc.unsafe doesn't exist.)

Paolomania
Apr 26, 2006

Vino posted:

One thing to note: There's no security restrictions just because something's private or protected. You can still access that memory if you play with pointers. It's just to organize code.

This is highly language and platform dependent. For instance, the JVM will actually use different opcodes when calling public instance methods and private instance methods (invokevirtual versus invokespecial) so that in one case run-time type resolution is used (allowing override) and in the other case the strict compile-time type is used.

Dr Monkeysee
Oct 11, 2002

just a fox like a hundred thousand others
Nap Ghost

Vino posted:

One thing to note: There's no security restrictions just because something's private or protected. You can still access that memory if you play with pointers. It's just to organize code.

That's only true of a close-to-the-metal language like C++. Most OOP languages actually enforce access restrictions at runtime. e.g. in C# you *cannot* get to the private members of a class because you never work with the raw memory representation of an object (ignoring things like reflection frameworks which are designed specifically to give you access in a relatively safe, controlled fashion).

The Saddest Robot
Apr 17, 2007
I could use some math/physics help.

I'm trying to implement some steering/control behavior for a spaceship. The user specifies a destination and direction they want to face, like in Homeworld, and the ship should move there and turn itself so it's facing in the specified direction.

I have the ship turning towards the target and accelerating. The problem is figuring out when to stop. I was pointed towards this formula, which is supposed to calculate the position you would reach 0 velocity at if you were to start decelerating right now:

code:
endPos = position + (velocity * velocity) / (2 * deceleration)
It kind of works, but only if the ship is moving along the positive X or Z axis. If it's moving -X, the end position I get from it is still facing the +X axis, so it looks like it's mirrored along the Z axis.

Am I doing something wrong with the math here or will I just need to account for this and check the signedness and flip endPos around? I hate to force fixes like that when I don't understand what's causing the problem.

PDP-1
Oct 12, 2004

It's a beautiful day in the neighborhood.
When you calculate the (velocity * velocity) term as you wrote it you lose the sign of the original velocity vector components. When you are moving in a positive direction that isn't a problem but if you are moving in a negative direction you'll get the kind of mirroring you describe. Try using something like

(Math.Sign(velocity.X)*(velocity.X * velocity.X) + Math.Sign(velocity.Y * velocity.Y)) / (2 * deceleration)

in the second term and see if that helps.

The Saddest Robot
Apr 17, 2007

PDP-1 posted:

When you calculate the (velocity * velocity) term as you wrote it you lose the sign of the original velocity vector components. When you are moving in a positive direction that isn't a problem but if you are moving in a negative direction you'll get the kind of mirroring you describe. Try using something like

(Math.Sign(velocity.X)*(velocity.X * velocity.X) + Math.Sign(velocity.Y * velocity.Y)) / (2 * deceleration)

in the second term and see if that helps.

Yeah, it's obvious now. Duh, multiplying 2 negatives together will give a positive value. Derp.

Thanks.

I changed the code to:
code:
            Vector3 velSquared;
            velSquared.X = Math.Sign(velocity.X) * (velocity.X * velocity.X);
            velSquared.Y = Math.Sign(velocity.Y) * (velocity.Y * velocity.Y);
            velSquared.Z = Math.Sign(velocity.Z) * (velocity.Z * velocity.Z);
            Vector3 endPos = position + (velSquared / (2 * (thrust / mass)));
It's mostly working, but in a few situations the endPos appears to be off.


The Yellow line in the image is the ship's current velocity. Green is the destination. The orange line/tick is the calculated end position. As you can see, it's not on the same vector as the velocity as I expect it should be.

It seems like it calculates correctly at 45 degree intervals, go off that and the endPos becomes inaccurate. any more ideas?

The Saddest Robot fucked around with this message at 19:36 on Jun 23, 2011

PDP-1
Oct 12, 2004

It's a beautiful day in the neighborhood.
Where did you get that formula from? The more I look at it the weirder it seems - thrust should be a vector, and that componentwise multiplication of the velocity seems like a dot product but isn't.

If you've got a link to the source that you could post it'd help a lot.

The Saddest Robot
Apr 17, 2007
Unfortunately the source isn't very detailed. I found it here when I was searching for physics/kinetics equations related to stopping at a specified point. I decided to try it out and it almost worked.

http://stackoverflow.com/questions/5293943/c-object-overshoots-target

I think the Velocity * Velocity is actually supposed to be Velocity * Velocity.Magnitude? That's giving me the results I expect.

I particularly enjoy the:
code:
            // Dark Magic. Do Not Touch.
            // This is the equation for projectile velocity. -ASR
            // Edited for correct float value -ASR
            // people keep touching! - AgH
in the original post.

PDP-1
Oct 12, 2004

It's a beautiful day in the neighborhood.
From that Stackoverflow post it looks like the equations are presented for a 1D case. This explains why they were using the (velocity * velocity) notation - they were assuming that the velocity was aimed along one direction so they are just multiplying the scalar magnitude and the direction is either positive or negative along that axis.

I think your issue might be coming from the fact that you're working in 3D (but take this with a grain of salt since I haven't cranked out the math myself) and just directly applying the 1D equation. If your ship is starting at some position (X0, Y0, Z0) and has an initial velocity (Vx, Vy, Vz) it can still arrive at some final position (Xf, Yf, Zf) after some time, t, if you split up the acceleration over each vector component to account for the 3D-ness of your simulation. Right now it looks like you're using the same acceleration value (thrust/mass) for each axis and that may be what is causing your problem.

The gist of the solution is to take the equations of motion in each direction, say for the x-component as

x(t) = x0 + Vx0*t + Ax*t*t

and solve it for t at the point where x(t)=X0 via the quadratic equation, and then solve that equation for Ax as a function of t. That's the acceleration value you need to use for the x-component of your sim to get the ship to arrive at the right x value after t seconds. You can get the Y and Z components via the same procedure, you probably won't even need to do any more math - just swap the appropriate vector component for each term.

The final bit is to select how long you want the ship to take to travel from the initial position to the final position. Suppose you pick a value of 2 seconds. This will give you acceleration values for the X, Y, and Z equations and the ship should converge on the final position in all axes simultaneously.

tl;dr version: Using (thrust/mass) for the acceleration value in each axis isn't right, you need to find different acceleration values for each axis.

Hopefully this makes some kind of sense, it's hard to explain without spewing out piles of equations.

The Saddest Robot
Apr 17, 2007
Yeah, I know. I wasn't quite ready to dive into the equations of motion yet - but I know eventually it's what I'll need to do. My math skills are way too rusty to do anything but make a mess out of them.

If someone else stumbles across those posts, the Velocity * VelocityMagnitude gave me the results I was expecting, I haven't come across any situations in my tests where it wasn't correct.

Scaevolus
Apr 16, 2007

Jonathan Blow (the creator of Braid) gave a talk at UC Berkeley titled "Programming Aesthetics learned from making independent games" with a lot of good advice.

The Cheshire Cat
Jun 10, 2008

Fun Shoe
Are there any good absolute newbie tutorials out there for UDK? I've got a simple game idea and I'd like to use it to get my feet wet with the UnrealEngine but the documentation seems to make a lot of assumptions about how much I understand about their folder structure.

Essentially what I need to know is starting from a fresh UDK installation, how do I create my own project and get to the point where I can create a quick empty room map in the editor and run it in my new project? I'm a bit confused because the UDK comes with its own sort of base game, and I'm not sure if I'm supposed to be creating my project by modifying that, or if I'm supposed to be creating entirely new things and just copying over the engine related items I need from the UDKGame folder.

Male Man
Aug 16, 2008

Im, too sexy for your teatime
Too sexy for your teatime
That tea that you're just driiinkiing

The Saddest Robot posted:

Yeah, I know. I wasn't quite ready to dive into the equations of motion yet - but I know eventually it's what I'll need to do. My math skills are way too rusty to do anything but make a mess out of them.

If someone else stumbles across those posts, the Velocity * VelocityMagnitude gave me the results I was expecting, I haven't come across any situations in my tests where it wasn't correct.

Does your system have to account for an arbitrary initial velocity? I'm not sure the solution you've described can handle that, since you mentioned that you're just pointing straight at the destination when you should be plotting a curved course in the general case.

By my pencil sketching, the generic velocity problem has 5 free parameters (2 for direction of accelerating thrust, 2 for direction of decelerating thrust and 1 for the time you should be deceleration) and 6 boundary conditions (3 from known final position, 3 from known final velocity (i.e. zero)), so it should be solvable. If you've got some Calculus in you, it shouldn't be too difficult to solve for the parameters (I think spherical coordinates might be easiest, but Cartesian should work) and then convert that to code.

If you can always assume that the ship starts each journey at rest (relative to its destination, at least), then disregard this.

Oh, and

PDP-1 posted:

x(t) = x0 + Vx0*t + Ax*t*t

should be

x(t) = x0 + Vx0*t + Ax*t*t/2

The Cheshire Cat
Jun 10, 2008

Fun Shoe
Long post incoming:

After tooling around in the UDK for a bit, I've figured out how to actually make things, but I don't believe that UnrealEngine 3 can do exactly what I'm trying to do (well, it sort of can, but in a very hacky and inelegant way). So I need an engine recommendation.

Essentially, the concept I'm building is a puzzle game based around navigating around every surface in a 3D environment by having gravity shift direction as the player passes through portals. The key point is that the puzzles themselves all take place within a single room, and the portals should connect seamlessly to other parts of the room, while also changing the orientation of the player and the direction that gravity pulls the player as they pass through said portals. It should all be done in a way that's invisible to the player, so that walking through a portal feels more or less the same as walking through any normal doorway between two separate rooms.

The issue with UnrealEngine was essentially that "portals" in UnrealEd are actually just dynamically textured areas that teleport you to another point in the game world when you pass through them. It's really not seamless at all, because the rendering engine treats them as textured solids rather than holes with actual geometry in them. The basic idea is that I want an engine that views portals as being exactly the same as a connection between two separate rooms, only the room is just looping the connection back on itself rather than bridging between two different areas (or, alternatively, seamlessly bridging between two areas that have no physical connection at all). Portals are a pretty common rendering technique in engines since most geometry is too complicated for BSP now, but apparently UnrealEngine 3 uses a different technique, so you can't exploit them to create impossible spaces as demonstrated in this video (interestingly enough, the engine used in this video is an older UnrealEngine, so it was possible at one point, just not with UE3).

Obviously Source would be a good engine to look at, since they did kind of build two entire games around seamless portal mechanics, but I'd still like to know what sort of options are available in case there's something easier to work with that I'm overlooking. Apparently Unity does the same thing as UDK with rendertextures instead of actual geometry, so that's not ideal either (though I have seen tech demos very similar to what I want to do, so it's not impossible; just not very simple). Are there other 3D engines out there freely available for amateur developers? Do any of them use zone/portal based rendering that you can manipulate to the extent I need?

I'm fairly new to modding/3D engines so I have a pretty good idea of what I want to do but no idea if it's possible, or if it is what I should use to do it. Any help would be appreciated.

Paniolo
Oct 9, 2007

Heads will roll.
I don't have any UDK experience, but it sounds like you might be conflating two uses of the term "portal" which are very different things. A portal as used for visibility culling isn't really related to a portal like the ones in Portal.

Gerblyn
Apr 4, 2007

"TO BATTLE!"
Fun Shoe
Cheshire Cat, look into using Trigger Volumes. They let you define a collision shape in space that fires scripts when an actor touches them/stops touching them.

I would use the following approach (it's been years since I last used UDK, so I might have some of the details wrong)

1) Create a new type of volume that derives from "TriggerVolume", give it a property that defines the direction of gravity used by an actor that is touching it
2) Create a list of gravity triggers in the Pawn. When the pawn touches a gravity trigger, it gets added to the end of that list, on untouch, it gets removed from the list.
3) Modify the Pawn so it always uses the gravity direction from the gravity trigger at the end of the list.
4) In the level, identify each area where you want gravity to have a different direction, and define a gravity trigger whose collision shape encompasses that area.

The list approach in steps 2/3 provides a method for resolving what happens if the actor is touching multiple gravity triggers at once (by saying, I'm affected by the trigger I touched most recently). You could also give the gravity triggers a "Priority" property, sort them into the pawn's list based on that priority, and have the pawn always use the gravity from the highest priority trigger.

Edit: Oops, had a link to the wrong UDK class.

Gerblyn fucked around with this message at 09:40 on Jun 25, 2011

heeen
May 14, 2005

CAT NEVER STOPS
Ceshire Cat: http://www.pseudoform.org/index.php?id=media went open source, looks like it fits your problem pretty well.

xopods
Oct 26, 2010

Woozy posted:

This is a really odd question so feel free to call me a moron/suggest a much better question to ask:

A year and a half ago, I set to paper a set of rules and mechanics for a PnP RPG/Strategy board game involving robots and guns and wrote some fluff to go along with it for my gaming group and I to gently caress around with. This is about to become the second nerdiest thing I have ever done. Some friends and I have agreed to try to port the mechanics into a 2d, X-Com like turn-based strategy game. The problem is, to I'm surely virtually no one's surprise, that we have plenty of artists, writers, sound designers, and musicians, plus a full blown tested and working system/rules design to serve as proof of concept, and no one with any experience programming. Whoops!

Here's how I thought we'd try to tackle this: since we need to actually learn to program as we go, and we couldn't couldn't possibly even begin work on a big complex project without getting a number of smaller ones under our belt, I was thinking I'd start out slow by proto-proto-typing the game with individual, text-based applications to handle the mechanics one by one. These would be basic "take an input, do some math, poo poo out a result" programs that you could use directly with our physical gameboard, and then over time slowly add and combine features until we have a working, albeit entirely text-based, version of the game. The end result I'm imagining would be similar to those old school RPGs where you'd have an actual gameboard to go along with the software, and from there we'd rebuild the game and add in the sound, interface, and graphics.

Is this even a remotely feasible way to go about learning to program games? Would we have any useable code at the end or would everything have to be re-written once we start prototyping "for real"? I'm really new to software development and I have a feeling I'm misunderstanding a lot of things, but it seems to me that with 2d games you could get away with treating the actual art as essentially a kind of GUI built on top of a text-based system, if that makes sense.

Any input would be greatly appreciated. I'm trying like hell to get through the learning phase on my own--of the five of us I have the "most experience" with "programming", which is a rather charitable way of stating that I designed web pages as a hobby in highschool--but it's really difficult to pick this stuff up at square zero. Mostly I struggled with getting a sense of what the syntax is for as opposed to simply "what it does" (I gather this is just the nature of the beast when learning to code). The plan is to start with Python but I'm looking at C# as well.

In any case I cannot tell you how frustrating it's been to have almost 50% of the game done and ready to go--sprites, rules and mechanics, animations, music, and we're spending the summer working on sound and story--and suddenly hit a wall when you actually try to program the motherfucker.

You may actually end up with a pretty decent game at the end of all of this. I've noticed that a lot of game developers who come at things from the other side of things - starting as programmers - underestimate the difficulty and importance of the other skills. Meanwhile, you sound like you're correctly assessing, or perhaps even overestimating the difficulty you're going to have learning to program well enough to write this game.

The one thing I think you are underestimating is the difficulty of 2D graphics and user input. Game logic is actually by far the easiest part in most cases (unless you're trying to write a good AI for the game, which is very hard). When you say "X-Com like," are you planning on doing it from an isometric perspective? It's definitely doable, but for a beginner you're going to have a lot of headaches with that.

After doing your text-based game logic prototype, which is a good place to start, the next thing I think you should do is either a chess game from isometric perspective, or if you want it to be a prototype for your game, then one with no game logic whatsoever, just a prototype to display a position and allow you to click on pieces move them around.

Aside from anything else, doing it that way will help you keep the game logic and user I/O separate, which is a good habit. And if you can do both those halves well, putting them together shouldn't be THAT hard.

One final tip: beware the black mile, and prepare your team for it. Unless you're planning on releasing the game in a very amateurish state, you'll find the point at which you're "90%" done turns out to be, in fact, the halfway mark, and the final stretch of polishing, bug fixing, implementing all those little secondary features you left out until now, etc. etc. seems like it will never end, and is the most miserable, disheartening, soul-eroding part of the project. A huge number of projects by fledgling developers get abandoned at this point (many of my own included).

Exadv1
Jul 22, 2009

The Saddest Robot posted:

Yeah, I know. I wasn't quite ready to dive into the equations of motion yet - but I know eventually it's what I'll need to do. My math skills are way too rusty to do anything but make a mess out of them.

If someone else stumbles across those posts, the Velocity * VelocityMagnitude gave me the results I was expecting, I haven't come across any situations in my tests where it wasn't correct.

I think your problem was that you are misinterpreting the acceleration variable in the original equations you stated. Technically, acceleration is the rate in change of velocity not speed.

Basically, if you are moving along the negative X-axis (thus negative velocity) then negative acceleration would increase your speed. You would need a positive acceleration to decrease your speed (deceleration).

This interpretation is more helpful for the 2D-3D case since then you can keep the vector interpretation of displacement, velocity, and acceleration so the system works for arbitrary values of each.

The Cheshire Cat
Jun 10, 2008

Fun Shoe

Paniolo posted:

I don't have any UDK experience, but it sounds like you might be conflating two uses of the term "portal" which are very different things. A portal as used for visibility culling isn't really related to a portal like the ones in Portal.

I know the difference, but in some engines (admittedly, older ones), you can actually manipulate portals used for visibility culling to function like the portals from Portal. It had to do with essentially tricking the rendering engine into thinking two spaces are adjacent by linking culling portals from two distant rooms, and then sticking a trigger in the doorway to teleport the player so they could pass through the area seamlessly. I suppose I'm getting a bit hung up on semantics with UE3 since technically you can use a rendertexture to accomplish the same thing, but the my main issue is because a render texture is a flat surface rather than actual geometry, it causes problems when say, pushing an object through the teleporter, or trying to shoot through the teleporter with a hitscan weapon. In UE3, the former causes very obvious jumping as the object disappears from the current location and appears in the area covered by the rendertexture, while the latter simply does not work.

heeen posted:

Ceshire Cat: http://www.pseudoform.org/index.php?id=media went open source, looks like it fits your problem pretty well.

This actually looks pretty cool and does a lot of things that I don't necessarily need, but certainly look like features I would want. It seems like the game idea they designed it for is very similar to my own, which is a good thing since really all I wanted to do was some level design (my original inspiration was to try to turn relativity into a game level), so if someone has already built an engine for that kind of game it's ideal.

Gerblyn posted:

Cheshire Cat, look into using Trigger Volumes. They let you define a collision shape in space that fires scripts when an actor touches them/stops touching them.

I would use the following approach (it's been years since I last used UDK, so I might have some of the details wrong)

1) Create a new type of volume that derives from "TriggerVolume", give it a property that defines the direction of gravity used by an actor that is touching it
2) Create a list of gravity triggers in the Pawn. When the pawn touches a gravity trigger, it gets added to the end of that list, on untouch, it gets removed from the list.
3) Modify the Pawn so it always uses the gravity direction from the gravity trigger at the end of the list.
4) In the level, identify each area where you want gravity to have a different direction, and define a gravity trigger whose collision shape encompasses that area.

The list approach in steps 2/3 provides a method for resolving what happens if the actor is touching multiple gravity triggers at once (by saying, I'm affected by the trigger I touched most recently). You could also give the gravity triggers a "Priority" property, sort them into the pawn's list based on that priority, and have the pawn always use the gravity from the highest priority trigger.

Edit: Oops, had a link to the wrong UDK class.

This isn't exactly what I'm going for; rather than having zones with different directions for gravity, each individual object needs to maintain its own gravitational direction at ANY point in the level, and that direction gets switched when passing through a portal. So two objects sitting next to each other may "fall" in different directions because they've both arrived at that spot through different portals.

Adbot
ADBOT LOVES YOU

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 Cheshire Cat posted:

... very obvious jumping as the object disappears from the current location and appears in the area covered by the rendertexture ...

... rather than having zones with different directions for gravity, each individual object needs to maintain its own gravitational direction at ANY point in the level, and that direction gets switched when passing through a portal.
Given that you're apparently wanting it to be possible for an object to be halfway pushed through a portal, how do you intend to resolve the gravity for that object? Just switching as its center of mass goes through, or would it have gravity acting in two directions on it such that it might start spinning?

Edit: It sounds like could still do it with a rendertexture, you'd just have to render two of an object whenever the object is part way through a portal, and do extra tests for hitscans when the line hits a portal.

roomforthetuna fucked around with this message at 01:19 on Jun 26, 2011

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