UI design

I’ve got a plan for the UI, and am now in the process of writing all the C++ funcitons to display and manipulate the separate elements.  Then I’ll finalize the file format for storing the data, then I’ll hook LUA in to it all to feed the C++ code the actual data that the UI will display.  So it will go something like this:
C++ recognizes a possible UI event (like, landing on a planet, or pressing ESC).
C++ sends the UI event type, along with possible extra data (like the ID number of the star and planet being landed on), to LUA.  There is a highly flexible stack kept for calls between C++ and LUA, so it’s pretty good about sticking optional extra data in the calls.

Then LUA will make a call back to C++ for every individual UI element required by the UI screen for that event, feeding in the screen-space coordinates for each individual button, the size of the sliders, that sort of thing.  Also, it will have to talk to C++ to find out the values for all of the stuff the elements represent.
All of those new elements will be put in a queue back on the C++ side, where it manages the frame-by-frame stuff like mouse motion and clicks.  This is the part I’m building now.  When certain things happen, like a button is pressed, it talks to LUA to figure out what to do about it.
LUA responds by calling C++ functions to change data, or whatever is required.  Writing the code for this part will be pretty tedious on both the LUA and C++ side.
And that’s it.  A giant mess of calls back and forth from C++ and LUA, at least one line of LUA to write for every single button, slider, or whatever; and a large number of tiny little functions to write in probably every class in the game in C++ to let LUA get and set any value that might be modified by the UI, since LUA can only call very particular functions.  All to have some buttons to click on.
This is the first major system that isn’t at all based on files you can modify without recompiling.  This is because LUA itself can be modified without recompiling- it’s all interpreted.

Posted in Design | Comments Off on UI design

Engine trails

Trails are done.  Positions are tracked in memory, but most of the work calculating the trail shape is done in shaders.
I’ve given enemy ships trails too.  Zooming out when there are a lot of them around is now more interesting looking.
Obviously the blue trail coming from the yellow/red flames of the player ship doesn’t make much sense, and neither does having the trail coming from the middle of the ship, but those are relatively minor things.
Note those ugly spiky things that happen when the player makes really sharp turns, also seen in many other games.  Getting rid of those is pretty difficult, and probably not worthwhile.  Instead, I’ll just manage it with the point update rate and trail width.
For next time: some kind of system for generating stuff to do at planets.  Trading?  Quests?  Base building?  Something.  This will probably involve building some sort of real UI, which is bound to be a major project.  Just building the UI for the emitter program took a while, and that wasn’t exactly user friendly stuff.

ver19

Posted in State of the Game | Comments Off on Engine trails

Engine trail prototype

I’ve added a map in the upper right of stars and planets.  It’s not great, probably zoomed out too much, and I don’t think it’s centered on the player correctly, but I’ll clean it up later.
But what I’m actually pretty pleased about is the engine trail I’m working on.  It’s only a one pixel line right now, but it’s tracking the information with what appears to be minimal performance loss, so that’s good.  I’ve hardcoded it to a 10 second trail right now, with a new segment every 100ms, but that’s super easy to change.  Once I get it all colored and glowy, I think it’s going to look pretty good.

ver18

Posted in State of the Game | Comments Off on Engine trail prototype

Back to the game. Now with wormholes.

New in this version:
Added a universe system.  Separate “galaxies” maintained with their own individual stars, planets, ships, and projectiles.
Added wormholes, to travel between galaxies.  Travel zeroes out any projectiles you left behind, but the enemies will be right back where you left them when you go back.  That’s probably not how I’ll leave it, but I don’t want them to just disappear, either.
Added shader versions of emitters in-game.  I use rendermonkey, a free ATI tool to write and preview shaders, to write and tune them.  It’s not a fully-featured IDE, but it’s not bad.  Check the .vs or .fs files for the actual shader code.  They’re based on (but almost entirely rewritten) the particle emitter demo that comes with rendermonkey.  The player’s rocket exhaust and the wormholes are both shader emitters now.  I might change wormholes to the old CPU version of emitters, since that gives me so much more control over particle behaviour.
Added a rocket trail to the player’s ship.
Explosions will also look a little nicer, thanks to exploring the different blend modes a bit.

