Friday, June 6, 2008

Wednesday, June 4, 2008

JJJFFFJFJFJFJFJFJJJFFFFFFJJJFFFJJJJFJFF

Ok ... type to learn lesson one: F and J

Actually I made the background scroll with the guy ... soon this will be added to the website, but I need to be at home to do that...

Here is the segment of code used:

if(_root.player._y > 100){
_root.player._y -= 2;
} else {
_root.wall._y += 2;
}
Okayyy, so here we have an if statement determined by the position of the player on the y axis. If the player's y value is greater than 100 (remember y axis is reversed in flash) the player will move up (y-2) and if the player is less than 100 (near the top) the wall will move down instead of the player moving up.

This all gives the effect of the player moving up, yet the player will never reach the edge of the screen because as soon as it hits the y = 100 point the wall will move instead!

SWF coming soon!

Tuesday, June 3, 2008

ASDFGHJKL

Here are a few of my .swf's :

http://www.maxhardcastle.com/Indy2008/IndyIndex.html

Hope that clears up the program from before (It's the one titled Trigonometry) ...

Monday, June 2, 2008

ABCDEFGHIJKLMNOPQRSTUVWXYZ

OKAAAAAAAAYYYY

So the four corner point thing didn't work out so well... It's basically a lot more buggy than the first version, but perhaps I messed up a corner. Who knows.

In other news I've been working with some trig and managed to make a rotating circle program. I think I might dedicate a page of my website to Flash swf's since I learned the other day that I have 300gigs of space to use (maxhardcastle.com server thing).

Here's a snippet of code from that program outlining some new stuff:

angle = Math.atan(mousex/mousey)

xval = _root.circle._x + radius*Math.cos(angle);
yval = _root.circle._y - radius*Math.sin(angle);


New terms:
Math.atan - This is the "arctan" or inverse tangent function ... returns a value in radians ...
Math.cos - cosine...
Math.sin - sine...
and later on:
Math.PI - 3.141592653584626 (That's all I can remember... might be wrong)

Here the code finds the angle that the mouse creates in relation to the center of the coordinate plane designated by the center of the movie clip that this code resides in. That might seem complicated, but it really isn't. There is a circle on the screen, the center of the circle is the origin. Imagine there is a point where the mouse is, now draw a line from that point to the origin, and then find the angle of that line in relation to the x axis.

The second part calculates the x and y coordinates where the imaginary line from the mouse crosses the circle on the screen.

As I mentioned earlier, all this would be so much easier with an example of this program because it's hard to describe exactly what I have created.

if( mousey > 0 ){
degrees = ((((Math.atan(mousex/mousey))*(180/Math.PI))+90)+180);
}
if( mousey < 0 ){
degrees = (((Math.atan(mousex/mousey))*(180/Math.PI))+90);
}


This code finds the angle the mouse creates in degrees (normally it's in radians) hence the name of the variable "degrees" ...

Flash movies coming soon! (I hope)

Friday, May 30, 2008

BLOGGERRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR

That's not going to be an annoying title!

wELCOME TO www.b.loggar.net (it's dot com!)

here is some new code for wall hit test that works relly G00D(ly):

onClipEvent(enterFrame){

var radius:Number;
radius = ((_root.player._width)/2)

var position:Array = new Array();
position[0] = (_root.player._x); //up
position[1] = (_root.player._y - radius);
position[2] = (_root.player._x + (radius*cos(45)));
position[3] = (_root.player._y - (radius*sin(45)));
position[4] = (_root.player._x + radius); //right
position[5] = (_root.player._y);
position[6] = (_root.player._x + (radius*cos(45)));
position[7] = (_root.player._y + (radius*sin(45)));
position[8] = (_root.player._x); //down
position[9] = (_root.player._y + radius);
position[10] = (_root.player._x + (radius*cos(45)));
position[11] = (_root.player._y - (radius*sin(45)));
position[12] = (_root.player._x - radius); //left
position[13] = (_root.player._y);
position[14] = (_root.player._x - (radius*cos(45)));
position[15] = (_root.player._y - (radius*sin(45)));

if(Key.isDown(Key.DOWN)){
if(!(_root.wall.hitTest(position[8], position[9], true))){
_root.player._y += 2;
}
}
if(Key.isDown(Key.UP)){
if(!(_root.wall.hitTest(position[0], position[1], true))){
_root.player._y -= 2;
}
}
if(Key.isDown(Key.LEFT)){
if(!(_root.wall.hitTest(position[12], position[13], true))){
_root.player._x -= 2;
}
}
if(Key.isDown(Key.RIGHT)){
if(!(_root.wall.hitTest(position[4], position[5], true))){
_root.player._x += 2;
}
}
}


So yeah... I haven't implemented the four corner points yet but the other ones work.

Explanation: the player can move right unless the right side of the body hits the wall etc.

shreck is a darth red and black painted person

btw player is a mc that is shape in a circal

Thursday, May 29, 2008

Maybe A good blog

I have been working on AI:

var time:Number = 16.66;
var delay:Number = 16.66;

function walk(){
_root.circle._x += 3;
clearInterval(delay);
}

delay = setInterval(walk, time);


Sets two variables, creates a walk function, and the final line executes the walk function over an interval (setInterval). Delay is how often it executes the interval and time is how often it executes the function (I think).

Friday, May 16, 2008

Game is coming along fine now.

TODO:
1) write better blogs. (ones that have capital letters at the beginning of each "sentence")
2) limit power on the laser (chance for upgrades)
3) make levels and make Ethan draw cool pictures for the levels

Monday, May 12, 2008

A better post than the last one

Third level contains walls. They continue to be a pain since walls near each other conflict and cause the player to be jumpy. The player also sticks to the walls (cannot move diagonally away).

Levels 1 and Too

Two levels are complete. They are actually fairly difficult... Evil things, money, and weird camo tables with watering cans inhabit the desolate green landscape. There really isn't a point to this game yet.

Tuesday, April 29, 2008

From Here on Out

Good song! In any case, my plan for post-windmill construction is to generate a list of all things that have to get done on the game. This will make things move a lot smoother because I can choose a task, focus on it, get it done, and then do the next one. Once these are all done, the product will be a game engine. From that point creating the game will only take a little work and a lot of Ethan's creative brain.

Soon to come: Plan of Action v. 1.0.4.9.1.0.4a.f5.b or whatever the 'first' one normally is.

Wednesday, April 16, 2008

Wind Power in Compy Class?

It's still electricity! Well, not really the same, but today I spent the majority of class learning about the new data logger that Richard has. It's super cool, we got the distance measurer to work. Before I got distracted by that, however, I made an ActionScript file from some code for the player mc. I've dabbled around with includes at home, so that wasn't exactly new, but I commented in the file to make it more universal. For instance, there were some instance-name-specific things in the code, so I just specified what things on the playing field had to be named.

After that, I played around with the enemy mc and now when he gets laser'd he turns into a little money sign. Perhaps I can make it drop random objects, that would be pretty cool! I suppose I would use some sort of random number generator to generate a number from say, 1 to 5. If 1, go to frame A, if 2, go to frame B, etc. The code for what the object is would be on the hitTest on each item frame. I'm really amazed how flexible flash is. The movie clip hierarchy system is very well designed and provides an incredibly easy system for working with more complex things. I think it was wise for Ethan and I to switch from C++ to this because of how basic C++ is, but there are a few other things I want to address in C++. I'll probably just do that on my own time though.

Saturday, April 12, 2008

Ahhhh

My variables are failing me!.. Actually, I'm just using them wrong, but I've implemented the previous knowledge in making the code more streamlined. The savegame function is my next big challenge. To do this, I will have to record the position of the player as _x and _y values, the rotation of the player, which part of the map the player is located in, which items have been taken, which enemies have been killed, etc. It's going to be complicated to get the system up and running, but once it's there things will be easier. The idea is that we're working towards a game engine and once that is figured out we can make challenges, etc. for use in the game itself (so that it's actually fun to play).

