Make your very own game using Visual C++ Express Edition (or in any PL)

I’m sure you all have heard of “Guess the number” game. Well who hasn’t. It’s practically in every programming book of every programming languages by every programming authors. The reason perhaphs is you can actually make billions of games from it. All you need to do is make up some weird stories with number guessing involved in there then you are good to go. Here are some examples:

1. Mind Reader Game

Here's the code:

#pragma endregion
  //declare two variables. intrandom will handle the generated random numbers
  //intcounter will handle the number of incorrect guesses
   int intrandom;
   int intcounter;
 private: System::Void guessbutton_Click(System::Object^  sender, System::EventArgs^  e) {
  //create a random object named randgen based on the Random class
     Random^ randgen=gcnew Random();
     //generate a random number from 1 to 31 and store the generated number into a variable named intrandom
     intrandom=randgen->Next(1,31);
     //if the date inputted by the user is lesser than the generated number
     if (int::Parse(this->datetextBox->Text)statuslabel->Text="Sorry. Your guess is wrong. Perhaps you need some crystal ball?";
   //if its lesser than the generated number obviously the user has guessed it wrong so we acummulate the value
   //of the intcounter variable.
     intcounter=intcounter + 1;
     }
   //if its greate than the generated number
     else if (int::Parse(this->datetextBox->Text)>intrandom)
     {
      //display this message
      this->statuslabel->Text="It's not what the audienced had picked.Perhaps you need some chant or something.";
   //if its greater  than the generated number obviously the user has guessed it wrong again so we acummulate the value
   //of the intcounter variable.
      intcounter=intcounter + 1;
     }
     else
     {
    //if the user has guessed it right. display the follwing message and disable the textbox.
      this->statuslabel->Text="You guessed it right. Congratulations! You are now a fullfledge magician.";
      this->datetextBox->Enabled=false;
     }
    //if the user has guessed it wrong thrice 
     if ( intcounter>2)
     {
    //dsiplay this then disbale the textbox.
      this->statuslabel->Text="You have failed the test. Your remaining magic powers will be taken from you.";
      this->datetextBox->Enabled=false;
     }

    }
};
}





2. Oil Magnate Game

Here's the code:

#pragma endregion
//I wont add comments on this one coz it’s practically the same code. we only //added random responses from the user if the answer is the answer is wrong
   int intrandom;
   int intcounter;
 private: System::Void guessbutton_Click(System::Object^  sender, System::EventArgs^  e) {
 
     Random^ randgen=gcnew Random();
   
     intrandom=randgen->Next(20,50);
   
     if (int::Parse(this->agetextBox->Text)Next(1,2);

     if (intrandom==1)
     {
     this->statuslabel->Text="Im flattered but I'm not that young.";
     }
     else
     {
     this->statuslabel->Text="I have a feeling  that you are just making fun of me.";
     }

        intcounter=intcounter + 1;
     }
  
     else if (int::Parse(this->agetextBox->Text)>intrandom)
     {
 
     intrandom=randgen->Next(1,2);

     if (intrandom==1)
     {
     this->statuslabel->Text="That's rude, I'm not that old.";
     }
     else
     {
     this->statuslabel->Text="Are you stupid or something?";
     }
 
      intcounter=intcounter + 1;
     }
     else
     {
   
      this->statuslabel->Text="Congratulations! You have won the 3 billion dollars.";
      this->agetextBox->Enabled=false;
     }
 
     if ( intcounter>2)
     {
 
      this->statuslabel->Text="You have used the maximum number of guesses and won nothing.";
      this->agetextBox->Enabled=false;
     }

    }
};
}

So there...enjoy game programming :)

Say "Hello" to Blender and Flash

I have not written any programming guide in a while now coz I’m sort of in a “hiatus” or something. But I’ll post some as soon as my dopamine level rises up.

Meanwhile, if you are interested in things that move i.e. computer graphics, some of the great computer graphic softwares out there are Blender 3D and Adobe Flash.

Here are some of the basic animations that you can do with flash. These are made by my former students, I captured them using KRUTS and edited using PD11. Enjoy!



Here are some of the basic blender animations that you can do with blender. These are made by my former apprentices, you’ll see their names at the end of the movie. Anyways, enjoy!

Mousey the Junkbot

