Forum ActionScript 3.0 trying to code authentic landscape (as3 fill object)

Problems and discussions relating to ActionScript 3.0 here.

trying to code authentic landscape (as3 fill object)

Postby kuvi » August 16th, 2013, 9:57 pm

hi guys i have a math problem i need syntax help with. So heres the scope: basically i have my stage which is 600px high by 1000px long, over this stage, superimposed, is a movieclip with identical dimensions, this is my game window movieclip which all of my players, monsters, arrows, landscape etc are attached to (stage.addChild(gameWindow:MovieClip)). Now in the game window I have two castles i want monsters to spawn from, traverse the randomly generated battlefield, and start pounding the castle on the opposite end. The castles are 50px high and 150px long and will be attached to the gameWindow.

Now to make the battlefield ground i think i want to go with fractals because i enjoy the way it makes the landscape look (i thought about doing something with sines and cosines but i dont think it can make the rigid looking peaks i enjoy) My dad gave me a great outline on how to use fractals on a line graph, but im trying to figure out how to impliment it in the flash setting

So what im looking for: I need to build a shape, from the as3 code, that will be 600px high and 1000px long, this shape will need to be bisected by a line from .x=0 to .x=1000 and everything below the line needs to be colored 0x00FF00. The beginning part of the line will need to start between .y=200 to .y=400 and be a strait horizontal line 150px to the right (the left castle will sit on this plateau ) similarly the second castle will start between y.200 and y.400 but instead of sitting on a x.0 to x.150 flat line, it will need to be a x.850 to x.1000 line. So between the two plateaus (aka from x=150 to x = 850) I need to produce a fractal graph connecting the two end points. And again the end step would be to fill everything below the line green, indicating traversable land terrain. Since i dont know how much of my dads fractal code would be relivent/compatible with the flash IDE i wont include his formula unless someone asks for it

and the second question is, once i make this movieclip-land-terrain, how would i make the enemies running acrossed it have precise collision detection? Again i know how i want to do this i just need syntactical help, i need the following pseudo code to work:

while (monster5(/*anyPixelHue 0x000000*/)hitTestObject(randomlyGeneratedGround(/*anyPixelHue 0x00FF00*/)))

do monster5.y--
kuvi
 
Posts: 11
Joined: March 29th, 2011, 12:32 am

Return to ActionScript 3.0



cron