Chomper Stomping jQuery/JavaScript/CSS 3/HTML 5, Java/PHP/Python/ActionScript, Git, Chrome/Firefox Extensions, Wordpress/Game/iPhone App Development and other random techie tidbits I've collected

27Aug/092

JavaScript Haxagon Game Board with Hexagon tiles

I'm working on a JavaScript version of The Settlers of Catan. The first problem I decided to tackle was constructing (visually and array-structure wise) the game board using nothing but loops (didn't want to hard code it).

This ended up being much more difficult than I thought it would be.

I am going to split this up into two parts:

1. Setting up the game board visually
2. Setting up the array structure

Creating a Hexagonal game board with hexagonal spaces in JavaScript with for loops:

For this to work properly, you must have an even number of columns and rows. I chose seven since that is what makes up the Settlers of Catan game-board.

You have to split the building of the board into three stages:

1. The expanding stage
2. The apex or middle of the board
3. The contracting stage

I placed everything in one large for loop that counted off the "rows".

I figured out that while the rows are less than half the max rows divided by two (and rounded down) the board would be contracting. The number of tiles you would start with would be equal to the maximum number of tiles divided by two, rounded up, plus the current row number.

Once the number of rows equals exactly half the number of maximum tiles (rounded down) you are on the middle row. In this case the number of tiles is the max number of tiles, no math required.

Otherwise, you are in the contracting stage and the number of tiles you need is equal to the maximum number of tiles, minus the current row, minus half of the maximum rounded down.

Sound complicated? That's because it is. This took me about 30 minutes to get straight in my head after studying the game-board shape, tiles, and making several diagrams and sudo-coding and then writing the actual code and fixing bugs (and deciding if I had to round up or down at certain places).

Here is the actual code:

<html>
<head>
<style>
img{
	margin-top: -18px;
}
#board{
	padding: 50px 25px;
	background-color: #000;
}
</style>
</head>
<body>
<div id="board">error loading</div>
</body>
<script>
function boardSetup(){
	var max = 7;
	var html = "";

	for(var row = 0; row < max; row++){
		if(row < Math.floor(max/2)){
			//place spacer tiles
			for(var space = 0; space < (Math.floor(max/2) - row); space++){
				html += '<img src="spacerTile.png" />';
			}

			//place game tiles
			for(var cols = 0; cols < (Math.ceil(max/2) + row); cols++){
				html += '<img src="tile.png" />';
			}
			html += "<br />";
		}else if(row == Math.floor(max/2)){
			for(var cols = 0; cols < max; cols++){
				html += '<img src="tile.png" />';
			}
			html += "<br />";
		}else{
			for(var space = 0; space < (row - Math.floor(max/2)); space++){
				html += '<img src="spacerTile.png" />';
			}
			for(var cols = 0; cols < (max - (row - Math.floor(max/2))); cols++){
				html += '<img src="tile.png" />';
			}
			html += "<br />";
		}
	}

	document.getElementById("board").innerHTML = html;
}

boardSetup();
</script>
</html>

Here are the images that go with it:

Here is the tile:tile
Here is the spacer. This one is completely invisible: start->spacerTile<-end

Here is the code running on my site.

4Jun/092

Other M