Mousey the Junkbot is a photovore(light-seeking robot) originally developed by Gareth Branwyn. It uses an old analog mouse, motors, light sensors. etc. It's not quite complicated to make and the steps in building it are readily available in the Internet. So if you have an idle time and you want to feel a sense of fulfillment or something, go ahead and build one.

Here’s a mobile video of a robot mouse made by one of my very appreciated minions.Lol. Enjoy!

How To Install WordPress On A Web Server Without MySQL Or CPANEL

Today we’ll be learning how to install WordPress on a web server without a CPANEL or MySQL database, just pure FTP. I’m sharing this because I run into similar problem before. The ftp server on the site that I’ve developed is not synchronized with my web server’s CPANEL thereby making it impossible to connect the database that I made there. It almost drive me crazy or something. I’ve searched the net for answers, but I haven’t found any clear solutions there and so I decided to do something about it. That’s like life actually, either you accept things as it is or you do something about it. Just kiddin.
The solution is surprisingly simple, upload WordPress on your ftp server, and since you don’t have a CPANEL, you can create a MySQL database using a free data provider outside of your web server such as freemysql.net or freesql.org . The details are listed in the following steps:
1. Download the latest version of WordPress from http://wordpress.org/.
2. Extract the downloaded files.
3. Start Filezilla(If you don’t have Filezilla installed, you can download it from http://sourceforge.net/projects/filezilla/files/FileZilla_Client/3.5.3/FileZilla_3.5.3_win32-setup.exe)>Enter your FTP server host, username and password then click quick connect.

4. Upload the contents of the wordpress folder to the public_html folder.
5. Open your web browser. Enter the URL of your site on the address bar.
6. Click Create Configuration File>Let’s Go button. The following should then appear.
7. Since we do not have CPanel and we can’t obviously create a MySQL database file which is needed in this window>Press CTRL + N. This will open up a new browser window. Enter freemysql.net in the address bar. The following should then appear:

Freemysql.net is a great site that offers free MySQL database storage for FREE.

8. Click the client area> then register.
9.After you have registered. Login to your account and create a MySQL database file. Remember the name of the database file that you have made because that will be used as your wordpress database name.
10. If you look on the bottom of your freemysql.net account, you will see your host or server name:
11. Now switch the browser screen to your WordPress configuration file then enter your freemysql.net database credentials>Click Submit.
12. Click the Run the Install button> And follow the on screen installation process to install wordpress.

Note: For more information, visit the wordpress official installation guide here http://codex.wordpress.org/Installing_WordPress. That’s all.

Fixing the “Previous release of Microsoft Visual Studio 2008” failed error when installing SQL Server R2

This error normally shows up if you try to install SQL Server R2 on a Windows machine. Unfornately, if you install Microsoft Visual Studio 2008 as the error implied, it still won’t work and it’s somewhat enough to make someone crazy or something.




This error could actually be fixed without installing Microsoft Visual Studio 2008. Follow these simple steps and I promise you, you will be able to install SQL Server R2 without fail. Trust me, I’ve tried it on ten (10) computers and it worked each and every time.

1. Download the necessary files in installing SQL Server 2008 R2. I won’t be covering how to install SQL Server R2 here, because there are several sites on the net that already teaches people how to do that. Just do a Google search and find a site that teaches how to install SQL Server 2008 R2 step by step.

2. Before you install SQL Server 2008 R2, uninstall any express edition applications such as Visual Basic Express Edition, Visual C# Express Edition and Visual Web Developer from your computer. Could be done by clicking Start>Control Panel>Add / Remove Programs> Select your Express edition file>Change/Remove >Uninstall>next>Finish.



3. Clear the TEMP folder. Could be done by clicking the Start button>Run>Enter “%temp%” no quotes> then delete all the contents of the TEMP folder.



4. Clear the contents of the PREFETCH folder. Could be done by clicking Start>Run>Enter “Prefetch” no quotes>Ok.



5. After clearing the contents of the prefetch folder, restart your computer the Install SQL Server 2008 R2. That’s all!

Note: This isn’t really the official way of doing this. But it worked for me and I thought it’s worth a share. Just tryin to help :)

Animating 3d models in DarkGDK using dbAppendObject

