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
Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
Screeb: Very Einhänder-esque. Stylish.

Adbot
ADBOT LOVES YOU

Beelzebub
Apr 17, 2002

In the event that you make sense, I will still send you to the 7th circle.

Screeb posted:

a side-scrolling space shooter

drat, makes my feeble efforts look, well, feeble.

TJChap2840
Sep 24, 2009

Beelzebub posted:

drat, makes my feeble efforts look, well, feeble.

Ya. Seeing stuff like this totally ruins any motivation I have to create something on my own. I don't even know where to begin to look to begin something like this and it just disappoints me greatly.

Bob Morales
Aug 18, 2006


Just wear the fucking mask, Bob

I don't care how many people I probably infected with COVID-19 while refusing to wear a mask, my comfort is far more important than the health and safety of everyone around me!

Biggz posted:

It's my first weekend with Unity and a really nice vector add on called RageSpline (https://www.ragespline.com if you're interested).



It's slightly more interesting in motion, http://www.youtube.com/watch?v=LyAbKJHSsbQ

You should do something where you get points for making circles around the beads that go back and forth horizontally.

poemdexter
Feb 18, 2005

Hooray Indie Games!

College Slice
My multiplayer asteroids game is on haitus since my buddy and I wanted to try some component based stuff and see if that was easier to use. We were starting to see where we might paint ourselves into a wall.



So now we're writing a roguelike in XNA. This is my first dip into Component Based stuff as opposed to straight OOP. I'm already in love with it. The animation component I used to make the torches flicker on the wall is the same component I used to make the player change directions he's looking as well as making the doors open and close.

It took me like 2 weeks to get the dungeon generation done just to have halls and rooms and I'm still not too happy with how it came out. However, with the component based stuff, it's been smooth sailing adding new features and hour or two at a time.

Sprite set is ORYX - http://www.oryxdesignlab.com/sprites/

The guy who OPs the Crawl thread in Games used this spriteset for his av. I had to dig back through my post history to November of 09 just to find the post where I asked what set it was to find his answer. :gonk:

TJChap2840
Sep 24, 2009

poemdexter posted:

My multiplayer asteroids game is on haitus since my buddy and I wanted to try some component based stuff and see if that was easier to use. We were starting to see where we might paint ourselves into a wall.



So now we're writing a roguelike in XNA. This is my first dip into Component Based stuff as opposed to straight OOP. I'm already in love with it. The animation component I used to make the torches flicker on the wall is the same component I used to make the player change directions he's looking as well as making the doors open and close.

It took me like 2 weeks to get the dungeon generation done just to have halls and rooms and I'm still not too happy with how it came out. However, with the component based stuff, it's been smooth sailing adding new features and hour or two at a time.

Sprite set is ORYX - http://www.oryxdesignlab.com/sprites/

The guy who OPs the Crawl thread in Games used this spriteset for his av. I had to dig back through my post history to November of 09 just to find the post where I asked what set it was to find his answer. :gonk:

Serious question:

What resources do you guys use for
references for your projects? I really really hate digging through google to find a half working tutorial. Any recommendations for books or online resources?

I can code basic games and decent applications but I want to move into random level generation and advanced AI.

TJChap2840 fucked around with this message at 03:28 on Sep 6, 2011

God's I/O
Jun 18, 2004
This is not a newbie
I'd rather shamefully plug my Wp7 game here instead of showing off the bastardized UI in GDI+ that some people with no Ux knowledge whatsoever want. That's a 5 million $ project that will most likely fail. So here you go, have a look at this! :)





This is a spare time project that costed me more than I made from, I love this! :D

Jewel
May 2, 2009

TJChap2840 posted:

I can code basic games and decent applications but I want to move into random level generation and advanced AI.

Actually I agree, can someone shed some nice resources on these? Websites are fine, but often they're not detailed enough. These two are the major two topics I have trouble with, other than good object management, but that's something I have to learn on my own.

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
Have you ever wondered what it would look like if someone wrote Pong in FORTRAN?

Wonder no more!

poemdexter
Feb 18, 2005

Hooray Indie Games!

College Slice

TJChap2840 posted:

