Author Archives: Travis

Moving Along A 2D Path

For game #2 of 2016, I wanted to use a movement system similar to one that can be found in Steam Birds, Critical Mass, and some other games. I am most of the way there and would like to talk about some of the different approaches and barriers I have run into so far.

Hermite Interpolation

Gonna start with the difficult sounding silly math that is not really what I needed and also not as complicated as it sounds. Especially since the code for it is out there and you can almost copy pasta it into whatever language you are working in.

In Monkey-X it looks something like this:


Function CubicHermite:FloatDeque (start_point:Float, end_point:Float, start_velocity:Float, end_velocity:Float)
	Local pathPoints:FloatDeque = New FloatDeque
	Local division:Float = 30.0
	
	For Local i:Int = 0 Until division
		Local t:Float = (Float(i)/division)
		Local t_square:Float = t * t
		Local t_cube:Float = t_square * t
		
		Local a:Float = 2*t_cube - 3*t_square + 1
		Local b:Float = -2*t_cube + 3*t_square
		Local c:Float = t_cube - 2*t_square + t
		Local d:Float = t_cube - t_square 
		
		Local point:Float = a * start_point + b * end_point + c * start_velocity + d * end_velocity
		pathPoints.PushLast(point)
		
	End
	Return pathPoints
End

Basically you use this method to find some number of points along the curvy path that you are trying to create. You need to know what direction and speed you are going to begin, the direction and speed you will be going when you are done, and what point in time you want to get on the line. Essentially if you wanted to move along the line at 30 frames per second you will need 30 points to render whatever you are moving at. You would loop through the function doing your interpolation 30 times where the point in time is 1/30 to 30/30. You push all of these points into some sort of ordered data structure, in my case a Deque.

Note: This particular implementation only finds 1 part of the coordinate. If you are in 2D you need to run it once for X and once for Y, and if you are in 3D you need to run it one more time for the Z coordinate.

The formula then creates a nice curvy path to go from the first point to the next but ended up being not exactly what I was going for.

Simple Steps Approach

The problem I was having getting my head around with the interpolation approach was how to properly put limits on the movement. Distance was not a problem, but I only want the units to be able to turn so far.

The solution I ended up going with was to give each unit a rotational angle limit. Then I went through the 30 step loop again and on each step I calculated the angle from where I was to where I was headed. If it was greater than my current heading, we add the rotation limit to our current heading. If less than, we subtract the rotation limit from our current heading. Then we move 1/30th of our speed in the new direction and repeat.


Method SetControl(click_x:Float, click_y:Float)

	Local goal_angle = ATan2((click_y - position.y), (click_x - position.x))
	Local start_angle = heading
	Local control_pos:Vec2D = New Vec2D(position.x, position.y)
	Points = New Deque
	
	For Local i:Int = 0 Until 30
		control_pos = NewPoint(control_pos, start_angle, goal_angle, maxRotation, maxVelocity/30.0)
		If (start_angle > goal_angle)
			start_angle = start_angle - maxRotation
		Else If (start_angle < goal_angle)
			start_angle = start_angle + maxRotation
		End
		goal_angle = ATan2((click_y - control_pos.y), (click_x - control_pos.x))
		Points.PushLast(control_pos)
	End
	control.position.Set(control_pos.x, control_pos.y)
End

Function NewPoint:Vec2D (start_point:Vec2D, start_angle:Float, goal_angle:Float, max_angle_change:Float, distance:Float)

	Local new_angle:Float
	If (start_angle > goal_angle)
		new_angle = start_angle - max_angle_change
	Else If (start_angle < goal_angle)
		new_angle = start_angle + max_angle_change
	End

	Return New Vec2D(start_point.x + distance * Cosr(new_angle * (PI/180)), start_point.y + distance * Sinr(new_angle * (PI/180)))

End

Doing this lets me intuitively limit the turning radius and maximum velocity of the units. It might not be the fancy way to do it or the most efficient. But it works. And that is all we are going for.

