Billiards Game Part 2 – Game Design Document

game design document billiards game

This is the second part to our billiards game tutorial. In this section, we will create a game design document for our game. Since this is an article a form of media that can only be consumed, this article will be set up into three sections:

 

  1. Game Design Document Outline: This is our document outline.
  2. Game Interpretation: This will explain what information goes under each section.
  3. Written Execution:  … or the finished document. Wow, that sounds lethal!


 

Section 1: Game Design Document Outline

I want to be clear that there are many different game design documents. Therefore, we will not follow any of them exactly. Instead, we will create a simple game design document that suits our needs.

Continue reading

Billiards Game Programming Part 1

Billiards Game Programming Part 1

Tutorial Order

This tutorial series will be split up into multiple sections. It is going to take some time to complete, so hang on.

  1.  Go over the billiards game and what decide what will be done (We are here right now)
  2.  Create a game design document
  3.  Set up project and make a display class to prevent magic numbers.
  4.  Get some billiard balls drawn on the screen.
  5.  Let’s start moving them around on a realistic looking table with wall collision.
  6. Add realistic movement, math equations elastic collisions, and friction.
  7. Make the game interactive. Shoot the white ball along with game states
  8. Add pockets to the pool table that actually work along with edge case fixes
  9. Add a ghosting effect and some snazzy slide through animations
  10. Let’s makes some noise!
  11. Make our billiards game 2 player
  12. Add text to the game.
  13. Add some HUD elements to the game.
  14. Add code to allow a player to choose stripes or solids.
  15. Add code to deal with the white ball placement and other glitch fixes.
  16. Now let’s add a pool stick to finish it up
  17. Bonus section: Make unrealistic bouncing to change it up a bit.

Continue reading

How to setup Libgdx for Android Studio

libgdx android studio

Some Background Information

I am in the process of writing a programming tutorial series about billiards. It will use Java as the language, Android Studios as the IDE, and libgdx as the supporting framework.

Also, if you have already setup LibGDX for Android Studio? Head on over to my newest tutorial about custom bitmap fonts. In it, you will learn how to make fonts that can be used in your android apps.

Android Studio welcome screen

Android Studio is the next eclipse, but better. That is why we are going to use it.

What is Android Studio?

Android studio is an IDE for Android developers. First announced earlier 2013, it has since grown to be a very effective tool. Last month, June 2014, Android Studio has went from alpha to beta. If you wish not to use an ‘in progress’ IDE, your other option is Eclipse. But hey, out with the old and in with the new. Source: http://en.wikipedia.org/wiki/Android_Studio

Unlike Eclipse, Android Studio is, in my own opinion:

  • Faster
  • Responsive
  • Visually unified
  • More productive

 

What is libGDX?

I like to call it a convenience. It is like XNA game studios for Android developers. It integrates easily into Android Studio, is cross-platform, and is super-fast. For a full detailed list, visit their feature page http://libgdx.badlogicgames.com/features.html

How to install Android Studio Beta

If you do not have Android Studio installed, you should do some research into it. I suggest going to the android developer homepage. https://developer.android.com/index.html. I will not go into great detail about this. Continue reading

Are you paying for winnings or defeat?

Money spend for winnings or defeat

Gaming at the Theme Park

This summer, I am working at a theme park at the games. My job is to have guests play the games, and generate revenue for the company. As corporate as that sounds, that is the truth and I love my job.

Not every game is the same. Some games require skill. Some games have you race other people. Other games are based purely on luck. The prizes may not be worth the price. Parents play games more than kids. Groups of people play more games than single individuals. Continue reading

My Top 25 Sites to Learn Game Programming

Learn Game Programming books that I have.

Do you want to learn game programming? Yes! Well then I have a surprise for you. Here are 25 sites you never knew would help so much. I for one will never be able to produce the amount of content available on these sites. My goal is not to do so anyway. Hopefully, this list will help someone learn. Please note that these sites have varying degrees of usage. Please read each one’s terms of use, privacy policies, and disclaimers. Thank you.

Learn Game Programming

Okay, this is what we are here for. I give you, my favorite programming resources. I believe that they are invaluable. But before we proceed, I must give you some advice. The only way to become proficient in a language is to practice it every day. Onward we go!

#1. Geeks for Geeks

www.geeksforgeeks.org
I highly recommended that you read this site if you want to be a software engineer. You can find answers to a lot of real-life programming situations. It covers: Algorithms, data structures, arrays, bit manipulation, C/C++, strings, and binary trees.

#2 Amit’s Game Programming Information