Serious question:

What resources do you guys use for
references for your projects? I really really hate digging through google to find a half working tutorial. Any recommendations for books or online resources?

I can code basic games and decent applications but I want to move into random level generation and advanced AI.

Binary trees for dungeon generation:
basic write up: http://doryen.eptalys.net/articles/bsp-dungeon-generation/
code example: http://7yrl.com/2009/04/10/7/ (flip through the days for more)

Basic XNA start:
Microsoft side scroller shmup tutorial: http://create.msdn.com/en-US/education/tutorial/2dgame/getting_started

Do note that the tutorial is aimed for poo poo coders because it's absolute poo poo. The player doesn't have a bounding box Rectangle inside the Player object. Instead, a new Rectangle is created every game loop. :pwn: However, it will teach you the very basics for getting started in XNA such as drawing stuff and collision detection.

Component Based Design:
http://cowboyprogramming.com/2007/01/05/evolve-your-heirachy/
just google "Component Based Game Development" and sift through.

I can't find the link to save my life, so I'm just going to rehost this C# project in dropbox. It's the barebones project using component based design. All it does it create a player entity, give it an HP component and takeDamage action, and then show the player taking damage.
Code Example: http://dl.dropbox.com/u/11893120/EntityPrototype.zip

As far as further going into dungeon generation, I chose the binary tree route. I've done a small roguelike before using a different method where you just draw random halls and try to place rooms every so often, but I wanted a more "room dense" algorithm.

good roguelike dev source: http://roguebasin.roguelikedevelopment.org/index.php/Main_Page

As for AI, you'll probably want to look into some pathfinding stuff like A*, and then some sort of list of states for your entity like "run away", "wander around", "martyr to player", etc. A* is well documented EVERYWHERE online and pretty efficient as far as pathfinding goes. The state stuff I'll probably be able to link to later once I get to that point in development.

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.

Tw1tchy posted:

TJChap2840 posted:

I can code basic games and decent applications but I want to move into random level generation and advanced AI.
Actually I agree, can someone shed some nice resources on these? Websites are fine, but often they're not detailed enough. These two are the major two topics I have trouble with
If you want an ultra-detailed example of non-Roguelike level generation, you can try to take a look through the code a friend of mine wrote for a 2D platformer we've been slowly working on here. I don't know the details since I haven't touched this part of the code much, but the basic idea is that a level is composed of a bunch of "moves" — basically level chunks — that we know the player can traverse. We generate a random path to the exit, and then fill in the rest with detours. This gives us varied and occasionally very interesting levels. Supposedly Spelunky does something similar, where the level is composed of a random arrangement of level chunks.

The other cool part is that the level format is plain text, each part of level generation (level geometry, free item placement, enemy placement, interactive parts of the environment) is a separate program, and we just connect them together with pipes. This, in conjunction with a debugging flag for the game, has been fantastic for debugging. With that flag, the game'll read the level description from standard input, instead of using its own pipeline. For example, if a certain enemy type has some odd behavior, it's as easy as lvlgen <width> <height> <depth> | enmgen <id> <count> | mid -p to start up the game with a small level populated with only the buggy enemy. Each program also accepts a flag to specify the seed for our portable random number generator, and these seeds are logged, so they can be passed around and used to recreate levels on different machines/OSes.

For AI, we just have some dumb, Mario-style behaviors, but those can get you pretty far. What we've got also allows for the AI to work as a state machine (just a matter of changing the AI struct's update function), but we haven't taken advantage of it yet.

The Wizard of Oz
Feb 7, 2004



I know what you're thinking, "why that just looks like what he posted earlier, with a crappier shader!" Exactly. Exactly right. But it's a crappy raytracing shader. Each volume (a 16x16x16 block as set in the World constructor) is rendered as a 6-sided cube, and then the shader traverses the voxels until it finds a hit and reports that as the colour. The normal is the opposite of the last voxel edge that was traversed. Exciting! And really simple too, I just ported the ray traversal code I was using for picking and had it going in under thirty minutes.

Rendering from inside the volume isn't supported yet, but would be really quite basic as it's just a screen quad with a different starting point.