So, I know this blog has been leaning more towards serious development than flash game development recently. But if you pay any attention to www.chomperstomp.com (you shouldn't) you will know that the last game I developed was a Metroid clone. Which might give you a hint at how I feel about Metroid. I love it. It was the first video game I ever bought, and I'll be a Metroid fan till I die. It's right there behind Zelda and in front of Mario and Mega Man, which are all embraced in the loving arms of Double Dribble...

So, that said, and without further ado, I present to you (as if you hadn't already seen this from reading PA or just having an appendage flaccidly placed in the vicinity of the pulse of video game culture) Metroid:Other M.

AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHWSOME!!!!

10Jun/080

Christian Video Games

If I ever have time to make another video game (it will be a while) I want to make one like this:

http://www.nintendo8.com/game/165/spiritual_warfare/

Yes, by today's standards it's lame. But at the time it (to me) was awesome. A Christian Zelda clone. It doesn't get any better than that.

The concept is so simple. Run around converting people to Christianity with the fruits of the spirit, the armor of God, and learning about Scripture to increase your faith.

I played this game for maybe a week as a kid (until I had to give it back to the person I borrowed it from) and I retained a TON of what I learned about the Bible because of it. I'd love to see a modern Zelda clone version of this game...

Anyone know of any good Christian Edutainment that puts fun before education like this one does (and therefor actually gets you to play it, and then you actually learn from it)?

13Feb/081

Hey wait… That’s cheating…

If you are at all familiar with the game Portal, you will know about the "challenge" levels.

I visited a little site called "wegame" and perused the top videos. One of the videos was on how to do a particularly tricky challenge in portal: Level 13 in 2 portals. I, having tried and tried to beat this level in two portals, knew this was impossible. What tom-foolery did they come up with to get this done? I had to see. So I clicked on the video. I was appalled. If you want to, you can take a look for yourself:

See, to me, that's cheating. It's never presented to you as a valid way to play the game. It's a hack. Granted, it's extremely clever, but I was never aware (when playing these levels) that you were allowed to beat them by cheating. Why do I call that cheating? Because it goes outside of the presented valid methods of game-play. You are given a set of tools, and to me, if you are going to get valid awards you have to stick with the valid tools, or else be told that you can use any method that you see fit. I was never told to use any method I see fit.

I know, I know, you're saying it should be implied. No, no it shouldn't. You should not be officially rewarded for a bug in the gameplay of a game. They should have fixed the bug, not expected you to find it and then relied on it for winning. Especially when they never officially present the bug to you. There is no circumstance in which I would ever have figured this out, because I follow the rules, and the rules do not state that this should be able to happen. The rules state that normal physics and gravity apply. Under normal physics and gravity, you would never be able to do this thing that you have to do to get the award.

I guess what I'm saying is, "Hey! That's not fair!". Maybe I just need to be more of a rebel, and look for ways to cheat. To "game" the system instead of playing by the rules. Who knows... I just know, I'm never going to require someone to exploit a flaw in my system in order to win. As soon as this flaw (and yes, it is a flaw) was found, it should have been fixed instead of being exploited. The game is broken. Don't celebrate it's fallen-ness, fix it.

=========EDIT=========

Hey, what??? So anyone who uses google reader knows that it sucks (I'll be switching to something else as soon as I can find an acceptable alternative). It takes anywhere from 1-12 hours to update after you post a news item for your feed. Even if you hit "refresh" it doesn't go out and get the newest items.

I was a happy victim of this programmatic shortcoming this morning.

See, my brother and I are telepathically, unconsciously connected. We both posted a different video from wegame about the same portal level at the same time without knowing the other one was doing it.

You can see his explanation here, but my path to this Reference Burst Theoryâ„¢ was a bit different. Here's how it went down:

I get an e-mail from PCWorld about their "beta watch" column. They talk about this video game site called "wegame". I didn't read the article, I just went straight there. I recognized it immediately as the site that Jesse has been using to post his videos. Ok, cool, maybe I'll take a look at it since it seems to be getting some attention. I click on "top videos" or something (basically I just wanted to see how good their best video was). I click on "Portal Chamber 13 - 2 Portals" (because I knew that was impossible and wanted to see how they had to cheat to accomplish it). I make a blog post. I go to Google reader (an hour or two later) and see Brian has some new comments in his comments feed. I read them. Jesse says "That's scary" in reply to some post called "Portal Chamber 13 - 4 Steps". I laugh at him cause I think he's a newb who accidentally replied to my post on the portal video on Brian's blog. I click on it to make fun of him. I can't get to The Gimcrack Miscellany because my computer sucks and makes it look like the site is down. So I IM Brian and we discover (to our amazement) that we have both posted about Portal, but because we both use Google Reader, neither of us knew the other one posted about Portal. This is insane because neither of us have posted anything about Portal in a long time, and because we both found the video at the same site and posted a video about the same level (just different aspects of the same level). Scary.

28Dec/071

Paperboy

Did you ever stop to think about paperboy? What were all those people doing running around trying to hinder you delivering their papers to them? How sits down and goes "I've got it! I'm going to make a game about delivering newspapers!"

It just goes to show you can make a game about anything. You just have to be creative.

Anywho, here is the whole point of this post:

Filed under: movies, video games 1 Comment
26Dec/070

Free Half Life Games

In honor of Christmas, I'd like to share a gift with the person who reads my blog. Free Valve Games.

http://www.steampowered.com/ati_offer1a/

That gives you free Half-life 2 lost coast, and Half-Life 2: Deathmatch. Your welcome. You also get 50% off of HL2 and HL2:E1. It's so worth it. If you don't own them, take advantage of this while you can.

Merry Christmas.

ps. I found this while updating my ATI Drivers X1300 drivers for Windows Vista...

Filed under: video games No Comments
25Dec/071

True 3d for Wii

This is one of the most awesome things I have ever seen.

You can check the guy's website out here.

If you are one of those people who just don't care about video games, then think about it this way:

Let's say your parents/grandparents/whatever live in... Pennsylvania, and say that you live in Indiana. What if you could just put on your glasses, put in your ear-piece, and call them on the tv phone. Then if you walk around your room, your perspective will change. It will look 3d (even though it's not). It will be as if they are standing just on the other side of a window.

Think about if you are in the army, flying a plan... sitting at a desk. It could look exactly like you were in the cock-pit. I know we have technology now that lets you fly remotely, but it's not this realistic.

I'm sure there is stuff like this out there already, but this is the first time I've ever seen it. Plus, all this costs is about $400. That's it. You could feasibly set any of this stuff up for under 1 grand (you'd need two wii's, the glasses, 4 wiimotes, and some special camera rig for the tv phone).

This is just amazing...

28Nov/073

My Enemy’s Enemy is My Friend

Well, the guy who has been bothering me in oGame went on vacation mode for the holidays. Then in the wee hours of the morning this morning he came back.

I'll admit I had gotten lazy in his absence. I didn't even bother to fleet save while I went to bed. I just sent out my fleet to attack a bunch of people at 100% speed, which meant they would be back well before i got up. When I got up... they were all gone. He had come back from vacation mode and as his first order of business, destroyed me utterly (again... for like the 15th time).

Once again, I thought about quitting. He destroyed about 600k worth of ships that I had worked hard for the last 6 days building up, and he stole a nice nice chunk of resources (about 175k).

Instead I looked five slots above me to the guy with the moon. His alliance is ranked 2nd in the universe, and he himself is ranked 24. I sent him a desperate plea for help. He responded VALIANTLY. You can take a look at the damage he inflicted here (loads really slow, so here is a screen shot):

eatthat.png

I wasted 16 espionage probes (8 before and 8 after the battle) to witness my enemies decimation for myself:

espionageparadise.png

espionageparadise2.png

Filed under: video games 3 Comments
21Nov/074

If you can’t beat them… Annoy them until they leave you alone or destroy you utterly…

So I'm having this problem in oGame.

I built up this fleet and planet, and then I wasn't able to log in for a few days. When I got back I had had well over 200k in every resource, but the guy below me came and stomped me, taking half of my resources and utterly decimating my defenses.

"Well played..." I thought. I realized I had not kept up on my defenses and really needed to improve in that area. So I devoted all of my resources to building those back up. I spent a week soley focusing on strengthening them, sending transport fleets from my five other planets to that one loading up my resources and then spending them all massing massive amounts of munitions. I had well over 60 light lasers, and at least 20 of everything else, plus small and large shields. Then I didn't log in one day.

The next day I logged in he had attacked me again and decimated my defenses. Great. So I shot back two interplanetary missiles to show him i wasn't just going to roll over.

He fires back a message. Something along the lines of "I can kill you all day long. Let me know whenever you're ready to give up and join my alliance. I've got spots for you and your alliance members."

Why thank you Emperor Palpatine, but I don't think I'm going to join the dark side just yet.

I'm of two minds here.

1) Do I really want to play a game where the only option you have is to harm other people (in game)?

2) This guy is going DOWN.

