PDA

View Full Version : Scrolling.



elPooter
July 23rd, 2004, 09:10 PM
Konichi wa, Fellow Kirupans!

I need help developing a scrolling terrain and backround for my game. In my other games, I have always used this wimpy coding for scrolling:



onClipEvent (enterFrame) {
if (_root.hero._x>268.4) {
_root.backround._x -= 2;
_root.terrain._x -= 2;
_root.hero._x -= 2;
}
if (_root.hero._x<44.5) {
_root.backround._x += 2;
_root.terrain._x += 2;
_root.hero._x += 2;
}
if (_root.hero._y>189.4) {
_root.backround._y -= 3;
_root.terrain._y -= 3;
_root.hero._y -= 3;
}
if (_root.hero._y<-2.6) {
_root.backround._y += 3;
_root.terrain._y += 3;
_root.hero._y += 3;
}
}



...And I HATE that coding :ogre:. If anyone can help, that would be great. Thanks in advance!

-elPooter.

dal platinum
July 23rd, 2004, 10:38 PM
onClipEvent(EnterFrame) {
this.gamebottom = -300;
this.gametop = 600;
this.gameleft = -750;
this.gameright = 0;
this.vx = 0;
this.ax = -250;
this.vy = 300;
this.ay = 0;
this.force = 0.07;
this.damping = 0.70;
}



onClipEvent(EnterFrame) {
this.ax = (_root.gamebase.char._x+_root.gamebase._x-375)*this.force;
this.vx += this.ax;
this.vx *= this.damping;
this.ay = (_root.gamebase.char._y+_root.gamebase._y-190)*this.force;
this.vy += this.ay;
this.vy *= this.damping;
this._x -= this.vx;
this._y -= this.vy;
if (this._x>this.gameright) {
this._x = this.gameright
}
if (this._x<this.gameleft) {
this._x = this.gameleft
}
if (this._y>this.gametop) {
this._y = this.gametop
}
if (this._y<this.gamebottom) {
this._y = this.gamebottom
}
}

This is the code on my last game (before I switched to one-framing it). It'll require some modification.

Unless I'm mistaken, you will need this on the background clip, and just have some code on the terrain clip taht duplicates the _x and _y of the background clip.

In my game, the player character was created in the gamebase mc, and the gamebase mc is the background and levelly stuff, so the real _x coordinates are relative to the gamebase mc. I'm not sure how yours is rigged, so I can't offer any more help.

the 375 is the x centre of my movie, and 190 is below the y centre of the movie, you'll have to alter these to match your movie.

mess around with force and damping until you get the speed you want.

Hope this is of some use.

elPooter
July 23rd, 2004, 11:02 PM
Arigato! Thank you :hugegrin: Ill experiment with that.

chriskalani
July 24th, 2004, 01:15 AM
Nihongo ga dekimasu ka!?

elPooter
July 24th, 2004, 01:48 AM
Hai! Nihongo ga skoshi Wakarimasu. Nihongo ga sogon na desu! doi suru ne?

chriskalani
July 24th, 2004, 02:50 AM
Nan to osshaima****a ka? (sogon, suru, doi) Sono kotoba wa shirimasen!? o_O?

Bahamutzero
July 24th, 2004, 03:23 AM
@.@ Oroo....Nihongo muzukashii desu ne!

....Watashi no nihongo warui desu yo! >.<


-Ja-ne


PS. I like your flippy guy! lol
=^-^=

elPooter
July 24th, 2004, 09:56 AM
Ok, if I said something bad in japanese, I would have no clue! Im a beginer at japanese.

elPooter
July 24th, 2004, 10:12 AM
Hey _saru_, what did you say when you said:

Nan to osshaima****a ka? (sogon, suru, doi) Sono kotoba wa shirimasen!? o_O?

and

Nihongo ga dekimasu ka!?

I thought you asked me if I understood japenese.

Bahamutzero
July 25th, 2004, 02:27 PM
you guys used alot of words in japanese ive never heard of....did you spell them right because they are not even coming up in my japanese translator......@.@

elPooter
July 25th, 2004, 02:48 PM
I just look up the words in my book.