00:00
00:00
Newgrounds Background Image Theme

fillup69 just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

As: Birds Eye View Rpg

1,279 Views | 11 Replies
New Topic Respond to this Topic

As: Birds Eye View Rpg 2006-03-19 13:04:27


heres where it all begins

Notes: I will refer to a moveclip as a MC

What will you learn?

From this tutorial you will learn how to create a basic birds eye view game which you will be able to adapt to your own style.

Example

Lets get started

Ok, what you need to do is decide on how your character is going to look. For example, my character is a human. With this in mind you need to create your character from a birds eye view.

From here you need to select your whole character and convert it into a moveclip, with a registration point of centre. After this, give that symbol and instance name of "hero" without the quotes.

draw character> convert to a moveclip> centre registration point> give instance name of hero

Character continues

With your hero MC on the stage, double click it. This brings you to edit mode. From here you need to insert another 3 frames. In total you should have 4 frames. Your first frame should contain your hero facing upwards, the next frame should contain a MC with your character facing upwards walking.( not going into depth about walking cycles from above). Your third frame should contain an MC of your character facing to the right, and the last should contain an MC of your character walking right.

Note: your walking MC's do not have to move visually as the code will do this.

Moving your character

The following code shouldn't take too much knowledge of AS to understand. I will briefly go over the coding. Place the following code onto your hero MC:

onClipEvent (load) {
speed = 5;
}
onClipEvent (enterFrame) {
if(this._y>300) {
this._y=300;
}
if(this._y<0) {
this._y=0;
}
if(this._x>400) {
this._x=400;
}
if(this._x<0) {
this._x=0;
}
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.UP)) {
_yscale = +100;
this.gotoAndStop(2);
_y -= speed;

}else if (Key.isDown(Key.DOWN)) {
_yscale = -100;
this.gotoAndStop(2);
_y += speed;

}else if (Key.isDown(Key.LEFT)) {
_xscale = -100;
this.gotoAndStop(3);
_x -= speed;

}else if (Key.isDown(Key.RIGHT)) {
_xscale = +100;
this.gotoAndStop(3);
_x += speed;
} else {
this.gotoAndPlay(1);
}
}

onClipEvent (load) {
speed = 5;
}

This section tells the game to load a variable of speed.

onClipEvent (enterFrame) {
if(this._y>300) {
this._y=300;
}
if(this._y<0) {
this._y=0;
}
if(this._x>400) {
this._x=400;
}
if(this._x<0) {
this._x=0;
}
}

Change the numbers in here depending on what size your canvas is.

This section tells the character that it cannot move out of the boundaries which have been set.


onClipEvent (enterFrame) {
if (Key.isDown(Key.UP)) {
_yscale = +100;
this.gotoAndStop(2);
_y -= speed;

}else if (Key.isDown(Key.DOWN)) {
_yscale = -100;
this.gotoAndStop(2);
_y += speed;

}else if (Key.isDown(Key.LEFT)) {
_xscale = -100;
this.gotoAndStop(3);
_x -= speed;

}else if (Key.isDown(Key.RIGHT)) {
_xscale = +100;
this.gotoAndStop(3);
_x += speed;
} else {
this.gotoAndPlay(1);
}
}

The last part of the code tells the game that, if a certain key is down, do something. In our case it plays out moving animations. Else, it plays another frame.

_xscale = +100; This is the scaling on the _x axis
_x += speed; this tells it to move along the _x axis using the variable "speed"

The Room

To make a realistic environment, you need to have objects which the character cannot walk through.

A code is used to test weather something is touching something else. If so, do something. Here's the code:

onClipEvent (enterFrame) {
if (hitTest(_root.hero)) {
if (_root.hero._x<=_x-(_root.hero._width/2)+_
root.hero.speed) {
_root.hero._x = _x-_root.hero._width/2-_root.hero.speed
} else if (_root.hero._x>=_x+_width-_root.hero.speed
) {
_root.hero._x = _x+_width+(_root.hero._width/2)
} else if (_root.hero._y<=_y-(_root.hero._height/2)+
_root.hero.speed) {
_root.hero._y = _y-_root.hero._height/2-_root.hero.speed
} else if (_root.hero._y>=_y+_height-_root.hero.spee
d) {
_root.hero._y = _y+_height+(_root.hero._height/2)
}
}
}