Edit: Speedwise this is looking extremely comparable to regular vertex buffers, and is much faster to update after changes. There are some optimisations I can do that are very simple, like having the chess distance to the nearest opaque voxel in the .w field. This is not a "hey, this works, that's cool but it brings it to 1 FPS" situation; I am certain now that I can use this as my rendering method. It's even fast on the XBox, although there are some weird issues with the shader I need to sort out.

The Wizard of Oz fucked around with this message at 23:04 on Sep 6, 2011

coldplay chiptunes
Sep 17, 2010

by Lowtax

Biggz posted:

It's my first weekend with Unity and a really nice vector add on called RageSpline (https://www.ragespline.com if you're interested).



It's slightly more interesting in motion, http://www.youtube.com/watch?v=LyAbKJHSsbQ
Looks like Tilt To Live.

God's I/O
Jun 18, 2004
This is not a newbie

TJChap2840 posted:

Serious question:

What resources do you guys use for
references for your projects? I really really hate digging through google to find a half working tutorial. Any recommendations for books or online resources?

I can code basic games and decent applications but I want to move into random level generation and advanced AI.

For XNA I used this: XNA Game Studio 4.0 Programming: Developing for Windows Phone 7 and Xbox 360 and I'm fairly satisfied with it. For AI I had to dig through my university courses but once I remembered the algorithms and their purpose I found wikipedia useful as a starting point.

TJChap2840
Sep 24, 2009

God's I/O posted:

For XNA I used this: XNA Game Studio 4.0 Programming: Developing for Windows Phone 7 and Xbox 360 and I'm fairly satisfied with it. For AI I had to dig through my university courses but once I remembered the algorithms and their purpose I found wikipedia useful as a starting point.

Ill probably end up purchasing this for a reference but I already know a decent amount of the XNA Framework. My problem is taking what I know and turning it into things like Poemdexter posted a few posts ago.

poemdexter
Feb 18, 2005

Hooray Indie Games!

College Slice

TJChap2840 posted:

Ill probably end up purchasing this for a reference but I already know a decent amount of the XNA Framework. My problem is taking what I know and turning it into things like Poemdexter posted a few posts ago.

google is your friend. Also being familiar enough with terminology to be able to google exactly what you want. Instead of going "XNA 4.0 split screen" you can search "XNA 4.0 multiple Viewports".

As far as pure game development goes, what I like to do is write out a very small scope document that lists basically all the core features I want to have it be "feature complete". From there it's just picking a feature and solving how to implement it. The more XNA framework and basic programming knowledge you have, the easier it is to solve a problem. Always start small.

My roguelike went like this:
1. Generate a 2 dimensional array filled with dungeon (0 for empty, 1 for floor, 2 for wall)
2. Put a player on the screen.
3. Make the player move on the screen.
4. Make the player move within the walls of the dungeon.

And that's pretty much where I'm at now. Next up is add a skeleton that walks at the player. As long as you have an idea of what you want to make, the rest is just code code code. You can email me at poemdexter@gmail.com if you want to talk more off the forums or if you had a more specific programming question.

steckles
Jan 14, 2006


I added dispersion to my ray tracer. Not too difficult as I had already implemented spectral rendering. Next up, implementing the Sellmeier and Cauchy equations to make it physically accurate.

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
Steckles: How are you describing scenes in your current setup?

steckles
Jan 14, 2006

Internet Janitor posted:

Steckles: How are you describing scenes in your current setup?
The geometry? It's just a .txt that lists the triangles, vertex normals, and material properties. I also wrote a crappy .obj converter.

Hubis
May 18, 2003

Boy, I wish we had one of those doomsday machines...

steckles posted:


I added dispersion to my ray tracer. Not too difficult as I had already implemented spectral rendering. Next up, implementing the Sellmeier and Cauchy equations to make it physically accurate.

If you've already got spectral representation, implement thin films!

http://www.kimdylla.com/computer_graphics/pbrt_iridescence/iridescence.htm

steckles
Jan 14, 2006

Hubis posted:

If you've already got spectral representation, implement thin films!

