Tuesday, May 12, 2009

I'm Still Alive!

I realized it's been almost 2 months since I posted here, sorry about that! Here's what I've been up to!

Yes, I've been very busy, but I'm going to try to stop ignoring this blog as I have been. I promise.

Tuesday, March 3, 2009

New Blog!

While I intend to continue posting to this blog, I have a new blog over at kavwoosh.com! It is primarily going to focus on games and game design, while this blog will stay at a more technical "i-had-this-problem-and-did-this" level. Kavwoosh will also focus on my professional activities, so keep an eye out!

Friday, February 27, 2009

MySql Subquerys Are Molasses

Just a quick note on an issue I ran into today.

When using MySql, if you have a query that looks like this:

Select A, B
From table
where A in (Select C, D From AnotherTable)

Even when the subquery returns a very small resultset, the overall query will slow to a crawl, if it completes at all. This is because of how mysql handles the "in" statement. The only way to really get around it is just to join the two queries and filter, which isn't terrible, though I hope a situation comes up where this solution is untenable.

Monday, February 23, 2009

Peek-a-Boo Divs

I was just messing around with some HTML/CSS/Javascript stuff the other day, and came up with something kind of awesome. It's a div that hides until it has the mouse placed over it, and then hides again when the mouse leaves. It's very similar to a hiding toolbar, and could be very useful if applied correctly.

Due to its ability to be present, although mainly unseen, it would be particularly useful for web pages/applications that require large amounts of content on screen, so that more wouldn't have to be devoted to the standard menu.

I've tested this in IE7, Firefox, Chrome, and Opera. It works no matter the resolution, though I have yet to try it on my G1 (for the size tests, I basically just scrunched firefox and IE down very small). It's W3C compliant (except for the colors, which I don't really care about) for both the html and the CSS. The HTML uses the XHTML 1.0 strict dtd, and there isn't a single table anywhere. This is how I roll.

HTML:


< !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Menu Bar Test</title>
<link rel="stylesheet" href="./menubar.css" />
<script type="text/javascript" src="./menubar.js"></script>
</head>
<body onload='pageLoaded()'>
<!--<div id="collapsedmenubar" class="menubar" onMouseOver="overCollapsedMenu()">
<p>Click here for menu</p>
</div>-->
<div id="fullmenubar" class="menubar" onmouseover="overCollapsedMenu()" onmouseout="leftFullMenu()">
<h1>Menu</h1>
<p>
<a href="index.html">Home</a>
<a href="index.html">Projects</a>
<a href="index.html">Contact Info</a>
</p>
</div>
<div id="content">
<p>This is where the content goes!</p>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Proin nibh nisi, dapibus vel, elementum eget, vehicula vel, lorem. Donec ipsum est, tincidunt iaculis, nonummy ut, dictum vel, velit. In leo magna, aliquam et, suscipit sed, cursus in, tellus. Suspendisse dui felis, convallis vel, porttitor pellentesque, dapibus vitae, neque. Suspendisse potenti. Sed erat orci, rhoncus at, tempor in, pellentesque vel, tortor. Nam urna. Sed bibendum. Aenean ultrices vehicula lacus. Duis ac arcu. Nulla facilisi. Sed pulvinar risus eget leo. Praesent pulvinar varius ante. Cras lorem nibh, elementum nec, accumsan nec, imperdiet et, felis. Fusce gravida sem et orci. Suspendisse lectus nibh, tempus eget, sagittis sit amet, pretium vel, dui. </p>
<!--There was more Lorem Ipsum, but I dropped it for readability's sake.--%gt;
</div>

<div id="footer">
<p>Here is the footer!</p>
</div>
</body>
</html>


CSS:
*{ /*I know this is bad, but hey, it's a test document.*/
padding: 0px;
margin: 0px;
border: 0px;
}

.floatedlabel{
float:left;
}

.menubar{
background-color: green;
border-left: 5px yellow solid;
border-right: 5px yellow solid;
border-bottom: 5px yellow solid;
color: white;
left: 10%;
position: fixed;
right: 10%;
text-align: center;
top: 0px;
width: 80%;
z-index: 9001;
}

body{
background: lightblue;
padding-top: 5%;
}

h1{
float: left;
}

#content{
background-color: lightgreen;
border: 2px yellow solid;
left: 5%;
position: relative;
width: 90%;
}

#footer{
background-color: lightgreen;
border-left: 2px yellow solid;
border-right: 2px yellow solid;
border-top: 2px yellow solid;
left: 15%;
position: relative;
text-align: center;
top: 5px;
width: 70%;
}


Javascript:
function pageLoaded()
{
var fullmenu = document.getElementById("fullmenubar");
//fullmenu.style.visibility = "hidden";
fullmenu.style.top = "-70em";
fullmenu.style.height = "70.2em";
}

function overCollapsedMenu()
{
var fullmenu = document.getElementById("fullmenubar");
//fullmenu.style.visibility = "visible";
fullmenu.style.top = "0px";
fullmenu.style.height = "";
}

function leftFullMenu()
{
var fullmenu = document.getElementById("fullmenubar");
//fullmenu.style.visibility = "hidden";
fullmenu.style.top = "-70em";
fullmenu.style.height = "70.2em";
}


Oh, sorry, did you want that menu to be at the bottom, maybe for some Mac OS X dock-style menu? Well, in that case, for the menubar, change
top: 0px;