Note about Monkey-X Documentation for ATan2(x, y): the documentation reads that it gives the Arc Tangent of x / y in degrees. Traditionally these variable names are switched. If you are thinking in typical Cartesian coordinates you will want to pass you Y value in as the first parameter and X as the second. This caused me a bit of confusion.

p.s. This code was not cleaned up for this post and a lot of it was written between 10 P.M. and 1 A.M. The purpose was not to show of how code should look but rather sample implementations of useful functions.

Releasing a Meteor-Angular App To Digital Ocean

I am not going to go super in depth on this but I do want to talk about what I learned by going through the steps of setting up a Digital Ocean server and building the text adventure game to release to it.

What You Need

  1. A computer with an internet connection and an ssh client
  2. A MeteorJS app you want to put online
  3. An account at Digital Ocean
  4. $5 or you can use my referral link to get $10 in free credit at Digital Ocean

First Step – Set up a Server

There are quite a few guides out there about setting up a server on Digital Ocean. They even have there own documentation section that is actually really good. Basically all you need to do is click “Create Droplet” from the Digital Ocean home page and select the options you want. You can get by with the $5 minimum size droplet, especially for testing purposes. I used a basic Ubuntu 14.04 install for this test.

I tried doing the meteor install manually initially and ran into a snafu. The base $5 droplet only has 500MB of RAM. This is not really enough for Mongo and NodeJS to run and do install things for Meteor. You may need to manually create a SWAP partition. I used this guide from Digital Ocean’s docs and created a 2GB SWAP space. This is basically just telling the server to use some of the hard drive space like RAM. This is not recommended for production scenarios but works just fine for testing.

Step Two – Use Meteor Up

While you can install Meteor and Mongo and NodeJS or Nginx all manually, I would recommend using Meteor Up. It has clear instructions and handles all of the yak shaving for you. All you need is to install it using npm.


npm install -g mupx

then do:


cd to_your_meteor_app_directory
mupx init

Then you fill out a nice configuration file and run:


mupx setup
mupx deploy

and you are done!

Additional Steps

If own a domain and want to point it at your server, get the name servers from the site you bought your domain from and go into Digital Ocean’s Networking page, select Domains from the menu on the side and add a domain to your server.

Disclaimer

This is not necessarily the right way nor the best way to deploy a MeteorAngularJS app. It is however a very simple and quick way of getting it deployed to testing environment.

Another way of getting an easy deploy on inexpensive hosting setup is to use Galaxy which is designed for Meteor apps specifically. This is now recommend in the Meteor tutorial as Meteor.com no longer supports free hosting for Meteor apps. I have not used this yet personally but it is another easy option.

Put some code out in the wild and don’t forget your Free $10 credit on Digital Ocean.

Game 2 of 2016 Design Notes

Its time to start on game #2. After the last few games experimenting with MeteorJS and writing games in Javascript, I figured it was time to get back to a dedicated game platform. As of yet I have not decided which but am thinking of going back to Monkey-X or diving into PhaserJS. Additionally, I have changed one of my goals for the year. I will not be releasing games to mobile. They will however still try to be mobile friendly designs but just released for the browser.

But enough of that, into the design.

The Game

For game #2 I am planning on using a mechanic that I have seen in several games, the most well known probably being Steam Birds although an almost identical mechanic was used in a game from the 90’s called Critical Mass. The player will have a unit (or units) that they give commands to that then move and act in short bursts of “real time.” Like a lot of games it will be combat based where your unit destroys others and tries to not get destroyed itself.

Goal

Destroy the most enemy units over a course of X number of turns. Deathmatch.

Rules

Each unit will have speed and turning radius that limits there movement each turn. They will also have some health or toughness that when it reaches zero, they are destroyed. After a set number of rounds, the player with the most enemies destroyed wins. Ideally this will be multiplayer.

Interaction

Basic interaction is players score by destroying each other. May give units additional abilities or power ups to be able to interact with the opposing units.

Catch Up