Been watching 3d Animation tutorials lately but I’ve never really found a tutorial or detailed example for that matter that actually teaches how to animate 3d models in DarkGDK in a less unclear way. And so I’m sharing this example in hope that it will be used by some computer enthusiast out there like myself as a starting point in creating their very own 3d computer game.

I have used the Babe model in this example. Babe model is a Dark Matter Model that is accesible by default when you install DarkGDK and is located at C:\Program Files\The Game Creators\Dark GDK\Media\Dark Matter Models\People. The controls and actions of our model in this example are illustrated in the following table.

ControlsActions
W,A,S,DMove.x
TabDie.x
QImpact.x
No key PressedIdle.x


Enough said, here’s the code:


// Dark GDK - The Game Creators - www.thegamecreators.com
// the wizard has created a very simple project that uses Dark GDK
// it contains the basic code for a GDK application
// whenever using Dark GDK you must ensure you include the header file
#include "DarkGDK.h"
// the main entry point for the application is this function
void DarkGDK ( void )
{
// turn on sync rate and set maximum rate to 30 fps
 dbSyncOn();
 dbSyncRate(30);

 //loads our 3d model
 //we'll be borrowing the Babe DirectX Darkmatter model
 //it's included in the DarkGdk package located in
 //C:\Program Files\The Game Creators\Dark GDK\Media\Dark Matter Models\People\Babe
 //Just copy the contents of the Babe folder to your game project folder
 dbLoadObject("H-Babe-Idle.x",2);
 //Idle.x has 25 frames
 //to find how how many frames there is in a .x animation
 //Click Start>All Programs>The Game Creators>DarkGDK>Documentation>Information>Type "Frame" 
 //in the Textbox and the command used to determine the number of frames will reveal itself to you.
 //appends the number of frames of the Move.x animation to the loaded model
 //Move.x has 25 frames
 dbAppendObject("H-Babe-Move.x",2,26);
 //Attack.x has 24 frames
 //adds the number of frames of Attack.x to the loaded model
 dbAppendObject("H-Babe-Attack1.x",2,51);
 //Die.x has 50 frames
 //adds the number of frames of Die.x to the loaded model
 dbAppendObject("H-Babe-Die.x",2,76);
 //Impact.x has 10 frames
 //adds the number of frames of Impact.x to the loaded model
 dbAppendObject("H-Babe-Impact.x",2,126);
 //positions the object in the -y axis cause its a little bit top aligned by default when loaded
 dbPositionObject(2,0,-1,0);


 while (LoopGDK())
 {
 //display descriptive text
 dbSetTextSize(14);
 dbText(10,0,"WASD-Movement");
 dbText(10,10,"Spacebar-Attack.x");
 dbText(10,20,"Tab-Die.x");
 dbText(10,30,"Q-Impact.x");
 dbText(10,40,"No key pressed-Idle.x");
  

 
   //if the W or A or S or D or Spacebar or Tab or Q is pressed
   if ( dbKeyState(17) || dbKeyState(31) ||dbKeyState(32) || dbKeyState(30)||dbKeyState(57) || dbKeyState(15)|| dbKeyState(16))
   {
   //stop the presently looping animation
  dbStopObject(2);
   //retrieves the object present angle
   int ObjAngleY=dbObjectAngleY(2);
   //determines if the object is presently looping
   int looping=dbObjectLooping(2);
      //if the key pressed is W
   if(dbKeyState(17)) 
   { 
   //move the object on the -Z axis
     dbMoveObject(2,-0.05f);
   //is the object presently not playing?
   if (looping==0 )
   {
   //if yes then execute move.x
      //move Move.x has 25 frames
   //the number of frames from the starting frame to the ending frame must be at least 25 frames

    dbLoopObject ( 2,26, 51 );
   };
   }
   //if the key pressed is S
   if (dbKeyState(31))
   {
   //move the object on the Z axis
    dbMoveObject(2,0.05f);
   //is the object currently not playing?
   if (looping==0 )
   {
      //if yes then execute move.x
      //move directx animation has 25 frames
   //starting frame up to the end frame must be at least 25 frames

    dbLoopObject ( 2,26, 51 );

   };
   }
   //if the A key is pressed

   if (dbKeyState(30))
   {
  //rotate the object along the Y axis
  //for instance, if the objects current angle is 275-5
  //The object will then be rotated 270 degrees which is exactly south
  //from the user's POV
  //the dbWrapValue is to ensure that the object rotation will not exceed 360 degrees

    dbYRotateObject(2,dbWrapValue(ObjAngleY-5.0f));
   }

  //if the D key is pressed
   if (dbKeyState(32))
   {
 
     //rotate the object along the Y axis
  //for instance, if the objects current angle is 85+5
  //The object will then be rotated 90 degrees which is exactly north
  //from the user's POV
  //the dbWrapValue is to ensure that the object rotation will not exceed 360 degrees
    dbYRotateObject(2,dbWrapValue(ObjAngleY+5.0f));
   }
     //if the space key is pressed
   if(dbKeyState(57))
   {
  //is the object currently not playing?
   if (looping==0 )
   {
   //if yes then execute Attack.x
   //Attack.x has 24 frames so from the starting to ending frames
   //must be at least 24 frames
    dbLoopObject ( 2,51,77 );


   };
   }
   //if the Tab key is pressed
   if(dbKeyState(15))
   {
   //is the object currently not playing?
   if (looping==0 )
   {
   //if yes then execute Die.x
   //Die.x has 50 frames so from the starting to ending frames
   //must be at least 50 frames
    dbLoopObject ( 2,78,127 );


   };
   }
       //if the Q key is pressed
  
   if(dbKeyState(16))
   {
  //is the object currently not playing?
   if (looping==0 )
   {
  //if yes then execute Impact.x
     //Impact.x has 10 frames so from the starting to ending frames
     //must be at least 10 frames
    dbLoopObject ( 2,127,137 );


   };
   }


   }
  else
  //if no key is pressed
  //execute Idle.x
  //Idle.x has 25 frames so from the starting to the ending frames miust be at least 25 frames
  {
   dbLoopObject(2,1,25);
  }
// update the screen
  dbSync();
 } 
//return to windows
return;
}