Wednesday, April 9, 2008

Variables

Today I figured out a bit more about variables. It seems that in Flash, everything is 'placed' within layers. The layers are determined by movie clips within movie clips.. etc. For instance, to access a clip (foot1) inside of another clip (player) the programmer would have to write _root.player.foot1 This approach goes for variables as well. If a variable (speed) is declared in the foot1 mc, then to access it the programmer must write _root.player.foot.speed ... seems simple enough, right? Well coming from the background of C++ where there were no layers, I assumed that the variables would all be accessible from all code anywhere. Wrong... but the good news is, making variables is very easy. It's as simple as:

var variablename:variabletype = some_initial_value;

For instance...

var money:Number = 0;
//code placed at the very top level of the movie (not in any mc's)

To access this from any mc I would write:

_root.money

For instance, if I wanted to add 50 to the value of money when the player gets 50 moneys, I would put this code:

_root.money += 50;

Simple! This is the great part about AS, once I figure out what the syntax is, it's very fast. I could write out the code to make a pulldown menu function with only a few lines.

Something else that I found out was AS supports "include" files. For instance, I have some chunk of code that makes the mc move with the arrow keys. I could create an actionscript file (.xml if I am remembering correctly) called "arrowkeycontrol.xml" which could be saved in the same directory as the .fla file. I could then type the code #include "arrowkeycontrol.xml" into any mc in that program and it would be controlled by the arrow keys. I could very well have the syntax wrong here, but finding that out is very easy with the actionscript library! I've found it to be the most useful help menu I've encountered!