This could either be a power up when destroying an enemy with more kills than you, or a bonus on respawn. Have not decided yet. We will play around with these ideas and see which one plays better.

Inertia

Like many good turn based games, this one has a set number of turns. Once they have all been taken the game is over.

Surprise

Random spawn locations and respawn locations. Random power ups perhaps. I was thinking of adding some sort of “cloud cover” where a unit could enter it and hide and nobody could see it and it could not see outside of the cloud. This would allow a player to change direction to get away but possibly make a bad choice and run into an opponent.

Strategy

I think in order to add a necessary strategic layer, the units will need some sort of limited consumable weapon, shield, etc. that players can learn to use more effectively. Possibly manage an energy level for weapons and shields.

Fun

I am taking an idea that I and presumably several others already find fun, 2D dogfighting, and adding some new twists that I believe will prove to be fun as well.

Flavor

With the energy idea, I am thinking space / sic-fi flavor. It fits pretty well and is one of my favorites. Maybe piloting drones in a space based tournament.

Hook

Sort of along the lines of taking something popular and adding other ideas into it. For me the hook is multiplayer version of steam birds. I think that would be pretty cool. Like 8-20 players battling it out, maybe even in teams. The turn based part of it might be a bit rough with that many players with each decision part of the turn needing a timer.

Final Thoughts

Looking forward to making a prototype of this game and start play testing. Learned a good bit the first 3 months working on game 1. Looking to learn even more in the 2 quarter of the year.

Keep growing and learning.

March 2016 End of Month Goal Review

Time for another month end review. This one just happens to be in the middle of the next month.

Goals

  1. Write 3 Blog Posts Per Week and Publish 2 – Publishing for March was mostly on schedule, writing still has not gotten up to 3 per week and the buffer is empty. In fact this post is about a week and a half late with 3 publish days passing with nothing written. All in all a bit of a failure. Still progress over last year though.
  2. 1 Game Designed, Created, and Released Per Quarter – I spent a good bit of my time during the last week and a half rewriting the Meteor-Angular 2 code to Meteor-Angular 1. The app now builds and runs on Android without a blank screen. The other part of the time was spent figuring out how to deploy it to a Digital Ocean server. This has been done successfully as well using mupx which turned a possible headache into a much smoother process. I still need to work on deploying the game to the Play store
  3. 1 Book Read Every 2 Months on Game Design – I might have read 3 or 4 chapters of the The Art of Game Design. It was all excellent reading and the book continues to provide excellent ideas. Looks like this may be 1 of 2 books for the year.
  4. 1 Article Read Or 1 Video Watched About Game Design/Creation Per Week – Absolute fail here. Maybe watched 1 video and read 1 article for the month of March. No notes taken and no real memory of what they were about.
  5. Get 100 People Reading Evolving Developer Per Month – Again, no progress made. However I did spend time researching various methods of marketing and promoting a blog. This was sort of done instead of researching game design for March. Ideally the ideas that are used to market a blog or website will translate into marketing a game.

What Went Right

I have a game, however bad, ready to deploy to the Play store and deployed to a Digital Ocean server. This was the ultimate goal for the first quarter this year. This process has given me material for several blog posts. Also I learned a bit about marketing and promoting a blog. Now all I need to do is put it into effect.

What Is Not Perfect Yet

A lot of the time I plan to use to write, code, and read is on Saturdays and Sundays. In March, 3/5 of those weekends was spent traveling in a way that prevented me from doing any of these things. I need to plan some time during the week for these activities. My new mantra is “Pay Yourself First.” I spent too much of the time I did have trying to figure out a bug in bleeding edge tech when I should have just used a stable framework from the beginning. The final form of the game is not really a game. It really needs better writing.

Corrective Measures

Start every day with at least 30 minutes to an hour devoted to writing, coding on the game of the quarter, or reading. Probably do these in a rotation. Pick a stable technology for game number 2. I may hire somebody to write a story I can drop into the framework for Game 1 to make it more interesting.

