Monday, October 19, 2009

Making Cars Go Bump in the Night

Finished another pleasant day at school, with one 3 hour canceled, leaving only one that started at 2:30pm.  It was kind of nice being able chill wth the ladylover and watch some Californication this morning instead.

Once at school, we continued to animate a car moving around the screen.  What I accomplished last week was keeping the car on the stage by cutting the speed to 0 when it hit the ed of the stage.  Now we are adding obstacles, which adds a new level of fun, both programming wise, and playwise.

It's pretty easy to moniter a hit between 2 objects, but each object is surronded by a an invisible box.  When Flash records a hit, it is when the two boxes overlap, but the eye, the objects are afair distance apart:



There is a trick out there to watch different coloured pixels overlap, that will take some research.

Another issue some people were having was removing a child from the stage.  We created the obstacle in an array of obstacles, but removing individual elements are turning oout to be a bit of a complicated pain.  Some more reasearch is required.

UPDATE:  Getting this error when I try to remove a child
                    ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
    at flash.display::DisplayObjectContainer/removeChild()
    at DocClass/HitObject()

Here is what my code looks like:
for ( var count:int = 0; count < NUM_OBS; count++ ) {
                 if ( car_mc.hitTestObject( obsArray[count] ) )
                 {
                     trace("HIT!!  KABOOM!!" );
                     obsArray[count].scaleX /= 2;
                     obsArray[count].scaleY /= 2;
                     //obsArray[count].play();
                     car_mc.speed = 0;
                     trace(obsArray[count].scaleX + " " + obsArray[count].scaleY);
                     if ( obsArray[count].scaleX < 0.125 )
                         removeChild( obsArray[count] );
                 }
}

Keeping in mind I am trying to manage an array of obstacles for a simple car game.




Powered by ScribeFire.



Friday, October 16, 2009

Databases - Microsoft Access

Year 2 inlcudes an introduction databases.  We get to cover the exciting world of Microsoft Access and Visual Basic for Applications (VBA).  Last school year, we had an introduction to Visual Basic, and I figured that would translate well to VBA when used with Access.  I was wrong.

The basic concepts behind Access are failry simple.  Getting into VBA code is pretty annoying.   This goes back to my preference for C and C++ syntax.  VBA makes absolutely no sense to me.  It's a convoluted language that has too many wierd quirks to remember.  I especially do not like how VBA will automatically shift characters a couple of spaces; there is certain way I like to code, and VBA usually prevents me from doing this.

This is also another where there is no text.  Also frustrating as this makes studying at home a little more difficult; having to jump between two windows is annoying.  The teachers notes don't explain how things work behind the scenes in Access and VBA, so I don't truly understand what it is we are doing.  I like to be able to easily look up things, instead of endless Googling hoping someone has had the exact same issue as me.



Powered by ScribeFire.

Flash - My First Experience

I have discovered that I am not an artist, or designer in any kind of way.  I can not draw.  Take a look:



That is probably the best car I have drawn on a computer, and only the second best one ever.

My Mutimedia & Internet class is based on Flash and ActionScript.  After a an introduction into basic animations such as Classic, Shape, and Motion Tweens, we have moved onto ActionScript 3.0.

I find the Flash platform a crappy development environment.  I do not have much experience with animation, and  I am new to the Flash environment, but there is something unrefined about the user experience and the workflow.  The compiler and debugger seem as though they were added as an after thought.  It would be nice if there was a more unified approach to developing with ActionScript;  compiling should be a step by it self, where error messages are reported by themselves.  As it is, errors are being reported once Preview Movie is Selected.

Even the teacher says Flash CS4 is not the greatest tool available, and is looking for alternate methods for developing with ActionScript.  Since Flash is a very closed piece of software, I do not think he will be too successul.

On th upside, my ugly can turn, acclerate, and has an emergency break.  What I am looking to add is a way get the car bounce slightly off a wall (the wall being the edge of the stage).  I am open to any suggestions.

Powered by ScribeFire.



Wednesday, September 30, 2009

Algorthims

Year 2 started out 5 weeks ago with an algorithms class. Luckily enough, it still uses C++, which I still find to be the most comfortable with.

The teacher is a hard ass, yet good. He is one of those teachers that will yell at the class for not being quick enough, or giving answers that he thinks are beneath us. At the same time, he is the most respectful and encouraging teacher; he can give a student hell in one breath, then in the next, heap raise on the same student for showing effort.

The first two assignments covered basics like flowcharting and array subscripts. The algorithms teacher is more concerned at this point, with us producing clean code; appropriate comments, and a readable, consistent style.

It is a class about thinking, and less about syntax.

He is a very old school programmer, using ideas from K & R. For example, right now we are doing an excercise in C-Strings, and passing 2-D arrays to functions. This is also bundled with an program that has different sorting algorithms.

An example of the code I wrote today:

#include <iostream>
#include <iomanip> //for setw function to format output
using namespace std;

const char title1[] = { "Unsorted Array Data" };
const char titleWt[] = { "Weights" };
const char titleName[] = { "Names" };

const int L_MAX = 100; //maximum number of name strings in array
const int N_MAX = 10; //maximum size of each name string
const int L_SIZE = 20; //number of actual name strings in array


// Function Prototypes -------------------------------------------------------------

void OutList( const char[], const char[] ,const char[], char[][N_MAX], int[] );

// ---------------------------------------------------------------------------------