Tuesday, April 8, 2008

Some homework... =o

At home, I created a movie to test pulldown menus. It worked well, to say the least. I used the code:

on(rollOver){
code;
}
on(rollOut){
code;
}

This controls what happens to movie clips when the cursor moves from being off the movie clip, to on the movie clip (and vice versa). There is one problem however. When the user puts the mouse overtop of the clip to be pulled down, the mask moves and reveals the menu, but when the user goes to click on a menu item, it moves off the original clip to be pulled down, and the menu disappears. I did a little research and downloaded some .fla's from FK but my CS3 trial ran out a while back. I'll have to extract the actionscript while I'm at school, or have someone on the ActionScript.org forums help me out. Menus are something intrinsic to most Flash applications etc. Even if they aren't necessary, they can be very beneficial.

Monday, April 7, 2008



Hope this works!

At a later date: It seems the quality is quite bad, but here's a 'commentary':

The user clicks "New Game" and a game begins. The character (in blue) is controlled by the arrow keys, and the space bar activates his laser beam eyes to kill an enemy. He then goes to collect money and as seen, the inventory records what happens. At the end, the player runs into the castle and wins the game.

Rather basic, but the money took a while and is far from being completed. 'NaN' stands for Not a Number and was a common error while working with the code to get the money to work. Here, it's an item that does nothing... =)

awkefbakwjefbkwaebfgakwgbkwjangkrgr

Today: worked on the game 'engine' ... more specifically, I researched how to use variables! Something that is usually important when programming... I also found out how to change dynamic text from actions (hitTest, buttons, if statement, etc.) Dynamic text is very handy for dynamic things that are text! The one I was working with was money. If the player runs over a hunk of money they have to be able to see the money in their inventory. TODO: figure out how to define global variables or 'more universal' variables. It seems that the variable that I made can only be used within one movie clip.

Thursday, April 3, 2008

Updateeeee

Haven't posted in a while... Here's an update:

Created a laser-eyed player that can zap bad guys and run to the finish with one minor bug of not moving diagonally away from the walls... However, hitting the bad guys results in losing the game...

In the process of: Creating a savegame system. I'm not sure how to store data for users... to the best of my knowledge, Flash doesn't have file I/O built in for security reasons (heavily used for web ads, etc.).

I know there are flash games out there with save options, etc... so we'll see how it goes. I may use level codes and quicksaves...

In any case, it's looking like there will be an actual game this year!

Thursday, March 27, 2008

A Game!

There is now a game! It has instructions, it has a way to win, it can get really boring, and it has bugs! woohoo!

Wednesday, March 26, 2008

Universal Wall Code

The moment of truth... a C&Pable chunk of wall! I have formulated some code to be applied to an mc(movie clip) so that it becomes a wall. It was pretty easy now that I know what I'm doing. I also figured out how to control the movie clip from hitTest.

Here is the code for the universal wall:

onClipEvent(enterFrame){ //code applied to the mc of the wall
if(this.hitTest(_root.player.head)){
_root.player._x = this._x - 13;
}
}

And here is the code applied to the player to make the hitTest control the movie itself:

if(this.hitTest(_root.win)){
this.stop();
_root.gotoAndStop(20);
}

Turns out I have to stop the movie before I switch frames...

In other news, the naming scheme is as such: Graphical entities are name_g, Movie Clip entities are movieClip_mc, and Button entities are button_b (this was a naming scheme I adapted from the flash book back in 9th grade...)

Monday, March 24, 2008

-insert title here-

So I haven't sketched so much detail yet... although I do have some. One thing I'm struggling with is hitTest combined with clip control. For instance, when el protagonist runs into the random blue square ... the movie goes to a new scene. However, that hasn't worked thus far.

onClipEvent(enterFrame){
if(_root.winsquare, hitTest(_root.player)){
gotoAndStop(5);
}
}

The above code has no affect on the movie....

//this code to go in main actions layer...
if(_root.winsquare, hitTest(_root.player)){
gotoAndStop(5);
}

This, however, seems to skip straight to frame 5 even if the player has not hit the block yet....

AGH! ... =D

in other news, Richard helped out with the FTP site, so I'll have to get Ethan set up with that soon... and I'll also have to cram some of my movies up there. If I can figure out how to make a folder public I can post links from this blog so that people can see my progress. Otherwise it'll be peering over shoulders, posted code, and screenshots!