Lots of Failure, But Still Progress

A Few Steps Further

One of the ways that I learn new technologies or programming languages is by getting an idea for a simple app that I want to write and then finding a tutorial on that makes a simple app and sort of following along with it but modifying it to be the app that I want to make. In the process, if there is something extra I want to add that is not in the tutorial I am following I will look up how to do that specific thing.

A few days ago, I wrote about the dangers of using experimental technology for things you plan on releasing to the wild. After I figured out a less than ideal workaround for my problem, I went a little further along in the Meteor/Angular2 tutorial and discovered that the solution to my problem was there.

The Solution (I Think)

On step 11 of the tutorial, they have you build the app to mobile. Android or iPhone, it doesn’t really matter. And this is where I was running into a blank white screen. Several of the next few steps did not apply to the app design, so I skipped ahead. On step 21, the tutorial has you split the logins for the browser version of the app and the mobile version of the app into separate packages.

A little bit of persistence paid off and now I have a way to get what I want working in my app. Remember when you run into an issue you can’t figure out, don’t just give up. Look around for the answer, try to figure it out. Don’t stop just a few steps from your goal.

Sprint at the Finish Line

My goal was to have this game built and released to the Google Play store by the last day of March which is tomorrow. Looks like this is going to join the ranks of most programming projects and go over time. After I release it I will do a post mortem and go over what I learned from the release process.

Don’t stop too soon.

The Bleeding Edge Hurts a Bit

So today’s post was going to be about how I built a MeteorJS/Angular 2 app to Android and released it on the play store. Instead I write a reminder/warning to all who like to develop in experimental technologies.

What Happened to My App?

The day started brightly. I was working away, being more productive than I had in a while. Getting things done. Cleaned up some code, got some things working that had not been and decided to try building my app for an Android device.

I plugged in an old android phone to my computer and ran:

meteor add-platform android
meteor run android-device

No errors showed up in the compile but the only thing showing on the phone was a blank white screen.

Investigating

Googling the issue brought me to this post. I am not the first to run into this issue. After reading through the thread, it seemed as if the issue might be fixed in a newer version of some of the packages that I was using.

So I ran meteor update and saw that indeed there were new versions of some of the core Angular 2 packages that I was using. Some of them I could only update by removing them first and then reinstalling them by the specific version.

Alas, this did not fix my problem.

In the course of research, I found another issue posting that is only 19 days old and is still open (as of this writing).

There are a few more experimental things to try but if they don’t work, looks like a few more days of work rewriting this to something more stable and tested.

Moral of the Story

If you are planning on releasing something to the wild, you should probably not use a technology that is in beta unless you are the one developing it and can fix your own issues.

Since the main purpose of this particular game was to learn a bit about releasing an app to the Android/Google Play Store, I will probably rewrite it into either basic javascript using Meteor or figure out how to write it into Angular 1 with Meteor.

Make games, have fun, and try not to cut yourself on the bleeding edge.

Update

