A Mega Blog

Posted by Astryl on Jan. 11, 2012, 1:37 a.m.

I promise to have some reviews of the F4D games I've played up tomorrow. For now, read this.

In a concerted effort to not post pointless blogs, I'm going to cover a lot of interesting topics in this one. So prepare for…

Mega's Mighty Wall of Text

Partitioned into neat little sections

Mathematics

I won't lie, I've forgotten 90% of the math I studied during my early

high-school years. So when my mom asked me to help find some free materials

for my younger sister and brothers on Algebra 1, I used it as an excuse to

get some decent books myself. I found some interesting books written by

lecturers at various Universities that covered the topic in an interesting

way.

I hate the textbook approach to studying. Textbooks are dry, horrible little

modular chunks of dried synthesized meat that leave a nasty taste behind when

you've finished chewing them. [/crazyAnalogy]

I prefer books written as books, by a real author who happens to be an expert

in the subject at hand; I'm not looking for a Mathematical Novel here, but I

mean somebody who can write for a technical subject in cohesive paragraphs.

Anybody can divide a subject up into eternal Headings, Sub-Headings, Examples

and Exercises; not so for a carefully constructed book.

Anyway, interesting fact: I learned C's operator precedence before covering

the similar Order of Operations at school. Result? Complete and utter chaos when

I insisted on performing problems from right to left, which only works when not

involving subtraction and division. Heh. Fixed that now.

Also, I had forgotten what Irrational numbers where. I know now, and also found out that I work with them all the time (Specifically, PI).

The only mathematical subject I truly mastered was Trigonometry, which is actually a relatively simple branch of Geometry; it only really deals with the triangle. This is important to me, since I wouldn't know how to rotate stuff without it. Or how to calculate motion.

Interesting problem that most game developers are faced with, in either 2D or 3D:

Given an object that has a movement speed of 5 units per frame, and implying that the next movement of the object must be in a direction of 45 degrees from the center of the object, what will the horizontal and vertical speed components be?

Most people I know instantly say that the components will be equal, but that's completely and utterly wrong. A speed of 5 in both directions at an angle of 45 equals a total speed of 7.07 (Rounded off to two decimal places). What this means is that the object will travel faster than intended at an angle.

The correct way to do this is by imagining the motion as a right-sided triangle. The Hypotenuse is the total distance to move (5 units), and the two 'legs' of the triangle form the horizontal and vertical components. These can be discovered using this equation:

hor_speed = cos(angle) * 5;

ver_speed = sin(angle) * 5;

Of course, angle has to be converted to Radians in order to be of any use in a Cartesian coordinate system, using either a deg2rad() function or making one:

def deg2rad(angle):

return ((math.pi/180.0)*angle)

(LOOK THERE PY! I USED PYTHON IN A BLOG! *end of world confirmed for 2012*)

To be perfectly honest, that nagging question that scares off most young game developers about the "needing math to develop games" thing? Yeah. I can answer it.

You can make games without math. Until you come to the point where you need it. And then you're going to find yourself copy+pasting some example off the internet, which might work, but here's the catch:

You don't understand how it works.

That can be damaging. One of the major reasons I waste time "reinventing the wheel" in my projects is because I want to understand how the underlying implementation works.

Games I've been playing

Well, I mentioned Transformers: War For Cybertron a few blogs ago. I finished it last week actually, and loved it. Pity I can't use the Multiplayer functions to completely pulverize some poor individual on the net, but I enjoyed the single player campaign enough to want to play it again. On Hard this time round for extra challenge.

Then there's Supreme Commander. Good tactical strategy, I must say. Difficult to get to grips with though, and the average game can take ages. Not as long as Civ though (I once spent 26 hours straight playing Civ 4. Dangerous game that.)

Starcraft has been fun. I've been breezing through the single player campaigns again (Ah, nostalgia), losing horribly when playing Single Player skirmishes, yet holding complete and utter control over a LAN game. Viva the combined Zealot/Zergling rush. Also, Mind Control. <3

Oh, and then there's Megaman Battle Network 3; I play it when I feel like a quick gaming fix without the loading times offered by major titles (Can't complain about that with Starcraft though).

I've once more used the most interesting exploit there is in the game: Bugs. You get this system in the game that allows you to customize Megaman with powerups that increase his HP, attack speed, power, and charge time (And other things too). You have to place these powerups on a grid of limited size, and with certain rules (Some parts have to be touching a certain line along the center of the grid, others mustn't, and you mustn't have two parts of the same color touching each other…. Mega disagrees).

One bug I have fun with is the Charge+1 Plus Part, placed on the line, which you're not supposed to do. Gives me an interesting 'bug' that turns my normal buster shot into a Reflectr1 with 200 shots or so. Fun stuff.

And I finally went and finished Sonic CD the other day. Started playing with the intention of getting all the good futures, gave up on that once I got to Zone 3, then managed to get them anyway when I found all the Time Stones. Good game that.

Oh. And let's not forget Quake 1 on Nightmare mode (Which isn't nearly as challenging as I used to find it a few years ago… I finished it quite easily)

