Sunday, July 12, 2009

LOS and Memory


So, I've got properly working LOS and a rudimentary implementation of memory. My LOS uses variable fields of vision, which adjust depending on what species you are and what you're doing. (if your unit is set to sprint, you'll get tunnel vision, if you're standing motionless, you've got the whole round to look around so you'll get an FOV bonus. In the image I've provided, the unit is facing south, after first facing east. You can see the void that the '%' creates in the 'X' unit's vision. The unit's memory is separate from the other unit's memory, but I'm going to impliment a static variable that they can all share, such that assuming they aren't radio-silent, they'll be able to know what the other units are seeing. (radiosilence would likely improve one's stealth ability/ make them quieter, but cut them off from their other comrades... but that is something to do in the future)

I'm really thinking that I need to swap my output methods soon, as i'm in desparate need for color/variation in darkness. You wouldn't know, but I'm currently differentiation between what the unit sees 'now' and what they 'remember', which would be done justice if I could render the current vision brighter, as is commonly done with roguelikes. One thing that might be problematic, though it's the same as I remember from X-Com, is that if something changes to the map (IE, a door opens/closes) in a portion where the unit visited but can no longer see, this change will show up in their memory... which doesn't seem altogether fair.

Saturday, July 11, 2009

We have LOS!

So, after sifting through my code for a bit, I figured out why my LOS was so buggy. When using the Java's Math.tan() function, it inputs the angle in radians. I was using degrees, so I had to convert the angle from degrees to radians. I then (most unfortunately) had two very-similarly name variables, one which held the degree in radians and the other which held it in degrees. Everything about what I wrote WOULD have worked, except that some of my if/then/else statements which I used to filter out a few cases were designed to work with degrees... Except I had plugged in the radian version into them all!

But, now it's fixed. I love how making horrid mistakes like this helps me become a better programmer, because it's just one more thing in the back of my head that nags me while I'm writing code. (and yes, this is the main reason I'm working on this project; to become a better programmer)

So, the LOS works fine. It's directional and your agent can only see in a variable field of vision centered on whatever direction he/she is facing. Tomorrow I'll add a screenshot, as I'm on my laptop and I can't figure out where my printscreen key is. next I've just got to impletement an 'explored' array, so that things that the agent has seen in the past will show up also;

My LOS effectively casts 'rays' of sight from the agent in the directions needed. I'm aware that this isn't the best way to do this, and I'm sure I'll change it in the future.

Thursday, July 9, 2009

A bit more LOS


So I've implemented a very buggy LOS algorithm... but the main thing is that it's properly updating the vieport as the guy is moving around. Bugs: he's always facing south, also, It seems that light gets around single post objects much too easy. I'll work on this more tomorrow, but I've got to get some rest. In the picture above the X is actually the character. To differentiate the multiple @, I'm currently displaying the currently selected unit as an X. When I impliment color, this will be much easier. The << up stairs are actually the ramp up to the skyranger, so these should/are blocking the LOS-- more or less.

Wednesday, July 8, 2009

LOS and other stuff

Well, I haven't quite gotten to LOS yet, but I've written methods that allow for it. Previously, the screen was being generated via the environment class without any regards as to what the selected unit could see. I've added a few unit variables and methods so that (unless you've enabled omniscience) the player only can see what the unit can see. I don't have a LOS algorithm yet, but I've got it set up so that I can drop one it. I randomly set the boolean array 'player can see this tile' to T/F and it works.

I've been reading through a few LOS explainations and such, but I think to start that I'll just do something simple.

Also, I've implement directional facing, both automatically when you move a certain direction, and also for TU cost if you change which direction you are moving while you are motionless.

Another thing, I've started writing methods to allow for sounds and smells to be left in the environment by agent's (and alien's ) actions. Sounds will only be stored for the current and previos turn in the form of a linkedList. Selecting a unit will show which sounds they heard (and where they may have originated) I'm trying to add in more tactical elements. :-)

Monday, July 6, 2009

floors and falling

Well, I've successfully coded some routines so that every time a unit moves forward, a check is made to see if the ground it's standing on is strong enough to support it. If they step onto a weak tile, (for example, say something has been damaged by an explosion, or the unit is a 4-ton tank and it's driving inside of a house) it will break through the floor and fall down. It will keep falling until it hits something that can support it, (or until it reaches the bottom z-level) No damage is currently done, but it does keep track of the distance that the unit fell. I'll likely institute falling damage, based on some preset 'free' bit of cushion based on whatever a unit's species/training may be, how much weight they're carrying, how far they've fallen, and perhaps how many spare TUs they have when they've hit the ground.

Next I'll need to write some sort of recursive function, perhaps, to check if every floor tile is being supported by something strong enough. I'd like to incorporate the aspects of X-Com Apocalypse that I found nice; and one of those was a destructible city. I want a high-explosive round to be able to topple a 3 story house. (though, the residents wouldn't like it that much and would likely demand compensation)

I'd like to make this game a bit more dynamic than X-Com was. Things I plan to include:

being able to jump various distances.
being able to climb over various things.

Saturday, June 27, 2009

I've returned

I'm back! I'd hoped to have remained active during the last semester, but I turned out to be more busy that I expected.

Anyway, I've been coding a bit over the last few days and I've now got working stairs. It took me a while to write the framework for ascending/descending stairs, because I wanted it to be robust. How it is now, I can later add ladders, ropes, fences, and even tree climbing; with little extra code.

The skyranger now has two levels and you have to go down the stairs to exit. Next I need to make it so that if your agent walks into 'air', he/she will fall until hitting something solid.

Sunday, May 17, 2009

summer class

I promise that I'm still around. I'm taking two classes right now during a condensed 7 week session, and I've currently been working on some ML 97 homework for almost the last 24 hours straight. I haven't abandoned my rogue-like at all, I've just been busy.