One thing I’m thinking about now is how to improve the radar.  The problem is, the radar should be pretty short range for the enemy ships, where you don’t care about the ships super far away, but it also needs to be long range for stars, which have big gravity wells and will kill you if you accidentally smack in to one.  As it is now, I think you can actually be inside a star’s gravity well without it even showing up on radar.  So, do I :
Zoom the radar out?  Then it would be kind of useless for enemies nearby, they’d all look like they were right on top of you.
Add a second radar, one just for planets?  Two radars seems a bit excessive.  A radar and a galaxy map, maybe?
Add the planet/star data to the outer ring of the radar, maybe growing in size as they get closer?  At least it wouldn’t be a second radar, and you’d at least be able to tell what DIRECTION stars and planets are in, but it would be hard to communicate how far away they are.
I guess the radar where it is, and a map on the upper right, is what I’ll probably do.  Then I can take the stars and planets out of the radar, which is probably for the best.

So, for next time: Maybe a map in the upper right.  Maybe some new weapons.  Maybe I’ll finally stick some LUA in there, probably on planet landing, so I can start scripting up some quests.

ver17

Posted in Design, State of the Game | Comments Off on Back to the game. Now with wormholes.

Emitter, now using shaders

I’ve been working on shaders for the last couple of days.  Nothing final yet, but here’s a preview of my new flame effect, I think it’s definitely a significant step up in terms of appearance, though unfortunately it’s a pretty big step down in terms of how easy it is to customize.  At least it’s almost entirely done on the graphics card.  Check particle.vs and particle.fs, that’s the code for the shader- they’re actually read in and compiled at runtime.
Also included: the .dlls that my programs have apparently been needing for the last few days, since I updated my gcc version.

emitterShader

Posted in State of the Game | Comments Off on Emitter, now using shaders

Shaders

I really thought I was done with the emitter stuff.  Then I decided the performance needed improving.  Then I read this.
So now I’m going to try to do that.  It does mean that I’ll now be requiring shader model 3.0 or higher, but steam says that’s only leaving out a few percent of the gaming public.

Posted in Design | Comments Off on Shaders

Significant emitter revision

This is possibly the final version of the emitter program, aside from adding in actual alpha blending options, which I keep forgetting to do.  It’s certainly not perfect, but it’s not like it’s really part of the game, so as long as it’s complete enough to kick out some good effects with minimum hassle, that’s good enough.
New features:
Each complete emitter system can have many individual emitters, each one individually tunable.  This allows for creating much more sophisticated effects, and is the way the Unreal Development Kit does it.  Each complete emitter corresponds to a single file.
Emitters can now be saved and loaded from files.  The interface for doing so is on the top of the screen.
Fixed that flickering/blinking screen problem.  Then created another slightly different one.  Then fixed that one too.
You can now define 100 separate data points instead of just 10 on all the “graphable” variables.  So you can now have essentially instantaneous changes, or much smoother curves- I found the 10 point system was visibly jerky with some transitions.
There is now a “displacement” mode.  Instead of just saying how fast stuff is being spit from the center, you can just graph exactly how far it is over time, if you want.  So you can have stuff that goes back and forth, stays in the same places, goes towards the origin, or starts somewhere other than at the origin.
There is now a “rotation” value.  This spins all the particles around the origin.

Also included is a couple of fairly silly-looking tech-demo emitters and a png with instructions and controls on it.

So, next up: Back to actually working on the game, instead of emitters.  Next thing to add: Support in the game for actually “attaching” emitters to objects, then giving the player’s ship a rocket trail emitter, which I feel is really going to be a significant improvement.  Then a wormhole emitter.  Then wormholes, and multiple galaxies.

emitterV3

Posted in Tool development | Comments Off on Significant emitter revision

Emitter designer, now with actual emitter stuff going on

Well, the emitter code is in, and you can now play with actually spraying particles around.  I’ve included a sample of what you can do by messing with the color values.  It’s a little inefficient, though, if you spawn a whole lot of particles.  On my computer, it drops to 60 FPS at 10,000 particles being processed per frame.  I’m just not really sure if that’s good enough or not.
Some notes on use:
First of all, type in a number and hit enter to change whatever value is red.  Click on the names on the left to change which value is selected.  Click twice to pick the value in the second column.
The first column (VAL) is the overall value, the second column (VAR) is how much randomness there is for that value.  Values are evenly distributed throughout that range, though I’m considering changing that.
For the values where a graph shows up on the bottom, draw on it with the mouse.  The X axis is the lifetime of the particle.  It doesn’t update the emitter immediately when you change the graph like it does when you type in new numbers, though- to force it to update, hit “R”, for “refresh”.  Also hit “R” if it is flickering or displaying giant colored boxes- it does that sometimes, I’m pretty sure I know why, but I haven’t fixed it yet.

