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
iopred
Aug 14, 2005

Heli Attack!

Hanpan posted:

I actually have no idea why I typed Flex because I primarily used the Flash IDE. Out of interest, do you have any projects you can show me? My tile engines always seem sluggish but I am more than willing to admit it's probably because I code them badly.
(Although the last project only used two movieclips, the rest was all copypixels!)

Flash is more than capable of doing a 2d platformer, infact I would say that is is one of the better technologies to do it in, especially because AS3 is totally badical.

Edit: I had typed up a hint to use copyPixels, but it seems you are already doing that, perhaps you are doing something horribly inefficient, PM me if you would like to discuss it further.

Adbot
ADBOT LOVES YOU

iopred
Aug 14, 2005

Heli Attack!

Sigvatr posted:

Does anyone like making games, knows C or C++ and wants to make money? I will be making graphics and also have a sound and music design guy. We got that artistic stuff under our belts but need a programmer dood.

Email me at me@sigvatr.com

Strange, I would have thought MM would've had the skill (and ego) for anything you'd want to make.

iopred
Aug 14, 2005

Heli Attack!

Twerpling posted:

Anyone know of the best way to implement a good FSM in C#? I am trying to make one for an XNA game I am working on but the one I always use I made in C++ and it falls apart in C# due to delegates not working the same a function pointers. If I work on this bloody thing long enough I'm sure I'll get it, but I was hoping someone would have an example of a good one already done so I can work this out faster.

FSM's can be made pretty easily in a nice OOP way, create a State interface, with methods like "Start, Run and End" and then just have a FSM class that does all the transitions by calling the right functions. Then its just an issue of making a bunch of different classes to do the things you want.

iopred
Aug 14, 2005

Heli Attack!

Pfhreak posted:

To be entirely correct, you should probably make a state abstract base class rather than a state interface. (Remember, C# has an interface keyword.)

There are a number of advantages to doing this, one, your states are all going to be like objects with a common type, not dissimilar objects with a common type. Two, you'll be able to create default methods for things like OnEnter, and OnExit, (heck, even Update and Draw) and it will make your concrete states that much cleaner to look at.

Ah, my bad, I'm not a C# programmer, we don't have thems fancy abstract classes in AS3.

iopred
Aug 14, 2005

Heli Attack!

Canine Blues Arooo posted:

Hello Gentlemen. I come to you with a very broad question in hopes that I can find a decent tutorial/example/resource on the issue.

I'm interested in building a roguelike engine in Java (No, I don't want to use some one else's mostly as I think I would learn a lot more if I attempted to build my own, and if I would finish it, I could do a lot more with it), but I don't know even where to start with the UI. I have a pretty good grasp on how to build the back end of the system, but I have no idea how to even build a simple window, set the font to something monospace and track (X,Y). I've googled a fair bit for a decent tutorial, but have found very little that could be construed as helpful. I'm hoping one of you fine folk could direct me to a resource that could start me up on this project.

You could start by doing it in console, no need to go GUI for it.

If you want full curses support:
http://roguebasin.roguelikedevelopment.org/index.php?title=Java_Curses_Implementation

iopred
Aug 14, 2005

Heli Attack!

MasterSlowPoke posted:

Just try and make tetris or whatever.

Or Pong, I find Pong is always a really good example... Hell you only really need 3 classes: Paddle, Ball and your main Pong class.

iopred
Aug 14, 2005

Heli Attack!

Pfhreak posted:

I'm looking to play around and implement 'boids' in actionscipt. I'd like to use the concept in a really simple game. I've used Flixel, and I kind of liked it, but I also want to know what other options are out there for generic lightweight flash platforms. What's good and what isn't?

Just use the DisplayObject tree and basic Events. They're super easy to work with and will help you learn more about AS3 and Flash in general.

That said, Flixel has some things right (using a single ENTER_FRAME event updating an array of objects).

Flixel is great for its speed, but if you want vector boids (and I'm assuming you do, as they rotate a lot) learn some flash.

Or if you just want another bitmap library, FlashPunk is supposed to be really good.

iopred
Aug 14, 2005

Heli Attack!

Pfhreak posted:

What are the free solutions for doing this? I've used flashdevelop, and had great success with AS3 there, but what would I use for the vector graphics?

FlashDevelop is perfect.

You can either draw with Flash's Draw API:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/Graphics.html?allClasses=1
If you go this route, use the lightweight class "Shape" and add it to the display list.

or embed SVG which you can edit with free SVG editors like Inkscape:
http://www.streamhead.com/how-to-use-vector-graphics-in-flashdevelop-svg-in-flash/

iopred
Aug 14, 2005

Heli Attack!

Pfhreak posted:

TL;DR: I suffer from apparently random methods taking 4-10 times as long to run. Could it be the garbage collector? How can I know?
TL;DR2: I define my boid's appearance in every instance of the class, is that wrong? How can I do it better?

You say you're creating a 2d array every frame, but then that you're suprised that you're GC'ing every few frames. Perhaps instead of recalculating your buckets every frame you should update positions instead, so when a boid moves across boundaries, it removes itself from its bucket and adds itself to its new bucket. That should most definitely be faster.

Secondly, if you're in Flash10 you can do graphics.copyFrom(source) to make a duplicate of your boid sprite from a master Shape/Graphic and just rotate the Sprite/Shape around its origin for rotation.

iopred
Aug 14, 2005

Heli Attack!

nibe posted:

I find myself endlessly fretting over what objects should have access to what other objects. I've got the notion in my head that less = better, but I'm not sure whether or why that is true beyond simplicity's sake. For example, I have a Unit class that represents humanoid objects that can move around. Right now the class only has information about that unit (name, position, HP, etc.) with no access to other game subsystems. But suppose I want a Unit to follow a moving target. In the Unit's update method I have to find a path to the target, which is a call to a function in the AI class. The only options I can think of are to include the AI in the parameters to Update (at which point, why not have a permanent reference), pass a permanent reference in the constructor, or move the pathfinding function call up outside of Unit into the class that has access to other things (which will fill that class with all the implementations of certain actions that can't be in the "lower" classes). I'm thinking of just passing a reference to the main game manager to everything and being done with it. Besides being highly inelegant, what cons does this solution have? Is there a better way? I'm using C# and XNA.

My thought about passing a reference to a master object (containing SoundManager, CollisionManager EntityManager etc. etc.) lately has been:
Pros:
poo poo gets done faster

Cons:
Not so reusable.

I was swept into the 'reuse is fundamental' argument for too long. As long as you are writing readable code, code is not going to be that hard to reuse in the next project with some tiny refactoring. But the savings from actually getting poo poo done is hard to ignore. It's said that the extra time spent making code reusable doesn't pay itself back until you use the code in 3 projects, so all the headache and messing around probably wont be useful. (I know I've never used the same code for more than 3 games) In the meantime you can do the important things like code the fun stuff instead of being stuck in refactor hell.

As an aside, even the big boys cheat. Source Engine has a bunch of singleton managers.

iopred
Aug 14, 2005

Heli Attack!

roomforthetuna posted:

(Hasn't someone made a Flash compiler that makes an iPhone app out of a Flash thing? Won't be in a webpage but will be supporting iPhone, if you can do it that way.)

Yeah Adobe did. You can package a project to iPhone in CS5.

iopred
Aug 14, 2005

Heli Attack!

BonoMan posted:

Should I just hire actual programmers?

As a designer what would you think if I said something like:

I have made a game, the functionality is all there but it doesn't look very pretty. I'm thinking of buying photoshop and playing around. I'm looking for some tutorials on the web that'll show me how to make some art, step by step. I think with a few months of messing around my art will be good enough.


You'd be thinking 'oh god he has no idea what is involved in making things look good', and my art would probably be garbage.

iopred
Aug 14, 2005

Heli Attack!

Gerblyn posted:

I'm actually writing a TBS game at the moment and the approach I've chosen for this is to have a Unit controlled by little command data structures, which instruct it to do things like "Move to X" or "Attack Y". So, instead of calling a function like:

pre:
unit.MoveTo(position)
You have:

pre:
class MoveToCommand : public UnitCommand
{
 ... blah blah blah ...
};

MoveToCommand moveCommand(position);
unit.AcceptCommand(moveCommand);
These commands can be generated by the UI for player units, by the AI or by the cutscene system. The advantage of this approach is that your commands can come from anywhere, you can send them as messages over thread boundaries, through network connections for multiplayer games, or load them from replay files.

The combination of commands and response lists are really good. The last thing you can do is combine all of them into a sort of 'event' system. Where the game listens to a set of conditions, and fires off triggers based on it.

Wrapped into XML you can do fancy things like:

code:
<event name="blah">
  <trigger>
    <turn>4</turn>
    <player>1</player>
    <unitat x="4" y="2" player="1"/>
  </trigger>
  <response>
    <spawnunit type="tank" x="5" y="2" player="0"/>
  </response>
</event>
To spawn a unit next to player 1, on turn 4 if he has a unit at 4,2

I built a really nice engine like this, it was used to produce 3 games and a multiplayer version:
http://www.kongregate.com/games/urbansquall/battalion-vengeance

iopred fucked around with this message at 00:57 on Apr 9, 2011

iopred
Aug 14, 2005

Heli Attack!

Medieval Medic posted:


code:
      if (Layers.ElementAt(counter).GetCellIndex(Engine.ConvertPositionToCell(sprite.Position)) != -1)
      {
          return;
      } 

There's nothing magical, on this line, you want to call it enough times to cover every position on the sprite.

The way I like to do it is something like:
code:
for (x = topLeftX; x <= bottomRightX; x++) {
  for (y = topLeftY; y <= bottomRightY; y++) {
    if (getCellIndex(x, y) != -1) {
      return;
    }
  }
}
Of course you don't do it for every single pixel of the sprite, just for each tile area the sprite is in, so define topLeftX as floor(sprite.x/tileWidth) and bottomRightX as floor((sprite.x + sprite.width)/tileWidth) or something similar.

iopred fucked around with this message at 18:55 on Oct 15, 2011

iopred
Aug 14, 2005

Heli Attack!

Ireland Sucks posted:

I'm trying to perform 'polygon clipping' on a triangle fan for lighting in a 2d sidescroller, but I'm having trouble coming up with a good method of doing it.

Example (just making a list of vertices to draw triangles around each line):


Probably not explained very well but hopefully you get the idea. Is there a specific algorithm for something like this?

Here's a great article: http://www.redblobgames.com/articles/visibility/

Adbot
ADBOT LOVES YOU

iopred
Aug 14, 2005

Heli Attack!

dizzywhip posted:

Feel free to correct me if I'm wrong about any of this or if I'm doing something stupid -- like I said, I don't have a whole lot of experience with this sort of thing. Any resources on this subject to help me get up to speed would be really appreciated too, ideally not super long and dry if possible.

Install macports, with it install pkg-config & SDL.

You can then run 'sdl-config --cflags --libs' which spits out everything you need to feed to clang to compile SDL.

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