http://www.kimdylla.com/computer_graphics/pbrt_iridescence/iridescence.htm

It's on my to-do list for sure. Accurate thin-film interference requires simulating polarization though, which is turning out to be a bitch to implement.

PnP Bios
Oct 24, 2005
optional; no images are allowed, only text
I've been working on a program, primarily designed for use with emulators, to capture and alter the output, and forward the input back to the emulator window.

Here, you can see it in action, playing Ocarina of Time using Project64 on a spinning cube.

http://softwarebyjoel.blogspot.com/2011/09/chin-music-in-action.html



The original purpose was just to do screen doubling so any game could be played on a cocktail cabinet.

The only downside is doing this is finicky as hell. Some games don't take nicely to having their windows redecorated, or their HDC stolen. Anything written in SDL that I've tried seems to work OK though.

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
I think I'm writing a video game.


I haven't worked with hex grids much, so I figured I'd whip up a little turn-based strategy game in the vein of one of my old favorites, Slay.

I'm not sure how far I'll get into writing an actual game, but I've already learned a lot about how to represent the grid and locate neighbors. These hexes are actually built out of 8x8 tiles, which vastly simplifies drawing over most of the alternatives I could come up with.

poemdexter
Feb 18, 2005

Hooray Indie Games!

College Slice
An interesting way of doing it. Personally, I would have just had a 2d array of points that were used for the origin of the texture. It can be easily offset along the X axis so that it tiles correctly. It also might make it easier to determine neighbors.

Also, I picked up Slay on iphone a long long time ago and played a ton. An amazing strategy game.

quiggy
Aug 7, 2010

[in Russian] Oof.


I didn't even realize Slay was still around. I played it back when I was a kid in the mid-90s, never knew anybody else who had heard of it. I loved it so much.

Hubis
May 18, 2003

Boy, I wish we had one of those doomsday machines...

Internet Janitor posted:

I think I'm writing a video game.


I haven't worked with hex grids much, so I figured I'd whip up a little turn-based strategy game in the vein of one of my old favorites, Slay.

I'm not sure how far I'll get into writing an actual game, but I've already learned a lot about how to represent the grid and locate neighbors. These hexes are actually built out of 8x8 tiles, which vastly simplifies drawing over most of the alternatives I could come up with.

Why 8x8 and not 2x3?

Also, what's your underlying representation for the hexes? I've thought about a few different indexing methods, but each seems to have their downsides.

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
Hubis: Partially because I'd like to port this to a platform that lets me build a background out of 8x8 tiles and doesn't allow me to overlay more than one such tile. So basically a completely arbitrary limitation. The hexes themselves are indeed composed of 3x2 overlapping regions of these tiles. When I said this simplifies drawing, I really meant that having the hexes be the shape they are (squashed vertically) simplifies things because they are composed of just four types of tiles- center, center with baseline and two diagonal tiles.

I'm using a hex-cell numbering scheme which resembles a grid in which every other column is shifted down half a tile. This particular arrangement is nice because it maps easily to a 2d array for storage, but makes finding neighbors a little sticky. Basically the relative positions of horizontal neighbors shifts depending on what column you're in. I handle neighbors something like this:

code:
int[][] cells = new int[14][19];

int hex(int x, int y) {
	if (x < 0 || x >= cells[0].length || y < 0 || y >= cells.length) {
		return 5; // default "water" hexes off the edge of the map.
	}
	return cells[y][x];
}

enum Dir { N, NE, SE, S, SW, NW };

int adj(int x, int y, Dir d) {
	switch(d) {
		case N:  return hex(x,   y-1);
		case NE: return hex(x+1, y-1+(x % 2));
		case SE: return hex(x+1, y  +(x % 2));
		case S:  return hex(x,   y+1);
		case SW: return hex(x-1, y  +(x % 2));
		default: return hex(x-1, y-1+(x % 2));
	}
}
I should probably replace this with a simple lookup table, I suppose.

As you said, there are several other ways to represent hex grids- another way I was considering was to use a scheme like this, where one of my axes is tilted:



Then neighbor offsets would be consistent but having a square map without wasting space is a little messier.

I'd love to hear more about other people's solutions to this type of problem.

