I played around with the Chapter 4 version of Tank War tonight.  Here are some of the changes I made:

  • I changed the explosions from rectangular to circular.
  • I changed the bullets to circular instead of rectangular.
  • I added rests after left/right turns (kind of like “debouncing”), so that you could actually control your turns better.
  • And I changed the screen size.

Yeah, it might not be all that impressive, but playing around with the different functions helped me understand how the programming worked.

Aaron :)

Wow I am looking forward to trying this out!!!


Here is an example command line game.
Rock, Paper, Scissors using Enum and Random Numbers.
Both were asked about in the last class.

#include <stdlib.h>
#include <stdio.h>
#include <time.h>

//Global Enum can be seen in both main and win function.
enum Signal{Rock,Paper,Scissors};

int win(int a,int b);

int main(void)
   int i;
   int your,mine, yourscore=0,myscore=0;
   char *Words[]={"Rock","Paper","Scissors"};

   // Seed the random number generator with time value.
   printf(" To play enter the number 1 - 3 and 4 to quit.\n");
   printf("Rock 1, Paper 2, Scissors 3   Quit 4\n\n");
   //Ascii value of 1 is 49 so we get a number from zero to 2.
   // the array elements are 0 though 2 but the enums are 1 though 3.
   {  //generate random move 0 though 2.
      mine=(rand() % 3 );

      printf("Your %s\n",(your<3 && your>-1) ? Words[your]: "Fumble");
      printf("My move %s\n",(mine<3 && mine>-1) ? Words[mine]:"Fumble");
      printf("Your score is %d and my score is %d.\n\n",yourscore,myscore);
   return 0;
int win(int a,int b)
{  if (a==Rock && b==Scissors)
   {	printf("Rock wins\n");
	return 1;
   if (a==Paper && b==Rock)
   {    printf("Paper wins\n");
	return 1;
   if (a==Scissors && b==Paper)
   {    printf("Scissor wins\n");
	return 1;
   return 0;

“ENUM allows you to define a list of alliases which represent integer numbers.”  In the examples from the PDF, all of the alliases represent integers which increment by one.  Suppose I want to assign specific integer values to each allias, such as:

enum OddNumbers {one=1, three=3, five=5, seven=7, nine=9};


enum fibonacci {zero=0, one=1, two=2, three=3, five=5, eight=8, thirteen=13};

(Note: I did not repeat the second “one” because it would be redundant to redefine it.)

Can this be done?  …I’m assuming that it can be done since a similar thing was done in the example of the escape characters.


Aaron :)

I have a question about pointers and typedef structures…

Take the example from Neil’s PDF:

typedef struct {int age; char *name} person;

 person George, *aMan;

I can access George’s age either by George.age or by aMan->age.

 But suppose I want to create multiple persons, George and Henry.  To whose age, then, will aMan->age point?


Aaron :)

Is there a limit to how many characters you can use for a variable or type definition?  …I realize that it’s probably kosher to use concise yet descriptive labels for variables and type definitions, but is there a limit?


Aaron :)

I wrote my own program exploring variable types, and it worked just fine.

Then I opened the Type_D2.c program and tried to run it first to see how the output should look before writing my own program for type definitions.  When I compiled, ran, and viewed the output screen, all I saw was the output from my variable program.  Hmmm…  Why?  Did I run out of room on the output screen?  Do I need to clear the screen before running the other program?  What am I doing wrong?

Any suggestions?


Aaron :)

This site is set to resist being seen by Search Engines.  This is so it can remain mostly private by invitation only.  However it is publicly accessible so only write in what you are comfortable seeing published publically.

Thanks Neil C.

Hello, everyone! :)
It was a pleasure meeting all of you this evening!  I thought it might be a good idea for us all to get to know each other a little and have each other’s contact information, so that we can use each other as a learning resource if we get “stuck” between classes.  That said, let me start by introducing myself.  My name is Aaron Ward.  I’m a 33 y/o electrical engineer from Hurricane, West Virginia.  I’m a United States Army veteran with 8 years of service.  I’m married and have a 7 y/o son named Ethan.  We attend Fairlawn Baptist Church in Dunbar – not far from WVSU, where I am a Sunday School teacher.  The two young men who were with me tonight, Alex and Jared Belmore, are in my Sunday School class.  I have known Neil for about 6 years now.  When I was in college at WVU Tech, I was interested in learning about robots, so I googled “robotics in Charleston, West Virginia”.  The only search engine result was the webpage of a computer scientist named Neil Chakrabarty.  I contacted Neil, and we met up at the Kanawha Mall (back in 2005) where he briefly introduced me to some ideas and resources for robotics.  Three years went by before I contacted Neil again and asked if he would like to start a robotics club with me in Charleston.  We did, and it lasted for a couple of years with about 4 or 5 faithful members.  Neil and I are good friends and get together to “geek out” every once in a while.  He is an extremely intelligent man with a wealth of computer programming knowledge – and one of the nicest guys I know! :)
My particular interest in this class does not lie in writing video games.  (By the way, I started out as a Computer Science major back in 1996, and I took two semesters of C++ Programming.)  As a hobby, I design electronic circuitry and robots.  Check out my YouTube page with about 17 videos!  I want to be able to write computer programs with GUI (Graphical User Interface) so that I can connect my electronics / robotics to my computer for control and feedback.  For example, I would like to be able to click on a graphical representation of my robot on the computer screen which will make the robot respond accordingly.  This is called HMI (Human-Machine Interface).
  • I highly recommend that everyone introduce themselves to the rest of the group and use each other as a resource when you have questions.  Don’t be shy! :)
  • Print out all of the PDFs and code that Neil publishes in his online Topic folders, hole punch them, and keep it all together in a 3-ring binder.  And READ them!!!
  • Play around with the code that Neil provides in his weekly online Topic folders.  Change the values and see what happens!  Tinkering is one of the best ways to learn!
  • Don’t get discouraged if you feel overwhelmed after this first class! :) Believe me; he hit us with the hardest stuff first!  Take comfort in knowing that everyone else is just as confused as you are! ;)
  • Feel free to contact me any time if you need help!  I receive my e-mails immediately on my Blackberry, and I’ll respond as quickly as I can (if I’m not at work).  I’m no expert, but I have some programming experience.
By the way, for those of you who are completely new to the concepts of computer programming, I realize that a lot of this stuff is Greek to you.  I could probably show up at 6:00 PM or 6:30 PM on Wednesdays if any of you need help understanding the basics.  For example, it might be useful for you to know the basic anatomy of a program: INCLUDE statements >> variable declarations / initializations >> function declarations >> MAIN program >> function definitions – and so on.  Maybe you need help understanding “pointers” or “addressing” or “passing values” or “returning values” or whatever.  A few of us (Eric, Tina, and myself) have prior programming experience and might be able to help those of you who don’t.  And of course, I’m sure that Neil would be happy to answer any of your questions too!
I look forward to seeing you all next Wednesday!  …We’re 6.7% of the way to being able to create our own video games in C! ;)
Aaron :)


Be sure to checkout the Class downloads page for the list of 30 Class Topics.

I plan to average two topics per evening for a total of 15 weeks with one week off for Spring Break. (No class on Wed March 23)

The Class will be held in Wallace Hall Room 733, 7pm Wednesdays.

Here is a Link to the book I will be using it is not required but is suggested  be sure to get the 3rd Edition as the other do not apply.

Looking forward to class!
Neil Chakrabarty.

© 2011 C-Class Suffusion theme by Sayontan Sinha