www-cs-students.stanford.edu/~amitp/gameprog.html
A wonderful collection of programming algorithms explained in great detail. In addition, each article contains internal and external links to even more great resources. If you want to read up on intermediate to advance topics involving path-finding, AI, game design, and scripting, you will love this site. This is my second favorite site.

#3 Eric Lippert’s Blog

ericlippert.com
Started in 2003, his goal was to write about the many wonders of programming. Each article seems to have its own personal touch. This is a great resource if you have nothing else to do or if you want to learn game programming.

Continue reading

Internet Cookies or Black Magic

Internet Cookies

What are internet cookies? Let me tell a tale about Joe, a normal person, that uses cookies to guide his life:

Once upon a time, there was a man who loved to shop. He bought all kinds of things. He bought fishing and hunting gear, books on black magic, beef jerky, and fancy cars. His name is Joe. Joe works at an office job in the town of West Haven. People in West Haven love to be social with each other.

Before Joe drives his fancy car to work, he puts on a suit and tie. Upon arrival, he pulls into his  Continue reading

The Joy of Sharing

Today I had a great time. It was a good reminder that a well-designed program does mean fun for the user. I had made an Android App that was part of a book. It took months to complete, and the code design was pretty bad (i.e. every single number was hard-coded). It was a beginner app. Good thing the later book projects improve upon this.

Despite all of this, something amazing happened. I brought it to my friends and they had a blast! Not only was everyone interested, everyone was laughing their heads off. What does this mean? Do not be the best. Rather, be better than your competition. I had a great time. What a relief knowing that other people find this small, poorly designed, book project app fun! Oh no! Did he say fun?

Within the game industry, sometimes programmers have these expectations that they need to create something fresh, innovative, and outside-the-box. Not today. Today showed me that a game can be silly. It is okay to make mistakes. One game’s framework does not have to be a god framework that fits every type of game. It has to work, be polished, and get the job done. That is not to say that one should skimp on the quality, even when money is not an issue.

I learned in my college class that money is not a motivator. This silly app will never make enough money to recoup the costs it has taken to make it. But the learning experience did. This was my first app. Passion will take a project much further than money ever will. This is what I call a productive hobby. Though, I use money as a technical objective. Can I make $5 in revenue off this insignificant app? Seems realistic enough as opposed to, I will make a living making apps.

Let’s review:

  1. Quality program design does not always equal a quality user experience
  2. Your friends and fans love what you make, even if you think it is not good enough
  3.  Industry standards and panacea programs are not always the way to go.
  4. Passion, learning, and motivation drive personal success. Not money.
  5. Always keep your head high. If you get sunk down, relax, reflect and talk to someone.

C++ Program to Website: Step by step

C++ Program

C++ Program to Website: Step by step

Hello World! Lets write a C++ program that opens up a link in your favorite web browser. But before we begin, here is what our program will look like:

1. This is what we will be presented with:

Program Startup

A console asking us for a favor.

2. We type in a web URL:

C++ Program

Old school manual URL typing

3. Tada! A web-page is opened:

C++ Program Output

The program opened up the website in my default browser

 

Before we begin writing our C++ program:

I assume that you have a basic understanding of the language and that you have a compiler installed.

1. Create a new Windows 32 Console Application project. Let’s call it “Browser Butler”, because it will open up a webpage for us.

2. Create a new C++ Source file and call it main.cpp

3. Type code as follows…

Like any program, we need to include our header files, standard library, and the main function

#include <iostream>  //Needed for getting user input and displaying text
#include <string>    //Needed for text
#include <Windows.h> //Needed for Windows commands

using namespace std; 

//-------------------------------------------------------------------------------------
//Main Function: Will ask the user to enter a website URL, and will proceed to open it
//-------------------------------------------------------------------------------------
int main (int argc, char *argv[])
{
     //TODO
}

Note: I have read up on the Windows.h header file. I suggest that you not mess with it unless you are sure what you are doing. It basically gives access to the Windows API. What we are using it for is okay.

Inside our main function

Okay, this next part might be hard to understand because it has some odd syntax. But in order to do what we want, we have to create a new thread to handle the new webpage. Thus we need the Component Object Model (COM) Library.

First Argument: Must be NULL
Second Argument: determines whether or not we want single or multi-threading
We use COINIT_APARTMENTTHREADED or single-threading
We use | COINIT_DISABLE_OLE1DDE as a safeguard to prevent possible problems

HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);

Then we check for errors using the HRESULT, a 32-bit integer.

if (SUCCEEDED(hr))
{
        // The function succeeded
        // TODO
}
else
{
        //Abort
}

Lastly, we uninitialize the COM Library and close the program

CoUninitialize();
return 0;

Getting Input from the User