Internet Janitor fucked around with this message at 03:12 on Sep 12, 2011

ten_twentyfour
Jan 24, 2008

steckles posted:


I added dispersion to my ray tracer. Not too difficult as I had already implemented spectral rendering. Next up, implementing the Sellmeier and Cauchy equations to make it physically accurate.

Any chance you're doing a write-up for this, or can link me to some info on the methods you're using? This looks amazing.

brian
Sep 11, 2001
I obtained this title through beard tax.

I recently made an SWF plugin for a video streaming program called XSplit that grabs tournament data from challonge and then formats it in a theme style manner, mostly for use in fighting game streams and whatnot. It allows you to pick matches and opponents from actively updated lists so it should make doing these sort of titles a lot easier. It supports themes based on the game being played and will try to auto select the correct theme based on the name of the tournament (e.g. "super alpha 2 tournament 5000" would mean the alpha 2 theme). It also auto-generates match names, e.g. Winner's Final, Loser's Semi Finals, etc.



Unfortunately due to weird limitations on how XSplit works, you can't edit scenes in the background, they're adding this but it's a bit of a pain and so those menus are visible on the viewer's end at the moment. That said it should be a lot quicker than writing in the names which the viewers see being written in anyway.

steckles
Jan 14, 2006

ten_twentyfour posted:

Any chance you're doing a write-up for this, or can link me to some info on the methods you're using? This looks amazing.

The underlying algorithm is similar to stochastic progressive photon mapping with the replica exchange sampling method.

Basically, you break the rendering into two passes that are repeated until the image is sufficiently noise free. First you trace your camera rays, reflecting and refracting as normal, but when you hit a diffuse surface, you drop a hit point there and stop. After you've traced all your camera rays, you trace rays from the light sources. When a path from the light intersects a hit point, you update the pixel associated with the hit point. This may seem complicated, but it's a very simple and robust way to compute illumination in complex scenes.

Spectral rendering isn't particularly difficult to implement. Instead of computing colours in RGB, you use a big array that represents the power of light in "bins". If for example, you have a 32 bin spectrum data type representing light from 332nm to 780nm, the first bin would represent all the power carried from 332nm to 364nm, the second from 365nm to 396nm, and so on.

To implement dispersion, you simply pick a wavelength, compute a new index of refraction for it, and zero every bin of your spectrum that doesn't include the wavelength you want to compute. If you want to compute a ray of wavelength 370nm for example, you'd zero first bin, and the 3rd through 32nd bins.

The real complexity of spectral rendering doesn't have anything to do with ray tracing; It's in converting the spectral data to RGB for display. You can't store your frame buffer in RGB, as summing spectral colours converted to RGB doesn't work. Taking your spectral rainbow and adding all the colours together in RGB won't equal white. Assuming you don't want to waste memory storing a complete spectral framebuffer, you need to store your it in a colour space where summing does happen correctly. I use the CIE XYZ colour space.

If you're interested in writing a ray tracer, I suggest you pick up a copy of Physically Based Rendering. There's really no better book on the subject.

Hubis
May 18, 2003

Boy, I wish we had one of those doomsday machines...

steckles posted:

The real complexity of spectral rendering doesn't have anything to do with ray tracing; It's in converting the spectral data to RGB for display. You can't store your frame buffer in RGB, as summing spectral colours converted to RGB doesn't work. Taking your spectral rainbow and adding all the colours together in RGB won't equal white. Assuming you don't want to waste memory storing a complete spectral framebuffer, you need to store your it in a colour space where summing does happen correctly. I use the CIE XYZ colour space.

If you're interested in writing a ray tracer, I suggest you pick up a copy of Physically Based Rendering. There's really no better book on the subject.

And the link I posted is to my write-up for implementing spectral rendering for thin film interactions (in case anyone is interested).

This page is where I got a lot of my info on doing spectral rendering. Basically, you are doing discrete integration along the X-domain on this graph:



for each of the curves shown (which correspond to the CIE XYZ values):



Spectral rendering is generally kind of un-necessary for most scenes, but thin film interaction, refraction (as Steckles is doing) and Fluorescence/Phosphorescence are some cases where it matters. The last part means your ray-tracer can simulate black lights!

