Scrolling Platform, I NEED HELP MAKING WALLS!

Hey my name is Daniel and after a break of 1 year i am starting flash again, but this time instead of animation i am focussing more on game development. After reading endless tutorials on actionscript i have come up with part of a side scrolling engine you can; walk, jump and pick up coins health ect and i am pretty sure i will be able to make enemies soon. before i make enemies i want to make a wall which you cannot get through i have tried various ways on this but none of them have been good solid ideas. So any help on this would help alot thankx.

P.S. sorry for the n00bishness :blush:

and by the way, when i figure this out you wont be able to go through that wall on the left.

use a if(!) to check they’re not hitting the wall before they move

what he means is

if(!_root.hero.hitTest(_root.wall)){//walking here}

more a long the lines or left wall, or right, or getBounds…

Because they would get stuck that way

Right i tried to make it so if the character is not touching the wall then he can move as you said but he gets stuck as Nathan said. But Nathan what do you mean by “left wall, or right wall” and i have never heard of getBounds what does it do? please your help so far has helped but not quite enuf.

:look: [SIZE=“1”]Just wondering, does anyone actually read any of the tutorials that explain exactly how to make walls?[/SIZE]
[COLOR=“Red”]explodes[/COLOR]

As i said i have tried numerous tutorials on making wall ect but none of them have seemed to work properly. They all seem to have glitches

well, ok I didn’t give you the whole code because i want’ed you to think a little bit but there isn’t really that many tutorials for making walls since making walls is what you do with the knowledge you should know,

now im assuming that you are using some sort of art based game and not tile based, so i would say maybe do something like this


var left:Boolean=false
var up:Boolean=false
var down:Boolean=false
var right:Boolean=false

if(_root.hero.hitTest(_root.wall) && _root.hero._x<_root.wall._x){right=true}else{right=false}

//movement

if(Key.isDown(Key.RIGHT) && !right){_root.hero._x+=2}


now as you can see this is partial code so all you have to do is rebuild, there is a million ways to do this, and i work with tiles so if my methods seems wierd just dont use it

Hehe, bomby, this would be better, though yours wouldd work too;

on frame(Full Left & Right movement for char):


stepHeight = 10;
hero.onEnterFrame = function() {
if(!_root.wall.hitTest(!this.getBounds(_root).xMax, this._y-stepHeight, true) && Key.isDown(Key.RIGHT)){
this._x += 2;
} else if(!_root.wall.hitTest(!this.getBounds(_root).xMin, this._y-stepHeight, true) && Key.isDown(Key.LEFT)){
this._x -= 2;
}
}

Sorry but i guess i must be a complete n00b cos i basically dont understand any of that. Try to think of it from my point of view, i dont understand any of that and you are telling me the answer but i cant implement it into my own code, it is very frustrating and in a way i am kinda scared to ask for help cos you guys have even bothered to help me so far i know u r going to be pissed when i tell u i dont understand cos i know i would be. i want to understand all this so i can make games without help, and maybe even help other ppl. So if you could giv me a link to a good tutorial that actualy explains code such as getBounds and so on or even just explain it to me that would be a great help cos to be honest i am completely lost. :ne:

Daniel man, look at the online documentation fo actionscript of press f1 in flash and get help there for definitions of action script functions etc. :stuck_out_tongue:

also i would say, if you dont know how to understand code and implement it, you are a very long way from even making a game yet, all i would say is build up, dont plunge in, make simple stuff (maybe a 2d ping pong game to start to get used to hitTests and moving stuff?) and just work ur way up.

getBounds = returns an object containing 4 variables:
xMin, xMax, yMin, yMax

those are the positions of the sides of the smallest square that contains the whole mc :slight_smile:

While it’s in my clipboard: http://www.kirupa.com/forum/showthread.php?t=204937&highlight=getBounds