Of course the angry #2 mind is automatically louder and stronger, and has a significant investment of emotions and time behind it. The calm rational #1 mind is probably right. Why would I want to play a game where the only option I have is to fight with other people, causing nothing but negative feelings and effects on them? That's evil. This game is evil. It really hit home when I spent a whole day pissed off and hating him and plotting my revenge.

Now, up until this point I've been able to ignore it. I've been attacking people who quit the game, and thus don't care if I attack them and take their stuff, they don't want it anymore. Or I've been building my resources by mining my planets. But at a certain point in the game... I have to start killing other people.

What do I want to get out of this game? I love resource management games. I'm greedy, and I like imaginary circumstances where I get rich quick.

So even when I'm not hurting other people I now am feeding a vice: greed.

That in itself doesn't necissarily make the game evil. Just because I like to work hard and horde resources and build up my empire, doesn't necessarily mean I am greedy. But an argument could be made in that direction. However, when asked, when I have the resources, I freely give to others in my alliance (sometimes at the cost of myself) so I can't be too greedy, right?

So, back to the purpose of this post:

What to do about Palpatine? I'm sure as hell not going to join him. I can't beat him though. I can do everything in my power to annoy him until I become to much of a bother to bother anymore and he leaves me alone.

Several things I will do to this end:

1. Make it un-rewarding to attack me.