Okay, that was a lot to take in. The last part of our C++ program is the fun part.
We are going to get the website from the user.
Replace the TODO comment with the following code:

//Acts as our website prefix
string shttp = "http://";

//Get the website URL from the user
string siteName = "";
cout << "Enter a website name and I will open it for you: \n" << shttp;
cin >> siteName;

//Glue them together
string address;
address = shttp + siteName;

//TODO

Opening up the webpage

This last part is also kind of tricky. In order to open up the website, we need to call the windows command, ShellExexute(). But before we do that, we need to convert the website address string into a wstring, or wide-string.

wstring wideusername;
for(int i = 0; i < address.length(); ++i)
{
	wideusername += wchar_t( address[i] );
}

ShellExecute(NULL, L"open",  wideusername.c_str() ,NULL, NULL, SW_SHOWNORMAL);

And that is it!

Here is the finished code:

#include <iostream>
#include <string>
#include <Windows.h>

using namespace std;
//-------------------------------------------------------------------------------------
//Main Function: Will ask the user to enter a website URL, and will proceed to open it
//-------------------------------------------------------------------------------------
int main (int argc, char *argv[])
{

	//Initialize the COM Library
	HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);

	//Check to make sure that no errors have occurred
	if (SUCCEEDED(hr))
	{
		// The function succeeded.
		string shttp = "http://";
		cout << "Enter a website name and I will open it for you: \n" << shttp;
		string siteName = "";
		cin >> siteName;
		string address; 

		address = shttp + siteName;

		wstring wideusername;
		for(int i = 0; i < address.length(); ++i)
		{
			wideusername += wchar_t( address[i] );
		}

		ShellExecute(NULL, L"open",  wideusername.c_str() ,NULL, NULL, SW_SHOWNORMAL);

	}
	else
	{
		 //Close the program
	}
	//Uninitialized the COM Library
	CoUninitialize();
    return 0;
}

Congratulations! You made a C++ program that opens up a web site in your favorite browser.

Sources/More information about the following lines of code:

HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
http://msdn.microsoft.com/en-us/library/windows/desktop/ff485844(v=vs.85).aspx
COINIT_APARTMENTTHREADED
http://msdn.microsoft.com/en-us/library/windows/desktop/ms693344(v=vs.85).aspx
(SUCCEEDED(hr))
http://msdn.microsoft.com/en-us/library/windows/desktop/ff485841(v=vs.85).aspx
ShellExecute(NULL, L"open", wideusername.c_str() ,NULL, NULL, SW_SHOWNORMAL);
http://msdn.microsoft.com/en-us/library/windows/desktop/bb762153(v=vs.85).aspx

Changing the Theme

Theme is on a way. Today has been painstaking. Themes are hard to choose, especially when there are hundreds to choose from. In addition to a theme, I am adding some more plugins. So far so good. This post is just a test to see how the newly changed theme feels. I am hoping it works, although it feels bland. Thanks everyone for hanging in their while this site matures.

In addition the theme change, I have been adding some better navigational elements. There is a links section which shows my favorite sites, and a calendar. If you want, you can also check out my gaming Facebook page.

My favorite new discovery those besides the well improved look is that I found out how to use Code;
cout << "Now I can insert code snippets into my posts" << endl;

Establishing Goals: Prioritization

Something seems off about this

Do you think you have more time than you really have?

Establishing Goals: Prioritization

So I have been thinking of what to post on this blog. It is not easy. In my case, I love to code, and read. How can I make time? Even more, how can anyone make time to do such a thing? Well, I, the programming man, will take his shot at answering this question.

  1. How much free time do I have? Any coder knows that he or she needs a lot of time without distraction. My favorite time to code is in the morning, when I have 5+ hours to concentrate. It is one of those things where your brain acts like it has 8GB of RAM. Once distracted, your brain loses that data and you must spend the next half-hour collecting your thoughts before continuing.
  2. What do I feel like doing? Anybody with a lot of free time has to decide how to spend it. During the evening, I might watch TV, or surf the web. It is when there are deadlines that progress happens. So one might suggest to write when there are other tasks to do first. Not me, Instead, I will do this type of activity when I know I have something to do in a certain amount of time. That way I can prepare first and then spend the rest of the time writing before moving on.
  3. Lastly, should I be the best blogger? No, I do not think that is fun. It is an art form, and you cannot rush it. Like anything, time is needed. I could elaborate, but not this time. It is self-explanatory.

In the end, maybe my posts would be most appropriate when I have some free time on my hands, but not so much that I could be using it to program, or educate myself on some other topic. In addition, when there are other jobs to do, my posts will have to wait. In the end, prioritization is key.