carlfoxmarten: (Default)
I never realized just how much knowing about different programming languages would affect my knowledge of other programming languages.

For instance: I learned C, Java and C++ before I attended university, where I learned more about them and programming in general.

While at university, I learned that the above languages were all the same type of language, namely, they're all Imperative languages, which means you give the processor a list of instructions that it executes pretty much directly.

I also learned about two more types of programming languages, such as Logic Programming, which is where you construct a solution to a problem and let the built-in logic solver solve the problem itself, without specifying the exact sequence of instructions, as well as Functional Programming, which is similar to Imperative Programming, without giving you any form of global state, which means that every function returns the exact same result when given the exact same parameters.
(Functional Programming is often used for low-level systems programming, such as for low-level Operating System functions and BIOSes)

I learned about these programming language types by learning about programming languages that implement these types, such as Prolog and Erlang.

While designing the Event system for my Tetris Power project, I started to realize just how using a Logic Programming language would simplify the core of the system.

For instance, many events more-or-less directly trigger other events, like a "block_land" event might trigger a "row_full" event, which itself triggers a "score_add" event, which then has to add a floating score to the screen.

Theoretically, it should be relatively easy to do something like this if I use Prolog (the only Logic Programming language I know at present), though it could be a little awkward in places, due to the extra layer between the game logic and the rendering system.

I'm going to be examining this more fully and even starting a new branch to work on this to see what happens in practice.

More will be posted as I learn about it.
carlfoxmarten: (Default)
Well, I'd said that I was going to post information about my event system for my Tetris-Power project, so here it is.

The main idea behind this is a simple means for defining and detecting achievements.
If everything done in the game can be represented by a large list of events, you can simply scan the list for a matching sequence to see if an achievement has been matched.

In this case, everything really does mean everything, including keyboard commands, block motions, rows filled, rows removed, scores added, the advancement of time, error and warning messages for the log, and so on and so forth.

The overall structure of the modules then is heavily involved with the event system, with messages getting passed to the events system instead of directly calling other system, and each system that needs to read messages registers with the event system for the types of messages they're interested in.
(for example, if the logging system were enabled, it would read log_info, log_warning, and log_error message types)

This should greatly simplify the overall structure of the code so that not everything would need to know about everything else.
One of the main issues I have right now is that too many systems need to know about each other, which overly complicates my code.

So far I haven't actually added any code yet, as I'm still working on the concept itself.
Once I have that figured out, I'll have to rewrite large swathes of code to use the events system instead of directly calling.
Supposedly, it should be possible to gradually move over to the events system, starting with adding in code to trigger events, having each module listen for appropriate events, actually using the event listeners instead of the function calls as used now, then removing the functions used previously, then refactoring code to simplify things.

I hope it doesn't break while I switch over, but you can't tell until you start what might happen.
carlfoxmarten: (Default)
I've fixed the issue I'd been having with Tetris-Power's old font engine (it was as simple as an array being too small to fit the information necessary), as well as managing to fix a bug where the current block disappearing due to some values becoming NaNs.

It's been a good evening for bug-fixing.

Now I need to figure out how to approach writing the new font engine.

The old engine made it fairly easy to parse in a long, thin image with a single row of characters as long as necessary, but I can't do the same thing with the new engine.
With the old engine, I chopped up the image into a single character's worth of bits for each symbol and stored each one in the computer's memory.
With the new engine, I'll need to store the image, unprocessed, in the graphics card's memory, which means that the images have to be square and a power of 2 wide and high.
(ie, 128x128 pixels or 256x256 pixels, or larger)

This new engine with allow me to rotate characters as I wish, without getting limited by the screen resolution.

