|
-
leight.com.au
[help] iso - collect - tonypa's tbw tuts
hey guys,
for a project in ITS we need to create something for a client (one of the teachers) in flash. what I have to do is create an interactive movie/game for my teacher.
what it is meant to be at the end
It is meant to be an isometric view of the workshop, where you wander around into different sections of the workshop (woodwork room, metalwork room, etc). there are tools and machines lying around and when the character walks up to them, a screen pops up asking them whether they want to watch a tutorial on how to use that tool/machine or if they actually want to use it.
well what i have done so far is created the woodwork and metalwork rooms with walls and benches.
what i am stuck on is actually placing things (machines and tools) onto the map properly. I have done it with normal tile based, but cannot seem to figure out how to do it properly with iso :S it seems to place it in a different spot! however it does collect the item at the specified spot by myItems, but the graphic isnt in the right spot!
here is my map:
code: workshop1 = [
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], // 0
[ 1, 0, 0, 0, 0, 0, 0, 0, 0,10], // 1
[ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], // 2
[ 1, 0, 0,40, 0, 0,40, 0, 0, 0], // 3
[ 1,55, 0, 0, 0, 0, 0, 0,44, 0], // 4
[ 1, 0, 0,40, 0, 0,40, 0,44, 0], // 5
[ 1,55, 0, 0, 0, 0, 0, 0,44, 0], // 6
[ 1, 0, 0,40, 0, 0,40, 0, 0, 0], // 7
[ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], // 8
[ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0] // 9
];
here is my script for placing the items:
code: myItems = [
[0],
[[1,1,8]]
];
here is my script in the buildMap function:
code: game.items = myItems[game.currentMap];
for (var j=0; j<game.items.length/2; ++j){
for (var i = 0; i<game.items.length; ++i){
var name = "item" + game.items[i][2] + "_" + game.items[i][1];
game[name] = new game["Item" + game.items[i][0]];
game[name].position = i;
game.clip.attachMovie("items", name, 10001+i);
game[name].clip = game.clip[name];
game[name].clip._x = (game.items[j-i][1]*game.tileW);
game[name].clip._y = (game.items[j+i][2]*game.tileW/2);
game[name].clip.gotoAndStop(game.items[i][0]);
}
}
_root.tuts = game.tuts;
thanks guys!
leighton
ps: been doing tonypa's tuts, theyre excelent!
ps2: sory for the long post
Last edited by leight; 05-09-2004 at 02:01 AM.
-
leight.com.au
just been talking to SaphuA,
i told him about how i wanted it like Bauk's 48hr comp game where u go up to the people (for me: tools/machines) and press Z (for me: SPACE), and you give beer to the people (for me: option for tutorial or interactive).
SaphuA suggested calculate the tile on which the character is on then go from there, but i guess i want to check to see if the hero is facing towards the machine (in this case (attatched) its the wood lathe: well it will, atm it says 'none') and if they press SPACE, they get the option of doing the tutorial/interactive for that tool/machine.
how would i do that?
maybe saying that will get me some help
-
SaphuA
:)
That's exactly what I tried to tell you 
Could you explain your item-placement thingy? I'll then try to help you...
SaphuA
Last edited by SaphuA; 05-09-2004 at 08:39 AM.
-
leight.com.au
-
Senior Member
I would make it exactly like you described in your last post
-
The way i would do it is that i would make an array of the room with the walls (5), tables (6), floor (0) and tools (2-4). Then when the player hits space the game checks what value the array has at his current position, and if it is 2, 3 or 4 and it runs a function according to the number:
code:
map=new Array(["5", "5", "5", "5", "5", "5", "5", "5"],
["5", "0", "0", "6", "6", "0", "0", "5"],
["5", "0", "0", "2", "3", "0", "0", "5"],
["5", "0", "0", "0", "0", "0", "0", "5"],
["5", "0", "6", "6", "0", "6", "0", "5"],
["5", "0", "6", "4", "0", "6", "0", "5"],
["5", "0", "6", "6", "0", "6", "0", "5"],
["5", "5", "5", "5", "5", "5", "5", "5"]);
//draw it like you would normaly do
function toolPlay(tool){
_root.popUp.gotoAndPlay(tool);
//this plays the movie of the tool or opens a menu
//where you can choose what to do with the tool
}
//this is in the main hero:
onClipEvent(enterFrame){
if(Key.isDown(37) and Number(_root.map[x+1][y])<5){
x++;
}...And so on
if(Key.isDown(32)){
pos=Number(_root.map[x][y]);
switch(pos){
case 2:
_root.toolPlay("Welder");
break;
case 3:
_root.toolPlay("Drill");
break;
case 4:
_root.toolPlay("Hammer");
break;
}
}
}
Hope you understand that
-
leight.com.au
-
Senior Member
Originally posted by leight
- check to see if the hero's current x position = desired position
- check to see it the hero's current y position = desired position
- check to see it the SPACE key is pressed
- check the hero's direction to see if theyre facing the object (well tile)
- if so, then up comes the option screen.
Like this.
-
My reply is kinda like tonypa advices. The breaks are there because its a switch/case. it could have been written like this:
code:
if(pos==2){
_root.toolPlay("Welder");
}else if(pos==3){
_root.toolPlay("Drill");
}else if(pos==4){
_root.toolPlay("Hammer");
}
The array is the map. If you standardize the maps, then this engine should work no matter what you load. I would advice you to set a limit at 20 ir 30, and everything below 30 is walkable (instead of and Number(_root.map[x+1][y])<5 you have and Number(_root.map[x+1][y])<30). That way you can fill up that up with tiles for other tools too. The tiles are told to gotoAndPlay the value they have (for table that is 6). But you can have lots of different table tiles.
If you want to keep this engien open then you can load a .swf url with the tile map for each tool tile. Then when toolPlay is called it loads the swf from its url. Then you can expand it as much as you want. You can also supply a tile map url with the array so you can load different tiles for different engines.
Hmmm, i think i want to make a tilebased iso engien now
-
leight.com.au
WOOHOO!!! my first ever tile based coding without a tutorial 
thanks guys! i took the map array idea from tonypa's tile based tuts, the switch/case from ihoss, some explinations on arrays (actionscript for flash mx: the definitive guide)
wana see what i wrote?
code: function Items(){
tool = "none";
toolsMachines = [
[1,2,8],[1,2,6],[1,2,4], // wood lathe
[2,2,5], // router
[3,3,2] // drill press
];
for (var i=0; i<toolsMachines.length; ++i){
if (char.xtile == toolsMachines[i][1]){
if (char.ytile == toolsMachines[i][2]){
toolType = Number(toolsMachines[i][0]);
switch(toolType){
case 1:
tool = "wood lathe";
break;
case 2:
tool = "router";
break;
case 3:
tool = "drill press";
break;
}
}
}
}
}
thanks guys!!!
ps: maybe i should have 2hrs sleep more often
Last edited by leight; 05-10-2004 at 08:47 PM.
-
leight.com.au
an easier way???
hey guys,
just wondering if there is a more efficient way of setting the tile properties? eg: in my map i have labeled the tiles their own frame numbers. would there be a really quick way to have the tiles from say 45-50 done in one statement (like the actionscript below) instead of doing each individual one???
code:
game.Tile10 = function () {};
game.Tile10.prototype.walkable = false;
game.Tile10.prototype.frame = 10;
thanks guys!
-
leight.com.au
-
Senior Member
Nice game so far 
I only wish it would be possible to close options pop-up with some key, not good to switch to mouse for it.
-
leight.com.au
what key? I just put [BACKSPACE] - took 2 seconds 
do u know if there is a quicker way? question 2 posts before.
thanks guys
Last edited by leight; 05-11-2004 at 06:12 AM.
-
Senior Member
Originally posted by leight do u know if there is a quicker way? question 2 posts before.
You dont actually have to make each tile with every frame number a separate prototype. With simple game like yours, you only need 3 prototypes:
walkable tile,
wall tile,
tool object.
You can place all the different walkable tiles in frames 1-99, all the wall tiles in frames 100-199 and all the tools in frames >=200.
Now when you read frame number from map array, you only have to check in which of those 3 it fits and use appropriate prototype.
-
leight.com.au
just found out today that i have 20 days left to make it (along with 6 other assignments in 4 weeks )
thanks tonypa!
-
leight.com.au
im having a little bit of trouble with setting it up. my 'Benches' frames are 40-49. i've tried:
code:
// another attempt - definatly wrong!
game.Benches = function () {};
game.Benches.prototype.frame >= 40;
game.Benches.prototype.frame <= 49;
//
// another attempt - thought it might work
game.Benches = function () {};
for (i=39; i<50; ++i){
game.Benches.prototype.walkable = false;
game.Benches.prototype.frame = i;
}
//
// another attempt - thought it might work
for (var i=39; i<50; ++i){
game.Tile[i] = function () {};
game.Tile[i].prototype.walkable = false;
game.Tile[i].prototype.frame = i;
}
could i please habe some tips
-
Senior Member
Not really like I thought. My idea was something like this:
//declare prototypes
game.Tile_walk= function () {};
game.Tile_walk.prototype.walkable=true;
game.Tile_wall= function () {};
game.Tile_wall.prototype.walkable=false;
game.Tile_tool= function () {};
game.Tile_tool.prototype.walkable=false;
game.Tile_tool.prototype.tool=true;
Now in the buildmap function, check whats the value is in the map array:
replace this line:
game[name]= new game["Tile"+map[i][j]];
with:
if(map[i][j]<100){
//walkable
game[name]= new game.Tile_walk;
}else if(map[i][j]>200){
//tool
game[name]= new game.Tile_tool;
}else {
//wall
game[name]= new game.Tile_wall;
}
game[name].frame = map[i][j];
-
leight.com.au
aaahhh its done like that im a tile/iso newbie 
thanks for all your help mate!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|