I will have absolutely NO FLEET on the planets he attacks. I will also have NO RESOURCES. So his only purpose for attacking me will be just because he wants to destroy my defenses. That's it. I'm not going to make that easy either. I'm devoting all of my resources now to building up defenses and researching stronger sheilds and armor and weapons strength to make it really painful to him. So now the only thing he will gain by attacking me is just the satisfaction of seeing my stuff destroyed, but he will pay dearly for that satisfaction.

2. If he attacks me, attack him back.

Never ever ever let any aggressive movement in my direction go un-retaliated against. Even if it's just one interplanetary missile, it will still cost him beyond his initial attack to attack me. I know he has defensive missiles that will just blow my missiles out of the sky, but those cost him 8k metal and 2k deuterium a piece. The more I launch at him after each attack he sends at me, the better.

3. Annoy him in any way possible:

haha.png

Also, whenever he attacks me, I am toying with the idea of sending him 20 messages to flush out all espionage and battle reports so that he is unable to see what my defenses are and what he killed/lost (until his fleet gets back to his planet). That will not only frustrate him, but give me the advantage of maintaining secrecy so that he doesn't really know exactly what he is up against.

I'll keep you updated on how all of this goes. And I'm still thinking about quitting this game...

Filed under: video games 4 Comments
16Nov/070

It all starts with an idea

When creating a video game, or program of any kind, it always starts with an idea. Well, it starts with a need, then you come up with an idea to address that need.

Today I have had my idea: Chomper Tactics, or maybe Tactics Stomping, or maybe just plain old Tactics.

Heres the gist:

Multi-player (optional)

Choose four team members

Choose where in the first two colomns of a seven column grid they go (on your side, player 1 left, player 2 right)

Battle it out turn based.

desktoptactics.png

Initial thoughts on characters:

Mage, Knight, Pali, Rogue, Archer, Fighter, Priest.

You can choose any combination of these, but only four total:

Mage, Mage, Priest, Knight

Pali, Pali, Pali, Pali

Possible Hurdles:

Balancing. Don't make any one class inherently better than any others.