Valid values for “texture” are 0 through 16.  I particularly recommend 8, and 15 and 16 are good once you’ve set up some color changing stuff with the RGB graphs.  Those two are the only two new textures, the rest of them are just textures that were already being loaded for other stuff.
The top value is now how many milliseconds it waits per spawn.  Values between zero and one are valid.
“Acceleration” doesn’t do anything right now.
The VAR value for “ejection dir” will change how wide a spray it is.  It’s in degrees.  The VAL will change what the main direction is.
The lifetime of the particle is actually measured in ms, but displays in seconds for simplicity.  So for 1 second, you actually have to type in 1000.
Hit “E” to export your values to emitter.txt, or “X” to export the “expanded” values- for every ms in the lifetime of the particle, the varying values are precomputed and saved in the “expanded” version.
So, up next: enable viewing multiple emitters at once for building more complex effects, and write the loading function, so you can load emitters instead of just saving them.

emitterV1

Posted in Tool development | Comments Off on Emitter designer, now with actual emitter stuff going on

Emitter designer

First a little background: If you aren’t familiar with what an emitter is, it’s something that spits out a bunch of semi-transparent images (individually called particles).  You set a bunch of rules about how the particles behave, maybe set up some basic physics, give them some randomization, then start spitting them out, and you can get some pretty nice looking stuff which is actually fairly simple in terms of code.  So there are a whole lot of examples up on youtube.  This is approximately the complexity level I’m aiming for. (that link has music.)
The game really needs some engine trails, if for nothing else than to let you tell which corner of the ship is the front at low levels of zoom, so it’s emitter time, and I decided not to go down the dead-end street of typing in hard-coded values, or tuning them via a file like I do with most of the data in the game.  No mere mortal can just type values in and know what it will look like, so you’ve really got to have some realtime feedback.  So I’m working on a full-on emitter generating program.
Right now, I have the UI stuff down, and a big empty space ready for the actual emitter to go into.  Now I just (just…) need to write the actual emitter code that will take all this data and turn it into what it’s supposed to be.
So, a totally new program is included.
Most of the names will be self-explanatory, except “val” and “var”, which are respectively “value” and “variance”.
q to quit like always
d toggles between display of the raw data and displaying the emitter (which doesn’t do anything yet)
pick the thing you want to edit on the left by clicking on it
Type in a number and hit enter, and you’ll give a new value to whatever number is highlighted in red.  Decimal points allowed.  Note that if you enter something above a few decimal places, it will start giving scientific notation with an exponent and the number won’t fit in the column any more, but numbers that big aren’t really useful in emitters, so I’m not worried about it.  Also, it will take full float precision, but only display the first three decimal places.
Where it gets interesting is if you pick one of the values in the middle, where it makes sense to change the value over the lifetime of every object emitted, and you get this box at the bottom where you can draw a line to represent a multiplier value to be applied over time.  That part I think is actually pretty neat.
And finally, hit e and it will export the entire dataset into emitters.txt, where it can (eventually) be read in by the main game.

emitterUI

Posted in Tool development | Comments Off on Emitter designer

Planets

Planets are in.  You can land on them.  Land hard enough, and there will be an explosion and a HP penalty (though there is no penalty for losing all your HP).  Most planets have too much gravity to take off with normal thrust, but hold down S to charge up for a while, and when you hit W it will give you an extra boost to get out of the planet’s gravity well.
You can’t land on the stars.  You will, however, zip through them like nothing happened, leaving a trail of explosions.
The planet and star text data files can be modified to add more planets and stuff, and the basic player data is now loaded from a file too.
You’ll notice the current ship graphic is basically from Tyrian, it’s actually from here, so it’s free to use.  There’s quite a boatload of free-to-use pixel art in that; it’s too bad 90% of the ships are about five pixels wide, and therefore pretty much useless to me.
Similarly, the planet and star graphics are from NASA, which are also free for commercial use under certain restrictions which are easily met.
I think next up is some sort of emitter system to give the ship a fiery rocket trail and perhaps some smoke, maybe for projectiles too, and probably cleaning up the whole timer thing, which I now think that I made much more complicated than it needed to be.

ver15

Posted in State of the Game | Comments Off on Planets