Hubis
May 18, 2003

Boy, I wish we had one of those doomsday machines...

Internet Janitor posted:

Hubis: Partially because I'd like to port this to a platform that lets me build a background out of 8x8 tiles and doesn't allow me to overlay more than one such tile. So basically a completely arbitrary limitation. The hexes themselves are indeed composed of 3x2 overlapping regions of these tiles. When I said this simplifies drawing, I really meant that having the hexes be the shape they are (squashed vertically) simplifies things because they are composed of just four types of tiles- center, center with baseline and two diagonal tiles.

I'm using a hex-cell numbering scheme which resembles a grid in which every other column is shifted down half a tile. This particular arrangement is nice because it maps easily to a 2d array for storage, but makes finding neighbors a little sticky. Basically the relative positions of horizontal neighbors shifts depending on what column you're in. I handle neighbors something like this:

code:
int[][] cells = new int[14][19];

int hex(int x, int y) {
	if (x < 0 || x >= cells[0].length || y < 0 || y >= cells.length) {
		return 5; // default "water" hexes off the edge of the map.
	}
	return cells[y][x];
}

enum Dir { N, NE, SE, S, SW, NW };

int adj(int x, int y, Dir d) {
	switch(d) {
		case N:  return hex(x,   y-1);
		case NE: return hex(x+1, y-1+(x % 2));
		case SE: return hex(x+1, y  +(x % 2));
		case S:  return hex(x,   y+1);
		case SW: return hex(x-1, y  +(x % 2));
		default: return hex(x-1, y-1+(x % 2));
	}
}
I should probably replace this with a simple lookup table, I suppose.

As you said, there are several other ways to represent hex grids- another way I was considering was to use a scheme like this, where one of my axes is tilted:



Then neighbor offsets would be consistent but having a square map without wasting space is a little messier.

I'd love to hear more about other people's solutions to this type of problem.

One of the more elegant solutions I've seen is using a redundant 3rd dimension -- one for each of the opposing sides (so like what you have above, but with another axis crossing the diagonal one). The system is under-constrained, but is nice because movement is always one step along one of the axes.

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
It is an interesting idea, but I'd imagine that normalizing the coordinates you get from axes like that could cause all sorts of wrinkles in the rest of the system. I haven't actually tried building an implementation that way, though. Perhaps worth a few evenings of experimentation.

In general I think hex grids are a very interesting problem because they're a perfect example of a "lumpy carpet". There are many problems with many potential solutions, but they all involve tradeoffs of complexity for different operations and there doesn't seem to be any one silver bullet.

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?

Internet Janitor posted:

Hubis: Partially because I'd like to port this to a platform that lets me build a background out of 8x8 tiles and doesn't allow me to overlay more than one such tile. So basically a completely arbitrary limitation. The hexes themselves are indeed composed of 3x2 overlapping regions of these tiles. When I said this simplifies drawing, I really meant that having the hexes be the shape they are (squashed vertically) simplifies things because they are composed of just four types of tiles- center, center with baseline and two diagonal tiles.

I'm using a hex-cell numbering scheme which resembles a grid in which every other column is shifted down half a tile. This particular arrangement is nice because it maps easily to a 2d array for storage, but makes finding neighbors a little sticky. Basically the relative positions of horizontal neighbors shifts depending on what column you're in. I handle neighbors something like this:

code:
int[][] cells = new int[14][19];

int hex(int x, int y) {
	if (x < 0 || x >= cells[0].length || y < 0 || y >= cells.length) {
		return 5; // default "water" hexes off the edge of the map.
	}
	return cells[y][x];
}

enum Dir { N, NE, SE, S, SW, NW };

int adj(int x, int y, Dir d) {
	switch(d) {
		case N:  return hex(x,   y-1);
		case NE: return hex(x+1, y-1+(x % 2));
		case SE: return hex(x+1, y  +(x % 2));
		case S:  return hex(x,   y+1);
		case SW: return hex(x-1, y  +(x % 2));
		default: return hex(x-1, y-1+(x % 2));
	}
}
I should probably replace this with a simple lookup table, I suppose.