Another way of animating models is by using the dbShowObject and dbHideObject commands. I'll post an example of that here when I have time. If you want more information on animating darkGDK models or creating games per se, you can visit DarkGDK's official site www.thegamecreators.com

Terminate an Executable Application in Visual Foxpro 9.0 at Run-time by Force

To terminate an executable application in Visual FoxPro 9.0 at run-time, use the RUN and Taskkill command. RUN is a Visual FoxPro command that allows you to execute DOS commands, Taskkill, on the other hand, is DOS command that allows you to terminate an exe applications and processes , similar to using the task manager. For details on using the taskkill command, follow these steps:

1. Click Start>Run>Type CMD> then press enter.

2. In the command prompt, type TASKKILL/?.

Using Run and Taskkill to terminate an executable application at run-time is essential especially if you have hidden the Visual FoxPro 9 IDE using the _SCREEN.VISIBLE command and your form just freezes when you click the Exit button, even though you have attached a THISFORM.RELEASE or whatever code to it. To see RUN and TASKKILL in action, follow these steps:


1. Click Start>All Programs>Microsoft Visual FoxPro 9.0.

2. Close the Task Pane Manager window.


3. Let’s make a form by typing CREA FORM in the command window and pressing enter.

Note: If the command window is hidden, just press CTRL + F2 to show it.

4. Add two buttons to your form, Refer to the following screenshot for control names and values:




5. Double-click the Terminate Ms-Word button, enter the following codes:

private anyvariable
anyvariable=MESSAGEBOX(“Are you sure you want to terminate Ms-Word?”,4+32)
if anyvariable=6
RUN "Taskkill /f /im winword.exe”
ENDIF


Your code window should now look like this:



6. Double-click the Terminate Visual FoxPro button, enter the following codes:
private anyvariable
anyvariable=MESSAGEBOX(“Are you sure you want to terminate Ms-Word?”,4+32)
if anyvariable=6
RUN "Taskkill /f /im VFP9.exe”
ENDIF
Your code window should now look like this:


7. Press CTRL + F3 to test your application.

8. Before Clicking the Terminate Ms-Word button, ensure that Ms-word is activated.

9. Try clicking the Terminate Visual FoxPro button and see what happens. And that’s all :)

Retrieve values from another form in Visual FoxPro 9.0