to
bottom: 0px;


and in the javascript replace all instances of "top" with "bottom". Enjoy.

Wednesday, February 4, 2009

PyGame Presentation

It's been a while since I posted, I know, but I've been busy. Here's one of the things that's been occupying my time. I worked up a 2d top-down collecting game demo for the Drexel Game Developer's Group, and a presentation to go along with it. I'm only a week behind schedule for posting it, which is easily attributable to my laziness.


Here's the presentation:





And here's a link to the code:


You need to have python and pygame installed to run it, but other than that, just execute runner.py.

Wednesday, December 31, 2008

Defend The < Insert Anything >!

Happy New Year! It's been a while since I last posted but I've started a few other posts, and will hopefully will be getting them out of the tube sometime soon. 


When I was younger, my dad, who was in the military, told me that whenever the Army is going to attack a fortified position, they always tried to have a 3 to 1 advantage on the defenders, to minimize their casualties. This is because it is much easier to hold ground than it is to gain it, especially if you know the lay of the battlefield better (or even fortified it yourself). You can concentrate your resources in certain chokepoints, and gain significant advantages on your adversaries. Unless taken by surprise, it is very easy for a defensive position to hold back wave after wave of attackers.

I think that this is one of the primary reasons that the "Tower Defense" style of games is getting very popular, especially in the casual/mobile gaming scene. Usually termed as "Strategy", "Action Strategy", or something similar, these games have a very basic premise: you've got a thing, the bad guys want to blow up your thing, don't let them blow up your thing. It's actually quite ingenious the way game designers have kind of spun us on our heads. Back in the days of yore, the player was always attempting to get past the defenses, rescue someone or something, or blow something to smithereens. Now, players are tasked with keeping out all those pesky interlopers, though the basic characterizations are the same.

What do I mean by that, you ask. Well, when one character was able to singlehandedly slaughter the entire Russian army with nothing but a toothbrush, some people called that "unrealistic." However, when that single person is tasked with repelling wave after wave of robotic archer demons, that's much more believable.

Like in my post about zombies, people who play video games like to suspend disbelief far enough to accept the game world, the (usually ridiculous) story, and the mystical powers that they are somehow imbued with. However, granting a modicum of realism, such as having them set up defenses, and actively engaging swarms of enemies, allows them to feel empowered, but not invincible. When the player feels like they can do anything with little or no consequences, the game breaks down somewhat, as the player tears through the levels, unconcerned about what will become of their avatar.

That's all I have to say on the subject, don't worry, I promise that my next post will have some code in it. ;-P

Thursday, December 18, 2008

The Analysis of the Dead

In this past week's Zero Punctuation (I should really stop getting my blog ideas from it, I'll work on that), Yahtzee remarked that besides Pirates, Monkeys, and Ninjas, Zombies were perhaps the most popular thing among "nerds". Specifically gaming nerds. Yes, the "legitimacy" of zombies in popular culture is growing every year. What used to just be a cheap horror movie effect has actually been used to create artsy, compelling narratives and games. Need proof? Check out "Fido."

Sure, zombies are getting big. Pirates got big, Ninjas got big, monkeys...I think their time has passed as well. Zombies seem to be sticking around for a bit longer though. It's probably partly due to the whole "decomposing" thing. All joking aside, what makes nerds, a generally erudite and intolerant bunch, so happy to have an antagonist that is slow, dim-witted, operates in hordes, and attempts to eat brains?
Hey, wait a second, I think there might be something there.
Zombies are the exact opposite of what a stereotypical nerd wants to be. They're barely above fungi when it comes to IQ, and have an unstoppable need to attack those that aren't one of themselves. Is it just me, or does this sound exactly like the kids that made fun of you in high school because you'd rather read than watch "Grey's Anatomy"? In fact, when you think about it, what do zombies usually want to eat? Brains? What's the only way to kill them? Kill their brains? If someone was coming up with these metaphors, they weren't digging very deep (probably about 6 feet). 
What naturally follows the intelligence disparity is the common criticism nerds have for "normal" people, that they act like sheep, meandering pointlessly around in herds. Or hordes. Used to social exile, imposed either by self or by others, nerds generally scoff at being part of a large group. They don't want to be following the trends that everyone else follows, because everyone else is stupid, and probably wrong. If you hadn't noticed, this is where the intolerance comes out. Although they commonly accept people who are "different" into their ranks, many nerds find non-nerds to be unbearable. Therefore, any nerd anathema is most definitely going to exist in some sort of large group. This serves another purpose as well. By making their antagonists a seething mass, each individual is deidentified, and it doesn't really matter who's head you're having to lop off to get to the rescue zone. It could be your old gym teacher, that cute girl who said you smelled funny when you asked her out, anyone. 
All that being said, I have to say that I'm still a zombie fan. Although I like to think of myself as a very tolerant person, I'd definitely agree that part of my liking of the zombie metaphor is a bit of distrust and dislike of the general public. Not exactly as a mass of individuals, but the whole societies themselves. To me, the zombie hordes represent the selfish, immutable cultures that are sending all of us to hell in a handbasket, finally imploding upon themselves, making way for a new world, while still representing major obstacles to that world as they slowly rot away.
Or maybe I'm just hungry for BRAIIINS.