As you said, there are several other ways to represent hex grids- another way I was considering was to use a scheme like this, where one of my axes is tilted:



Then neighbor offsets would be consistent but having a square map without wasting space is a little messier.

I'd love to hear more about other people's solutions to this type of problem.

In addition to the one's you've got, a simple linked list like structure can be appropriate in some cases. Each tile records it's on screen location, and a pointer to all it's neighbors. Pathfinding with A* works just fine, as does a lot of other stuff, often quite elegantly. It's also quite general - much of the same code can work on other regular or even irregular grids. However it's not for every situation.

Also, the "three coordinate" system can be helpful when working stuff out before you program it, even if the code itself doesn't use that third (redundant) coordinate. For example, I once had to work out rotations about a tile on a hex grid. It seemed hopelessly complicated until I tried looking at it with the third coordinate. Suddenly everything became simple. Afterwards I just used the constraint equation that relates the third coordinate to the other two to program it using two coordinates. Something to keep in mind if you find yourself stuck.

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
HappyHippo: You can certainly use a linked structure like you described to handle neighboring connections, but wouldn't you still need a coordinate system like one of the three we've discussed for locating an absolute hex? That comes up pretty frequently.

Edit: Unless you just meant using linked hexes as an alternative to using a 2D array as backing storage. Then it's just a tradeoff between easier neighbor finding with the linked hexes versus more compact storage with the array. Linked hexes also make it easier to add hexes to the graph dynamically, which could be useful for some sorts of games.

Internet Janitor fucked around with this message at 03:50 on Sep 13, 2011

parkov
May 4, 2005
Vintage Ahoy!
I wanted to get your opinions on a web app I've been working on. It's a Jeopardy scorekeeper where someone watching the show can play along and keep a personal score log. It should work nicely on both desktop and mobile devices, with application cache + local storage so no net connection required.

I tried two approaches to the look and feel, very much a Jeopardy theme and a more generic but perhaps more appealing interface. Which do you prefer, and do you have any general suggestions for improving either look or function?





You can try them out for yourself here:

http://thomaspark.me/projects/trebek/

http://thomaspark.me/projects/trebek2/

poemdexter
Feb 18, 2005

Hooray Indie Games!

College Slice

parkov posted:

I wanted to get your opinions on a web app I've been working on. It's a Jeopardy scorekeeper where someone watching the show can play along and keep a personal score log. It should work nicely on both desktop and mobile devices, with application cache + local storage so no net connection required.

I tried two approaches to the look and feel, very much a Jeopardy theme and a more generic but perhaps more appealing interface. Which do you prefer, and do you have any general suggestions for improving either look or function?





You can try them out for yourself here:

http://thomaspark.me/projects/trebek/

http://thomaspark.me/projects/trebek2/

This is an awesome idea, and would be the first in line to pick it up. My grandma had a handheld game that you could use to follow along that pretty much did the same thing when I was a kid. Very clever idea!

I like the first one personally. It has that blue hue of jeopardy and it's clear the red and green are meant for +/- where as the other is an orange-ish color for negative.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

parkov posted:

I tried two approaches to the look and feel, very much a Jeopardy theme and a more generic but perhaps more appealing interface. Which do you prefer, and do you have any general suggestions for improving either look or function?



I like this one better, though I think you've inverted the segmented control labeled 'single/double/stats'. I should be pushing the current mode in, at which point the mode I'm leaving pops back up. Think a cassette tape player: when you hit stop, the play button pops back up.

Also, some way to handle daily doubles and final jeopardy would all be cool, though that's a bunch more buttons to add, so only do that if you can make it work.'

Great idea!

Zeph
Apr 9, 2007

This bagga nasty from Dogbert is
FRESH
Not really a screenshot, but I saw a thread on Reddit about Slashdot serving Bender quotes in their HTTP headers, which is awesome, so I quickly whipped up a script that does Bender, Fry and Zoidberg!

source on my github

Adbot
ADBOT LOVES YOU

Arsenic Life Form
Jan 1, 2011
Ignore

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