One of the ways to retrieve values from another form in Visual Foxpro is to use a Form Set. A Form Set (from the name itself) is a set or collection of forms. To create a Form Set, follow these steps:

1. Click Start>All Programs>Visual FoxPro 9.0.
2. Close the Task Pane Manager Window.
3. To create a form, type CREA FORM in the command window, and then press enter.



Note: If the Command Window is not shown, Press CTRL + F2.
4. A new form will now come into view.



5. To create a form set, click Form>Create Form Set.




Although nothing appear to happen when you click the Create Form Set Submenu but essentially a new submenu will be enabled, the Add New Form submenu.

6. To add a form to your Form Set, Click Form>Add New Form.



A new form named form2 will now be added to your Form Set. If you add another form, that form will be named form3 and so on. Repeat the step no. 6 to add one more form to your form set. Our form set will now have 3 forms named form1, form2, and form3.




7. For the sake of example, let’s make an application that will allow us to enter our first name in the first form, last name in the second form, and display our first name and last name in the last form. We also want to display just the main form when our application is first executed and hide the unneeded forms.

8. If we click the Run icon or press control + E now. you’ll noticed that all forms are displayed at once.




8. Click all the close button of all the opened form to go back to the design view. To hide Form2 and Form3 when the application is first executed, double Click Form1, in the Init procedure, enter the following:
*hides the second form
Thisformset.Form2.Hide ()
*hides the third form
Thisformset.Form3.Hide ()


The code window will now look like this:




9. While still in the code window of Form1, Select the Unload event.

Enter the following code:

*Closes all the forms in the formset
 RELEASE Thisformset


The code window will now look like this:



10. Click the close button of the code window to save all codes that we have entered so far in form1.

11. Add a Label, a textbox and a button to form1, refer to the following screenshot for control property values:




12. What we aim to do here is if click the next button, form1 will be hidden and form2 will appear. To be able to do that, double click the Next button in form1 and enter the following codes:

*Hides form1
Thisformset.Form1.Hide()
*Show form2
Thisformset.Form2.Show()

The code window will now look like this:



Click the close button of the code window to save the codes that we have entered in Command1.

13. Add a Label, a textbox and two buttons to form2, refer to the following screenshot for control property values:



14. What we intend to do here is if we click the Prev Button, Form2 will be hidden and Form1 will be shown. If we click the Next Form3 will be shown and Form2 will be hidden.

15. Double click the Prev button then enter the following codes:
*Shows form1
Thisformset.form1.Show()
*Hides form2
Thisformset.form2.Hide()

Your code window will now look like this:




Click the close of the code window to save your codes

16. Double click the next button in form2 then enter the following codes:
*Hides form2
Thisformset.form2.Hide()
*Shows form3
Thisformset.form3.Show()

Your code window will now look like this:



Click the close of the code window to save your codes

17. Add four labels to form3. Refer to the following screenshot for control property values:



18. What we intend to do here is if Form3 is loaded, all the values from the previous will be displayed on their respective controls. Double-click form3. Select the Activate procedure then enter the following codes:
*retrieves the value of the textbox in form1 and
*display it in the our label in form3
Thisformset.Form3.Label2.Caption=Thisformset.Form1.text1.value
*retrieves the value of the textbox in form2 and
*display it in our label in form3
Thisformset.Form3.Label4.Caption=Thisformset.Form2.text1.value

Your code window will now look like this:



19. Click the close button of the code window to save your codes. Let’s take a look to all our forms once more time.



20. Click the run icon or press Ctrl + E to test your Form Set.

21. Try entering your first name on form1>Next. Your Last name on Form2>Next. Your first name and last name should now appear on form3.

Symet BEAM Robot

Time for some break in programming and delve into the exciting world of robotics. Symet, FYI , is an intelligent agent that can sense it’s environment through the solar cell and perform an action (e.i. tweaks or rotates) the moment it senses heat. A perfect example of a simple AI robot. Here is a mobile video taken by Christine (one of my apprentice LOL) showing Symet at work. This was edited using PowerDirector( A rich-featured video editing software by Cyberlink) which is available for download at www.cyberlink.com. The title and PIP Templates were downloaded from directorzone.cyberlink.com. The Kinetic Typography was made using Microsoft PowerPoint.