Place this code on any MC object you do not want the character to walk through.

Room information

Maybe you want the game to be more interactive. A fun and easy way to do this is to show whitty comments about objects around the room. To do this you need to make the comments.

Write anything on the stage, e.g "this is a rug". Select the text box and convert it to an MC (f8). You may want to give it an instance name of what the comment is. ( "ruginfo")

You now need to decide what is to be clicked in order for the information to be displayed. Make sure the object is an MC and place this code on it.

onClipEvent(load){
_root.ruginfo._visible=false;
}
on(press){
_root.ruginfo._visible=true;
}
on(release){
_root.ruginfo._visible=false;
}

Using visibility is a common way of displaying objects if you dont want them to always appear.

onClipEvent(load){
_root.ruginfo._visible=false;
}

This tells the movie/game to load the ruginfo to be invisible.

on(press){
_root.ruginfo._visible=true;
}

Once the object is pressed , the ruginfo becomes visible

on(release){
_root.ruginfo._visible=false;
}

Once the mouse click is released the ruginfo returns to invisible.

thats all folks!

Using what i have told you, you should be able to throw together some nice games. Hopefully people will find this usefull,

If you would like to comment on my tutorial feel free.

_danny_

Response to As: Birds Eye View Rpg 2006-03-19 13:49:44


Cool. Nice tut

Response to As: Birds Eye View Rpg 2006-03-19 13:50:50


Yes lol..... Nice constructive crit :P LMAO

Response to As: Birds Eye View Rpg 2006-03-19 13:54:31


That hitTest code is done by me, so i would like to get some credit, please.

Response to As: Birds Eye View Rpg 2006-03-19 13:56:25


Only 4 directions? Meh.
The hittest could be better.


BBS Signature

Response to As: Birds Eye View Rpg 2006-03-19 13:58:54


Yeah creepy i was going to credit you, but i rushed it so... sorry

CREEPY MADE HITTESTING

Response to As: Birds Eye View Rpg 2006-03-19 14:00:19


At 3/19/06 01:55 PM, pyro111 wrote: Beat you to it.
http://www.newground../topic.php?id=451040


No offence, but mines also better.

Hey, it's not a competition!


BBS Signature

Response to As: Birds Eye View Rpg 2006-03-19 14:02:47


At 3/19/06 01:55 PM, pyro111 wrote: Beat you to it.
http://www.newground../topic.php?id=451040


No offence, but mines also better.

Lol, ok. Take alook in AS:main theres plenty of tuts which do the same things but differ in difficulty

Response to As: Birds Eye View Rpg 2006-03-19 14:24:25


Ok, i didnt write it? This tutorial is a basis of a RPG game. The example was a peice of a first level which i created. I am quite new to AS and i do admit i didnt write the hitTesting. What i cannot understand is why your trying to get rid of this because youve posted something similar recently? Thats rather said.

To be honest with you, im not totally bothered to see this thread drain away. All im now bothered about is your big headidness (SP?).

Response to As: Birds Eye View Rpg 2006-03-19 14:32:41


Ok (simple as)

Response to As: Birds Eye View Rpg 2006-03-19 15:02:11


At 3/19/06 02:31 PM, pyro111 wrote: No, im mad because this isnt an RPG game, or build for it. This is just basic movement, which could be done in 10 minutes by anyone, and that you didnt even fully write.

Why are you so angry? Even if it's a total noobish tutorial just leave it alone, it can't harm anyone. I do believe he wrote that code and it's an alright tutorial. And yes, it can be done in 10 minutes by a lot of people but he was the one to do it, and it bothers you so much?

Now it wasnt explained well, you should use // to describe every line in your code. As Main is about learning, and this is just copy and pasting.

It was explained quite well actually, and it is not copy and pasting.

Also, you didnt even make it well, it is much easier to use rotation when dealing with matters like these.
Finally, you admit to not being good at actionscript, and if you arent good, then you shouldnt be making a tutorial on it!

He never said he was a bad actionscripter, he just said he is new and that is why he wrote a tutorial for beginners.

Stop being big headed.


BBS Signature

Response to As: Birds Eye View Rpg 2006-03-19 15:04:13


At 3/19/06 03:02 PM, -Toast- wrote: some very nice stuff:P

Thanks, I understand totally that this was maybe a bad way of overcoming some issues. It's just I had the opportunity to make a tutorial thread.