## Shadows and Light in SpaceFight!

I had the theory churning in my head and this tigsource thread helped me solidify it in my brainspace.

It’s not something I absolutely needed in SpaceFight! but it’s kind of a staple for 2-dimensional games. Mostly, I was trying to wrap my head around an alternate method of accessible area mapping. When working with “lighting” it’s important to forget about the light. What’s important are the shadows. Now I can try working these ‘light sources’ into the accessible area map, placing one at each available node, and I could have that efficient accessible area mapping algorithm I’ve been looking for.

## Breaking ground on the Generic2DPlatformer

I’ve been building up a 2D Game “Engine” in my head over the last few months. I’m writing it in Java and am using the Slick framework. I’ve got an information page set up and of course I’ll be posting here with the progress.

## 2-Dimensional Array in Perl

This example starts with the usual declarations.

```#!/usr/bin/perl -w

use strict;

my (\$width, \$height) = (3, 4);
my (\$x, \$y);
my (@array2d, @rows);```

Now we create the “Y-Axis” array which will give us “height”. Here I set the value to “0”.

```for (\$y = 0; \$y < \$height; \$y++)
{
push @rows, "0";
}```

Then we stuff the “rows” array into the main array. We’re creating an array of arrays.

```for (\$x = 0; \$x < \$width; \$x++)
{
push @array2d, [ @rows ];
}```

That covers creating a two-dimensional array, so let’s test the output to make sure it’s working as expected.

```\$array2d[1][3] = "1";
print "Just set position (1,3) to value '1'\n";

for (\$y = 0; \$y < \$height; \$y++)
{
for (\$x = 0; \$x < \$width; \$x++)
{
print "(\$x,\$y) => \$array2d[\$x][\$y]\n";
}
}```

Output:

```Just set position (1,3) to value '1'
(0,0) => 0
(1,0) => 0
(2,0) => 0
(0,1) => 0
(1,1) => 0
(2,1) => 0
(0,2) => 0
(1,2) => 0
(2,2) => 0
(0,3) => 0
(1,3) => 1
(2,3) => 0```

Staypressed theme by Themocracy