I finally got the game to build to Android properly (around 1:00 A.M. after undoing all the other experiments I had tried then removing the login packages that were being used. Technically it can be played without logging in currently, but there is some additional functionality that tracks some statistics and scoring based on the user meaning I still need to figure out how to handle users. But it builds. Huzzah!

What I Learned From Making Breakfast

My wife likes eggs over easy. When we first got married, all I knew how to do was make scrambled eggs. But I like breakfast and like doing things for my wife so I determined to learn how to make eggs over easy the way she liked.

In case you don’t know what I mean by eggs over easy, it is an egg where the yolk is not cooked but pretty much all the white of the egg is and the yolk is sort of enclosed in a pocket. If you only cook it on one side it is called sunny side up.

The hardest part about cooking eggs over easy is making sure you don’t break the yolk when you flip it over.

Cooking Eggs Is Harder Than It Looks

Many of my first attempts at making eggs over easy were complete failures. I broke yokes left and right. Sometimes the yokes broke as I cracked the egg into the skillet. Other times they broke as I was putting the eggs onto the plate to serve. Not only did I break yokes, but often I undercooked one of the sides because you can’t see it. Eventually I started getting better though.

When I first started, maybe 1 in 3 or 4 eggs would turn out right. But soon I noticed that I was only breaking 1 out of every 2 yokes, then 2 out of 3 and at least 1 of them was cooked thoroughly, now I can get about 9 out of 10 cooked all the way without breaking the yokes. This took a lot of broken eggs though.

Failure Is the Way to Success

Cooking eggs is just an example. Most things in life worth learning how to do will require you to fail multiple times before you become good at them.

Making games is no exception. The common wisdom that I have heard in several places is you will probably make at least 10 bad games before you make a good one. That does not mean you intentionally make bad games. What it means is you make those games as best you can but don’t worry about them being good or popular. They probably won’t be.

Fear of Failure

This is what stops most people. They are afraid to fail so they don’t even try. If you won’t try then you can’t ever succeed.

I struggle with this myself. Many times I write these posts to myself because I need the reminder to just do the thing and not worry about success. Success for you when you are learning is to get something done, not to have it be perfect.

So get out there, break some eggs, and fail just as hard as you can so you can succeed.

Build an Audience by Playing Games

One of the ultimate goals of a game designer is to have people actually play your game. What better people to offer your game to than people who already love games.

Twitch

Several months ago, I was looking for some entertainment and went to Twitch. For those of you not familiar with Twitch, it is a service that allows gamers to stream themselves playing and build up a following of people who can subscribe and give them money to watch them play.

I happened across a streamer named Cohh playing Fallout 4 which had just been released. I found him to be really entertaining and building a great community so I started watching his channel sometimes while I was working.

Come to find out, he is a game designer and has a game studio that was making his game for him. And he is streaming on Twitch full time to build an audience and a community that enjoys games like the one he is making.

This January he ran a kickstarter campaign for his game and got it completely funded fairly quickly.

It was genius.

So for those of you who like to play video games in addition to designing them and making them, which I am going to assume is all of you. Consider using your time to play as dual purpose and possibly stream on Twitch or make Youtube videos. Both would probably be good. This way you build an audience who already likes you and are willing to try things that you make and possibly even be your beta/alpha testers.

And remember, start as simple as possible. You don’t need a $300 podcast mic or super fancy equipment to get started. Use what you have on hand.

Beginner Blog Growth Tactics

One of the goals I set for myself this year has been to get a reliable readership of this blog. So far this year, I have not really paid much attention to this goal. Not because it isn’t important, but because it is an uncomfortable area for me. And it isn’t marketing that really makes me uncomfortable, it is having people read what I write. Having others pass judgment on your work is a little scary. Ultimately though, I am here to give and to provide value. The only way to do that is to have people read what I write and to get feedback on what they find is valuable.

Some Blog Marketing Basics

For Christmas, my wife bought me several books that I had been wanting to read. Among them was Soft Skills: The software developer’s life manual by John Sonmez. John runs Simple Programmer and does a fantastic job of giving advice to developers.

In his book, he has a few chapters on blogging and how to build a successful blog. (He also has a blogging course that I mentioned at the end of this post about putting your work online.

John has built a successful brand and even has a premium course on how to market yourself. And one thing I have learned already this year, if you want to be successful at something, study others who are successful.

Consistency Is the Key

Of all the things that are listed in the book, consistency is by far stressed the most. If you want consistent readership, you have to write consistently. Sometimes you won’t feel like it and it won’t feel like your best work, but it is super important to have a schedule and stick to it. This is one of the areas I did poorly in last year and have been able to do okay in this year.

Often beginning bloggers don’t post because they don’t know what to write about. Here are a few tips from the book and some of my own.

  • Have a conversation, debate, or argument with a friend or coworker about a particular technology or idea that you want to write about and turn that into a post. This a great way to find something to write about. And if your friend and you have fairly strong differing opinions on the topic, it is likely the post will be slightly controversial and get people to comment and respond.
  • Write a response to a blog post you have read and agree or disagree with. While this should probably not be the majority of your posts, it will help fill out those days where you just draw a blank.
  • Do interesting things. One of the most difficult times I have writing is when I have not been doing interesting things. I haven’t been working on games, and I haven’t been learning about games and game design. When you do interesting things, you can write about you own experience doing it. That is one of the purposes for this blog, to share the experience of learning to design, create and market video games.
  • Keep a list of blog topics. Do a brainstorming session and write down ideas of topics you can research and write about. Whenever you don’t have any ideas for a blog post, go to this list and pick a topic.

High Quality = High Sharing

After you get the consistency down, you want to increase the quality of your posts. Whenever someone reads a high quality post with valuable information, they are more likely to want to read other things you have wrote and come back for more. Also they are likely to tell a friend and share it with others.

In addition to repeat visitors and their friends, another important side effect of quality content is backlinks. Many search engines use links to your site from other authoritative sites as a measure of quality and authority. This will give you a higher rank when people search for that topic. Also you will get a percentage of the readers from the site linking to your post.

Add Value on Other Blogs

Search engine traffic and other people posting links to your blog are not very likely when you start out. So what do you do about it? You comment on other people’s blogs.

Now don’t just leave a useless little drive by comment with a link to your blog. Actually try to provide value. This will net you goodwill with other bloggers and help you make connections. In his book, John suggests leaving a few comments a day on different blogs.

Share With Your Network

Use the power of social media to share your blog posts. Twitter, Facebook, LinkedIn, and everything else. It probably won’t get much traffic, but it is a place to start.

If You Are Brave

Sites like Hacker News and Reddit can get you a lot of readers, at least temporarily. And if the content is good or controversial, some will stick around. A few of the blogs I read are ones I found on Hacker News. The section title is because there are some trolls and hateful people who will leave angry comments or at least try to say something harmful. Thick skin is needed for this and a good amount of confidence in what you are writing.

Create Value

If you create value where you are and leave some behind where you go, you will have no trouble developing a readership for your blog. This is just another example of the universal law of “give and it will be given to you.”

This week, go find somewhere on the Internet to add value so that value will come back to you.

Story Design Mistake

My first design for the story of my current game was a colossal failure. I made a huge mistake that I did not quite see at first.

For every decision the player made, the story went in a different direction. Each choice starting towards a different ending. Part of this giant tree of story was cut off by choices that ended in the player dying, but it quickly got out of control.

I realized that I needed to pick a few endings and have the story converge to them. This proved to be better but the story tree was still large.

Then I read the next chapter of The Art of Game Design. It had a name for what I was doing and did the math for me. If the story is only 10 choices long and each choice leads further towards a unique ending, I would need to write over 80,000 endings! The book refers to this as the “Combinatorial Explosion” problem.

Game Story Patterns

There are a couple patterns described that are used in most games to avoid a lot of the issues that arise from trying to be too free with interactive storytelling.

The String of Pearls

In this scenario, the story is fairly linear but has a series of points in which the player must achieve a goal. There is basically one ending but on the journey the player has some freedom along the way for how to achieve the goal. Once they accomplish the goal for the area they are in, they are advanced to the next area.

The Story Machine

This type of design is based around giving the player an experience that they want to tell someone else about. Free build type games like Minecraft and Rollercoaster Tycoon, competitive games like football and CS:GO allow the player to create an interesting series of events that they want to tell someone else about. The goal is a system that creates interesting stories when your player interacts with it.

Following Examples

A couple years ago I had come across an interesting little text adventure game on Android called Wizard’s Choice which was largely the inspiration for the design of my current game. So I went and found it and played it again and guess what I found. It followed the “String of Pearls” design pattern.

The story has 1 ending. It has basically 3 areas from beginning to end where you have some freedom to make choices that affect how you get through the area alive.

I am going to borrow this design pattern and redesign my current pile of spaghetti of a story.