int main()
{
//array of name strings
char names[L_MAX][N_MAX] = { "wendy", "ellen", "freddy", "tom", "susan",
"dick", "harry", "aloysius", "zelda", "sammy",
"mary", "hortense", "georgie", "ada", "daisy",
"paula", "alexander", "louis", "fiona", "bessie" };

//array of corresponding weights for those names
int wt[L_SIZE] = { 120, 115, 195, 235, 138, 177, 163, 150, 128, 142,
118, 134, 255, 140, 121, 108, 170, 225, 132, 148 };

OutList( title1, titleName, titleWt, names, wt ); // print raw data


return 0;
}

void OutList( const char title[],const char nameTitle[], const char wtTitle[], char name[][N_MAX], int wt[] )
{
// prints the unsorted array of names / weights

cout << title << endl << endl;
cout << left << setw(12) << nameTitle << left << setw(12) << wtTitle << endl << endl;

for ( int count = 0; count < L_SIZE; count++ )
cout << left << setw(12) << name[count] << left << setw(12) << wt[count] << endl;

system ( "pause" );

}

The function Outlist() is not my favourite I have ever written. There are too many arguments, it is too easy to get lost, which leads to debugging nughtmare. Three arguments should be the maximum. Thoughts on this?

What did me in with the last assignment, was not that my program did not work, in fact it worked perfectly, I did not comment my code properly. If any one has any suggestions on how I should comment code in a way tht would please an old school programmer, let me know.




Powered by ScribeFire.

Saturday, August 29, 2009

Semester 2 - Programming 2

Take two on programming in C++.  This was by far my favourite class last semester.  The teacher was amazing.  If I could have this teacher for all the mundaine classes I will have to take in Computer Science, I would be very happy.

This teacher had a huge stutter, and the less comfortable he was, the more aparent it was.  But, as he became more comfortable with the group, his stutter started to fade, and would only come out on occasion.

Everyone I spoke to who was in this program before me, or even poeple in a year ahead of me, all told what an amazing teacher he was.  I thought they were saying this to be nice, but they were bang on the money.  He new exactly how to explain the complexities of C++ in a way that made perfect sense.  This guys knows everything there is to know about computers.  I'm sure if he tried he could re-invent Google.

Programming 2 covered searched, sorts, structured data, file input and output, an introduction to classes, pointers, and the part I found the hardest:  recursion.

Even making command line programs became more interesting because of the use of classes.  Breaking a program down in smaller parts made a lot more sense, and made debugging much easier.

He gave us challenging problems as labs, which were mostly simple games; Connect 4, Poker, and the most challenging, Othello/Reversi.

Reversi made all our other labs seem like childs play.  It was easy to make a move, place the piece on the board, and switch players.  Making any chain reactions happen because of a move was different.  Thanks to the teacher I was able to figure it out.



Powered by ScribeFire.

Semester 2 - User Interfaces

Class number 2 for my second semester was an inroduction to user interface design.

Again, this was not my favourite class, but I feel like I accomplished more than in Tech Support.

Based on Visual Basic, the teacher often referred to the class as VB, adn I don't remeber a thing from this class.  Visual Basic is annoying, I was getting used C++, and I found "if" statements much easier to understand in C++ than in VB, even though VB was intended to be simpler language to program with.  C++ required a lot more attention to detail, where as VB would finish statements for you.

Simple loops did not make sense to me.  In C++, we were taught understand how variables and arrays are stored in memory, then dealt with loops that would cycle through the array.  In VB, the connection between the variables we were creating and the loops we were using to process the data was not made.

The class was not made that interesting, and the teacher would lose his temper often enough that we had a hard time taking seriously when he got mad.  There was no text book for the class, yet I managed to find a Visual Basic 2008 text, which helped a lot.

On the upside, my tic-tac-toe game got 100%.

Powered by ScribeFire.



Monday, August 24, 2009

Semester 2 - Technical Support

The second semester at Computer Science at John Abbott College turned out to be no more interesting than the first.  One of the least interesting classes I had to take was Technical Support.  This class should have been in the first semester as Introduction to Computer Technology, I did not learn anything in this class either.  In fact, this class did prepare me for a technical support job.

There was some coverage of binary and hexadecimal numbers, again the history of computers.  Two assignments that were training manuals; the first on how to install a piece of software on Windows 98 (this class was taken in the winter 2009!!), the second on to zip a file in Windows XP.  The third assignment was a training presentation on any topic of our choice.  I chose using Twitter.  Our limitations were 10 minutes long, and we had to use the computer in classroom, which had no internet connection;  demonstrating how to use Twitter, and a few Twitter applications was pretty difficult, it's hard to show the full scope of something like Twitter with a few screen shots.

Hardware trouble shooting was rushed, and all I learned was how to install a hard drive and a RAM chip.

Software trouble shooting was even a bit more ridiculous, it involved formatting and partitioning a hard drive with F-Disk, install Windows 98, then re-format the hard drive with Partition Magic, and install Windows XP.  Norton Ghost was briefly covered.  Keep in mind, all of these applications were ran off a 3.5 inch floppy disk.

I am old enough to remember Police Quest and King's Quest on 5.25 inch floppies, but the recent high school grads in my class had only seen them lying around their parents place.  They had never actually used one.  This also made want to bring in a copy Leisure Suit Larry in the Land of Lounge Lizards for old times sake.



Powered by ScribeFire.