Python and Networking

Well, in a complete fit of un-Megalike behavior I've been experimenting with other languages frequently. Python and Java being at the forefront of my experiments.

I love the easy multi-threading in Java, and the instant responses in Python (And some of the best documentation I've ever seen).

I've been tackling the beast that is Networking, using Python to experiment and generate psuedocode, then implementing it in C++.

To achieve this, I've been working with low-level Sockets. These are interesting beasts, and are used for any number of odd and completely non network related tasks. So after figuring out how to create simple client and server interfaces, I tackled two variations of the same problem: Blocking. So on one side I'm creating a multiplexer, and on the other I'm using Threads. I must say that tackling problems like this in Python can actually be fun. In C++ it involves countless hours hunting for the correct functions in the MingW headers, then looking up documentation on said function. Still fun, but more tedious.

That doesn't mean I'm not using C++

My C++ game kinda sunk. Why? Collision. I love/hate my engine. You see, the way it works is like this:

On the highest level you've got the Engine class. This handles the Window mostly,

and also contains a reference to a Room instance.

The Room instance contains a list of objects, and on a per-frame basis performs

initialization where necessary, the step events, draw events, and removal events.

In addition to this, collision detection is handled through the Room object.

My problem is that I seem to have a problem where a solid object can't collide with a non-solid object (Or vice versa) because of some code I had in there somewhere. Problem is, I can't find it. This causes a problem because I can't very well have bullets being solid objects, which leads to potential bugs where the player can stand on enemy bullets.

Now, all these problems can be directed at the HYDRA engine, which due to lack of foresight and poor overall design is now a horrible multi-headed beast (Seriously. Four GIT branches; one that was supposed to use SDL, one that kinda works in a Linux environment, and one that's a backup of an early version in addition to the latest 'stable' version).

So I made a smart design decision:

Instead of trying to debug the monster, I'm going to scrap it and start from scratch. With a brand new project file and a new design goal.

So the new framework/engine I'm making will probably use SFML again. It intends to mimic the functionality of Game Maker (That is, the low level scripts and helpers). This means that on the highest abstract level these types of objects exist:

Sprite

Tileset // I differentiate between Tilesets and Backgrounds for a reason

Background

Sound

Music

Object

Room

The attributes for these objects will likewise be 'lifted' from GM, to prevent my usual lack of foresight from hindering progress (I didn't implement an Origin function for Sprites in Hydra. And gave up after trying once I realized I wanted one).

Eventually I hope to turn this into a Runner, where the game itself is coded in a scripting language (Probably Embedded Python).

I plan on keeping the engine simple. This way, porting the runner will be simpler than my attempt at porting HYDRA to Linux (Which is kinda where I want to port the runner to).

C-ASM, SAUCE and LOLCODE-M

It turns out that while digging through my Dev folder, I found three old projects that I

had begun (And progressed with) last year.

C-ASM and SAUCE go hand in hand. Can't remember what the names mean, but.. C-ASM is an assembler into a custom opcode set for… SAUCE. Which is a CPU emulator for a 6502 based theoretical CPU. I got as far as implementing the opcodes BRK, ADD, LDA, STA, JMP, JMPZ, and of course NOP (Easiest opcode ever).

Then I forgot about it. Of major interest to me though was the assembler, which doesn't use Flex or Bison. I made it from scratch. It also handles loops, labels, indirect addressing, comments… not bad for a quick project that I forgot about.

LOLCODE-M is a bit older. A Lolcode interpreter, but a damned buggy one. Hey, at least I got it to successfully run this example I had made for it:

;Tis lolcode, Mega style

;So far, it has conditional statements, but lacks loops

hai;
canhaz stdio?;
kthx;

;Setting up mah cheezeburgers (Variables :3)
cheezeburger name = "Blank";
lol $name;
;Every line needs to be terminated with a ;. No reason really. I could remove
;it as a requirement, but I feel it's good to get into the habit.

;Variable re-assignment!
$name = " Variable";
lol $name;

;This is a weird language. The variable declarations are weakly typed, while
;the variable use is strongly typed (You have to decide WHAT you're using
;the variable as. $ is for string, @ is for a number. I'm still working on
;a full fledged number assignment parser (Must be able to read whole lines
;of input, like x = (2*@k)+6;

lol "";
rofl "Enter your name: ";
; OK, lol is like a println method, and rofl is like print. Dunno why I chose them
; though. And in case you haven't noticed, this is NOT very much like normal
; lolcode.
lolwut? $name;

lol "";
rofl "Hello ";
lol $name;

; Here comes the conditional
wut? $name == "Mega";
kk;
lol ":3";
lol "";
kthx;
wut? $name !! "Mega";
kk;
lol "You're not Mega >:{";
lol "Get outta here :P";
lol "";
kthx;

; Currently, not much can be done with numbers, besides addition.
; Because I only made the interpreter as it stands in 1 hour.
cheezeburger number = 5;
@number += 10;
; This will print the result, same as typing 5+10 in Python.

; Anyway, that's the end of this example code. 

kthxbai;

Of course, I have now learned of a new technique that I knew nothing about before: Tree based tokenization of expressions. And here I thought that Binary trees were best suited to game data-structures. Heh. Shows how much I have to learn.

The best approach to writing a 'proper' language is to implement only the basics. If you can implement mathematical expressions, variables, pointers/references, loops, conditionals and native code (External Dynamic library loading), you've got yourself the basis for a potentially unlimited language.

Programming languages like C++ are surprisingly compact if you take them minus all the added extras. They only have a handful of keywords. The rest of the language (The libraries we use) are built in the language itself, which is an interesting concept.

Of the arts and the mind

My mind. I will attempt to explain it to you. Imagine a futuristic looking computer room, with a pedestal in the center. On this pedestal is a gearbox of sorts with four settings:

LOGIC, CREATIVE, RELAX, BURNOUT. Now imagine a hyperactive gremlin that loves flipping the lever all day.

I'm currently going through a RELAX phase where I don't feel like creating anything in general. My artwork has suffered, as has my music. Heh. Of course, yesterday I was on a programming binge; who knows what I'll be doing tomorrow.

Back when I was 'only' a programmer (When I was still learning Pascal and C) I devoted my time to the subject. I didn't have any other skills to work with.

Until I started to hone my horrible art ability and even less impressive musical talent.

So now I enjoy drawing as much as coding, and that as much as composing music in either chiptune style or modern (On my guitar or in a synthesizer). If lurking on IRC was a skill I'd be working on that too.

Ponies hidden below. Don't read if you're allergic to that sort of thing.

Yeah, I'm still a brony. Not going to deny that. I wonder if anybody else on this site is still watching? Anyway. I thought I was a bad enough case (I have a wallpaper, icon-set, screensaver… all I'm lacking are real-life decor… which is a good thing), but I just had to laugh when my family don't seem to notice anything odd going on. I suppose with all the weird video-game characters that have hitherto graced my desktop over the years, they think that the cast of My Little Pony are something to do with a game I'm currently playing (Heh).

Why am I still watching the show? Something draws me to it. The animation, the voice acting, and the little references that are thrown in for adults.

The odd thing is, the people you'd be expecting to watch the show don't. Like my little sister. She hates it.

I found an unspeakable horror on the internet the other day. A fansite for My Little Pony… G3. I was going to nuke the site from orbit, but I used up all my nukes on the Transformers G2 sites… *sigh*

And I'm still investigating why I got a knife and Cupcakes.docx for Christmas….

So what else am I watching? Nothing. Adventure Time is on at irregular hours, and only holds my attention for a few minutes. I still love to watch Mythbusters though, when I catch it.

*Changes song in Windows Media Player. Explorer.exe crashes*

That's not an irrecoverable error though. Happens sometimes if I switch from a file format that uses a third-part codec (Like Haali) to a normal MP3 or something. Heh.

To end off

I'll write a bit about what I do when making music (Usually chiptune). I start by choosing an instrument, or a drum sound, and start by placing notes/beats that I like the sound of.

Sometimes I start off with a melody, sometimes I start off with a bassline, and other times I'll make an interesting drumroll.

Then it's a case of working out the chorus lines in the tune, and mixing everything together, figuring out a loop point then leaving it for a while so I can listen to it with 'fresh ears' and fix the problems that didn't jump out at me the first time round.

Anyway, enjoy my long blog. It should at least have one interesting section for each person reading it.

Caution:

TL;DR at your own risk. May contain traces of Ponies, Mega, Misinformation and Procrastination.

This document weighs in at around 17kb, with a word count of 2700+ words, and being 6 pages in length without changing the formatting. Only took me 20 minutes.

Comments

Unaligned 12 years, 8 months ago

Interesting read, although I didn't quite understand the section corresponding to C++. Good writing style for 20 minutes too.

death 12 years, 8 months ago

jeez that's a lot of text. i only had time to read some of the stuff on games. i'll be back to read more if this stays on the first page long enough lol.

I never encountered that bug in MMBN3 i thought that system was very well designed and i actually would spend a lot of time organizing my skills.

Sonic CD is easy. i got all bad, and all good, and all the emeralds, in separate save files. in fact the game was too easy that it was kinda disappointing. even the special stages are easy which are usually hard as hell in Sonic games such as Sonic 2 and ANY OF THE GBA Sonics. I also did time attack on every stage and special stage in Sonic CD. the sound track and graphics are amazing in that game but the level design sucks.

Astryl 12 years, 8 months ago

Quote:
I never encountered that bug in MMBN3 i thought that system was very well designed and i actually would spend a lot of time organizing my skills.

In all the Battle Network games that use the NaviCust system, there exist a bunch of useful bugs. BN6 had the bug that places the Stone Block when you charge your buster, and combined with the Airshot Buster bug… win.

Quote:
Interesting read, although I didn't quite understand the section corresponding to C++. Good writing style for 20 minutes too.
Thanks. Proving that 64digits has improved my formerly lax writing style.