I don't think it's going to be an easy thing to write...
carlfoxmarten: (Default)
So I tried working on my Tetris-Power project again, only to find out why I'd dropped it last time: It was full of bugs.
(if it was literally full of bugs, it'd be easier to fix)

Something I'd done when upgrading the font system seems to have caused major bugs to show up elsewhere in the code, and even rolling back the font system doesn't seem to have fixed everything.

I'm racking my brains trying to find out what the problem could possibly be, but I'm not having much success just yet.

If I can remember how, I'll try to roll it back several versions to see where I went wrong, but chances aren't so good that it'll be that easy to fix.
(plus, there are some beneficial changes I've made since then, so there's no telling if I'll be able to undo all the damage I've done to it)

Though if I can't get anywhere with this, I'd hesitate a lot before I rewrite the whole thing from scratch...
(maybe I'll remember to put in more debug stuff and lots more comments)


Incidentally, I'm starting to work on my graduation application so I can get out of university for a bit.
Currently, I'm working on an appeal to use an arts course for one of my liberal arts credits, and need to find information dating all the way back to the Spring of 2005, which was less than a year after I got my very first "proper" computer, which means that I didn't have a good system set up for making backups.
(I'd had an old 286 with 1MB of RAM running Windows 3.11 and something like MS-DOS 6, so an upgrade to Windows 98SE was a huge jump)

However, I've still found time to try fixing Kathy's site under Internet Explorer (after about six months to a year, that is), and I just might be onto something, I'm just not sure if it works completely.
carlfoxmarten: (Default)
What good is a game if it doesn't move?
For that matter, what kind of game doesn't have at least some kind of background imagery?

Now, if your backgrounds have lots of bushes, trees, waterfalls and the like, and they kind of slide or swing into place, wouldn't it make sense for them to wobble back and forth a little bit?

There will need to be more than one animation type, as one type is terribly easy to do and another that I know I'll need will be a bit more difficult.

The easy one will be used for swaying objects, such as trees and bushes, and is accomplished by a simple and oft-used 3D transformation called "shear".
(shearing is like pushing a stack of CD cases over so they form a stair-like structure, with each case offset the same distance from the one previous. This means I have no need to modify the actual model, and can change it very easily on the fly)

The hard one I haven't quite figured out yet.
It'll be used for stuff like the water in waterfalls, and will depend on what the waterfalls look like when I finally design them.
(at least, the specific usage will highly depend on it, the implementation behind it just might be generic enough for more uses than that)

So, the upshot of all this is that I am still thinking about Tetris-Power, the only issue is managing to have spare time for other things, most notably all the homework I have, as well as playing some games.
(currently, LEGO Indiana Jones 2 with my brother and Team Fortress 2)
carlfoxmarten: (Default)
So, as I'm bored today (at least until I start making dinner, then going over to Grandpa's to watch the hockey game), I've decided to rewrite my font engine.

The current font engine I have for Tetris-Power is strictly based on bitmaps which are used to directly affect the screen pixels, which means that if I need a different font size, I have to create, load and track another font file, which is not a recommended practice.

So, I need a polygon-based font engine that allows me to specify a size for each line of text without needing a new font for each point-size I need.

This will need to be almost a complete rewrite of the engine from the ground up, as my previous font engine used a vertically short and horizontally long image to represent the font, and graphics cards like square images to work with.

Another reason I need this rewrite is that when a row gets removed, the score you get floats up from the vanishing row, which means that I needed to figure out exactly where in pixels I had to start the score, when the rows exist in three dimensions. With the new engine, I'll be able to specify the location of the score text by simply taking the 3D position of the row and moving it closer to the viewer, so much simpler and with even less chance for mistakes.
(also, it makes graphical effects like spinning text SO much easier to do, and it even gives me anti-aliased text for nearly free, too!)
carlfoxmarten: (chair)
To help me get more interested in starting up work again on Tetris-Power, I've decided to compile a list of all the modules I've written so far and what they do and support.
Large amount of geekery behind cut )
It's also looking like I might need to switch to a more event-driven approach sometime, as what I'm currently doing will require a fair bit of work to connect certain things together.
carlfoxmarten: (Default)
I thought I'd post some of what's on my current TODO list for the tetris project:
  • Add a background:
    Should include a sky and some ground, but levels can be indicated by the following:
    • Trees
    • Bushes
    • Flowers
    • Hills
    • Clouds
    • Cliffs (towards later levels)
    • Waterfalls (usually off the sides of cliffs. May have some trouble animating them)
  • Add an Options screen:
    I'm not yet sure what to put here, but something about background music, enabling sound effects, graphics detail, etc. would be a good idea.
  • Add sound effects:
    A light thud for blocks landing gently, a slightly heavier thunk for blocks dropped from a higher height, some kind of explosion for when a row gets removed (or maybe a cool disappear sound, I'm not sure), etc.
  • Add background music:
    A friend has offered to make me a Techno remix of the original Tetris background music, but you can be sure that if I include that, I'll provide an alternative option as well as the choice of turning it off...
  • Add an in-game menu:
    To pause the game and let the user change settings without having to restart their game.
  • Add levels of difficulty:
    Because one level isn't challenging enough.
  • Add a highscore list:
    To record how well you've done. I'll probably use SQLite to keep things relatively simple.
  • Tweak or rewrite the font engine:
    To add multiple brightness levels. Right now, fonts don't look that great and could use some extra zing.
  • Write a shaders module:
    To allow me to use shaders on a variety of platforms and even on some lower-end systems, including low-end Intel graphics cards.


Current status is that things look and play fairly well, but certain aspects could be greatly improved, such as block textures (I'd like to use a bump map, but that requires I use a shader so far as I know, thus the need for a shaders module).
I also seem to have lost some of my enthusiasm for work on this project, partly due to finally fixing textures (now I don't have a big challenge staring me in the face, just a bunch of smaller ones).

I want something big and difficult! Not small and difficult!
(sounds weird, I know)

Finally!

Aug. 23rd, 2009 06:51 pm
carlfoxmarten: (Default)
Textures work now! Woohoo!

Man, I really do prefer Java to C++, but since I've been using C++ more recently, I'm having to relearn things I took for granted with Java.

For instance, in Java, everything is not referenced directly, so when you create an object, you pass around a pointer to the object instead of passing around the object itself. However, in C++, you pass around copies of the object itself instead of pointers (unless you choose to work with the pointers, that is).

I'd created a class to help with textures by providing a simple interface for applying and disabling textures.
One of its features was a "destructor" that would tell OpenGL to drop the enclosed texture when any copy of the object was destroyed. Simply passing the texture to a sub-function or method would make a second copy that would destroy the texture when that method was finished...

Fortunately, if I don't delete the textures myself, it seems to delete them when my program is finished anyway, so removing the delete code has fixed the most elusive problem.

Now that textures are working, I can use them now to full potential, and my rounded-border stuff is working okay.
(it doesn't quite look right yet)
carlfoxmarten: (Default)
From the "Why aren't they doing that?" file:

Personal Radio Recorder:
Most of us are familiar with Personal Video Recorders (PVRs) that let you pause, rewind and record live TV, but doing the same thing for radio would be a Very Good Idea™! It would also be fairly easy, and wouldn't require much of an interface.
(you might get away with a programmable MP3 player with a radio built-in. And no, I don't think an iPod would suffice...)


In other news, I haven't done much in the progress of Tetris-Power, I've still been thinking about it.

In regards to indicating levels, I've been thinking about a cartoony landscape that rotates sideways to hide the old level scene and show a new one.
(imagine that the background is a very large disk who's center point is a bit below the screen)

I'm not sure I want to change how the blocks look yet, but I should probably do something about realism with some kind of shadows...
The simple kind of shadows are when you draw everything twice, the first time you draw surfaces, while the second time you change how drawn objects are transformed so they fall flat onto a plane, which requires that you know where your lights and your plane are and where they're pointed. The disadvantage of this technique is that it works fairly well for projecting shadows onto a flat surface only, and to shadow other surfaces requires rendering everything once for every plane or polygon you want shadows on!
The other kind of shadows also require drawing things twice, but the first time is for shadows (looking from the position of the light, so it works best for sun and spot lights) and the data from that is used to render the actual surfaces. Which would actually require me to figure out how to do that...

I'm currently figuring out exactly how to draw nicely curved objects with OpenGL, and so far I think that a semi-circle texture is the simplest way to go. So far with a test program, this has proven very satisfactory, though I'll need to fine-tune a few things on it...

This, however, brings me right back to the problem of textures not actually showing up in the project... D:
I may have to cut the project apart and sew it back together again, adding pieces until textures no longer appear, assuming they show up again in the first place...

Not fun.

I've cut out the loading system to see if it's causing some problems (so far nothing), so I'll look for other stuff that doesn't make sense (which could be a lot of stuff).

Anybody know OpenGL or know somebody who knows OpenGL that would like to contribute to an open-source project and likes debugging? Anybody? Anyone at all?
carlfoxmarten: (Default)
Well, it's starting to feel more like a game now...
(translation: I've been able to play it for minutes on end now)

Rows are now removed (as per my last entry), and the blocks fade out (a rather cool-looking effect) as well as spin and shrink, after which the above rows fall.

Colours are now completely random, as are block orientations, and you even get to see the next block before you get it.

Requisite screenshot:

(not cut, to generate interest)

What I need to do next:
  • Add score-keeping
  • Add a background (probably ground and sky-type stuff)
  • Add the Options screen
  • Add sound effects and music
  • Add an in-game menu (to allow pausing the game)
  • Add different levels of difficulty
  • Add a highscore list
  • Make sure absolutely everything is animated (a very tough job, by the way)


I'm sure there's more I'm missing, but those are the high points.

Lotta work ahead of me...
carlfoxmarten: (Default)
Yay! Rows can be removed now!
(though textures still don't work)

Now, on to animating the removal...
carlfoxmarten: (Default)
It looks so simple on paper and in the online tutorials, but why, oh why is it so difficult in my code?!

I've downloaded one or two sample code projects that demonstrate texture-mapping in OpenGL and have successfully modified them to use my textures, but haven't had any success making my own code display textures...

I guess I just need to Grep through my code to see where I'm enabling and disabling things to see if I've stepped on my own toes somewhere.

Now my code seems to be even less stable, for some strange reason...
Think it's time for a recode? I should at the very least have a thorough look through things to see exactly what I'm doing where and why, and if there's a better reason to do things another way.


And to ensure that this isn't entirely about programming...

I was in an Office Depot today, and it was very dangerous.

You see, I happen to like the better quality writing instruments, and if I find a set that looks good, isn't terribly expensive, and appears to work how I like it to, I'll pick it up. And sometimes, if I think I'd like it enough, the price matters even less.

Staedtler's Triplus line (those long pens with the triangular barrels) are one of my favourites, and I have a small variety set consisting of a highlighter, a pencil, a roller-ball pen, and a fine-pointed felt-tip pen. Both the roller-ball and the pencil have seen a lot of use (the fine-liner - as it's called - and the highlighter, not so much), so I may need to replace the pen sometime, which means I'm technically in the market for a replacement.

As I was browsing the writing instruments section of the store, I found out that Staedtler is now also making gel pens in their Triplus brand for about CAD$13. It was very difficult, but I did resist the temptation to buy the set of eight colours.

They also had an actual replacement for the pen that I have, but it would cost about CAD$3, not a good price for just the one pen. Though if I wanted a fineliner (the fine-tipped felt pen), it would only be CAD$4 for three of them. (guess which one is cheaper to make?)

Oh, and unrelatedly: I need to find a good emoticon set to use here on LJ...
carlfoxmarten: (Default)
First, I now own a half-interest in a second-hand EeePC.
Tiny little thing (7-inch screen, 4GB drive), most of what I've been doing are updates (I finally found Synaptic, a Linux package manager), and trying to do web-browsing on the small screen.

If there'd been one available, I'd have chosen a 9-inch model, but anything is better than nothing.
(and a small, lightweight model like the EeePC is better than a four-pound, widescreen model for portability)


Anyway, so far I've tweaked how the grid stores blocks to make it easier to check when a row is full, swapped out the 118KB cube (1248 faces, 1250 vertices) for a 26-face, 24-vertex, 3.3KB version with texture coordinates in the hope that I can map a texture on it to simulate a more complex cube.

So far, however, all my texture efforts have been in vain.

The image is loading fine, but none of my efforts have been able to pass the texture data over to OpenGL, and most of the documentation I've found is slightly incomplete. The missing part is how to separate loading the image into OpenGL and rendering with it.

The confusing part is that the same function call is used to set up the texture for loading and use it for rendering, so I'm not sure if I'm calling it the right way each time.

Anybody have any suggestions for OpenGL texture tutorial or reference sites? I'm a little stumped...
carlfoxmarten: (Default)
I've reached one of the next steps in Tetris-Power development recently, that of a slightly-playable game.

So far I have the loading screen, the menu screen, and the play screen. The play screen will let you play the game, including moving the block around the screen (and automatically dropping by a row about once a second) and dropping them to the bottom (which still needs to be animated), and it will even give you a new, random shape after it lands.
(it won't yet remove rows, I need to rewrite how the cubes are stored first)

Current problem is that my development computer is getting a little bogged down by rendering as the number of blocks on the screen increases, which means that I need to drop the number of polygons some more.

You can find my current block shape here (for those of you who can read Wavefront Object files). Current file size is 118KB, which is probably a bit large. I'm open to suggestions for replacements or tweaks to reduce the number of polygons to a more manageable level.

Requisite screenshot not yet available.

Yet to come are the block preview windows, score-keeping, timing (if I decide to include it), the in-game menu, the options screen (if I have any options to change), randomizing each new block's colour, better graphics, the power-ups, and etc to the power of ten.

I suspect my problem with the frame-rate is that it's using software for non-fullscreen windows, and will let you use hardware for fullscreen windows.
I hope I'm wrong...

Current line count is over 4100 raw lines.
(I suppose I should look for a linecount metric tool to count how many statements I have sometime)
carlfoxmarten: (Default)
One of the things I said I was going to work on next was position interpolation stuff.
(i.e., the stuff that makes things move smoothly)

I'm currently taking a course on Numerical Analysis (basically doing math on computers and how to make it easier and/or more accurate).

What are the odds that I just learned about doing this sort of thing this last week?

Very high, apparently.

I'm using a variation of what's called Bezier curves, equations that are governed by two endpoints and two control points that determine the shape of the curve, and generate a smooth curve between the endpoints.
It's a variation because the original definition works in two dimensions, but the two sets of equations do not depend on each other, so are completely independent and can be used separately.
This simplified the code somewhat, as I only had to deal with one curve at a time, so could just use two instances to control the two dimensions separately.

Testing has been very satisfactory, as any change in direction is taken into account when generating the new equation set, by taking the current position and velocity and using them as the starting point for the next equations.

Overall, I'm not quite sure what's next. Several things need doing, such as the grid system (potentially a lot of work) and designing and displaying the backdrop behind and around the game-grid (needs a lot of thought).

Sometime after that, I need to redesign how the buttons, progressbars, etc., look, start work on the power-up system, add scoring and timing (including deciding on game modes. Especially the part about endurance versus timed modes, and if I should just include them all), all the particle and otherwise effects, then the final graphics redesign.

I should probably also stop working until midnight because I was up late due to working late the night before...
carlfoxmarten: (Default)
...No news at all for the programming world...

Seriously, though, I've reached yet another major milestone in the development of Tetris Power: I now have a block I can move around the screen.

Despite the fact that I have no bounds and no other blocks for it to bump into (and the colour doesn't seem to be properly random), it's still an important step.

Next milestone should be in a couple of weeks when I add the bounds and the landed blocks. Then it'll almost be playable, but still far from complete.
(the landed blocks will be very tricky as I'll need to be able to drop not just an entire row, but also individual blocks due to powerups)

Currently, I have 19 source files (one of which is currently empty, and the matching header needs to be rewritten), and a total of 3572 lines in those files.
Current Linux executable is 180KB in size, with approximately half a Megabyte of data to load during run-time.

I think I'm still having fun writing this, as each small piece set in place is its own reward.
I should be working on smoothing the shape's motion next, then implementing the block randomization system, and finally fixing the colour problem before moving on to the grid system.

It's still a lot of work, but since I'm doing this a bit at a time, and ensuring that it works at each step of the way, I'm not getting bogged down!
carlfoxmarten: (Default)
I've got another image to present:

Cafe Wall:


There's a few things about this I want to do over (such as the doorway itself and the glass on the lamps), but most of the scene is pretty good.
(kind of surprising for a scene that could be as old as two years, I'm not sure)

Anyway, I think this scene was supposed to be a backdrop for the cafe chair scene I did around that time, but now I'm not sure it would be a good fit...

Any comments or suggestions?


More news of Tetris-Power:

I've started on the underlying game graphics and mechanics, which translates to loading and rendering a Wavefront Object file.
Next is drawing four of them in a Tetris shape, then moving them with the keyboard, then dropping them into the grid, then, well, you get the idea.

Lots left to do, but it's definitely coming along nicely.

I have to say that I'm almost enjoying this (actually enjoying this would be getting paid to work on it), the amount of thought I have to put into it is a bit much sometimes, but then you realize that you're over-engineering it again, and you really shouldn't be doing it that way.
(kind of like when I made a tape into MP3s and the software crashed. I took almost four hours on Sunday almost tearing my hair out trying to recover the backup files when I could have easily re-recorded it again in 2 hours while doing other stuff as well!)
carlfoxmarten: (Default)
After finding out why my Tetris-Power project wasn't running on my laptop, I've resumed development on it.
(apparently, my embedded Intel graphics-card doesn't do anti-aliasing, so I'm now making it fall back to no anti-aliasing if none is available)

Currently, I have a working "screen" system (to show and hide screens such as Options, the Main menu, the Splash/loading screen, and of course the main game screen) which I'll be using extensively to split the main drawing code out of the main entry point.

I still don't have any artwork done up for it though, and that's going to be very important if I want this to look professional...

Next I need to work on, well, the rest of it, including widgets (button, checkboxes, drop-down menus, etc. Mostly for the Options screen), the mesh-loading system, the block shapes and colours, the input system, and then powerups.

I guess I still have a long way to go...
carlfoxmarten: (Default)
*insert momentous occasion music here*

Simple Tetris version 1.1 is now available for download!

The requisite screenshot:


It retains all features of the previous version, but now with greater stability.

Only one known bug has been introduced during this rewrite, and I'm not sure how to handle it.
Previously, you could hold down a key and the block would move repeatedly (for example, holding down the 1 or 3 keys would have the block spin continuously), whereas now you have the press the key repeatedly yourself.
(admittedly a minor bug, but a bug nonetheless)

If you do choose to download and play this, please let me know so I have some idea of how popular it is.
(and any feedback would be appreciated)



The improvements I have planned for Tetris Power are as follows:
  • A "screen" system so I can show overlays, dialogs, etc. such as intro, option and help screens.
  • Hopefully an improved animation system so I can animate almost everything.
  • A more intuitive default key layout, with the option of changing them to fit the way you play.
  • Colourful backgrounds to add that professional touch.
  • Support for more block shapes, including three- and five-piece blocks, with options to enable and disable them.
  • More bells, whistles and shinies.


We'll see how long it takes to complete...

Profile

carlfoxmarten: (Default)
Carl Foxmarten

August 2017

S M T W T F S
  12345
6789101112
13141516171819
20212223242526
272829 3031  

Syndicate

RSS Atom

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Sep. 21st, 2017 06:59 am
Powered by Dreamwidth Studios