Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[Flash/AS] Falling objects

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Noz3001
I'm a spammer
Reputation: 26

Joined: 29 May 2006
Posts: 6220
Location: /dev/null

PostPosted: Thu Jul 31, 2008 6:06 am    Post subject: [Flash/AS] Falling objects Reply with quote

I'm trying to make a game for my DA profile where random objects fall down and you have to collect them (and dodge some).

So far i have:
Code:
var drops = new Array( "_shuriken", "_kunai", "_konoha", "_kibaCollect" );
var count = 0;

function SpawnDrop ()
{
   var Drop:MovieClip;
   Drop._x = Math.Random()*Stage.width;
   Drop._y = 0;
   
   if( count <= 35 ) {
      Drop.attachMovie( trace(drops[ Math.Random()*3 ]), "_dropTmp", count, count );
      Drop.onEnterFrame = StartDrop(Drop);
   } else {
      gotoAndStop(3); // Leave to the completion frame
   }
   count++;
}
var IntID = setInterval( SpawnDrop, 3000 );


function StartDrop ( item )
{
   var gravity = 6;
 
        item._y += gravity;
        item._y += item._y;
        if (item.hitTest(_root.tray))
        {
            trace("Item fell");
            delete item.onEnterFrame;
        }

}


Does anyone know why NOTHING appears or falls? if i change "item" to "this" in the StartDrup function, the whole stage falls down so I know that the falling works.
Back to top
View user's profile Send private message MSN Messenger
merlin22
Master Cheater
Ban
Reputation: 0

Joined: 29 Mar 2008
Posts: 267

PostPosted: Thu Jul 31, 2008 8:08 am    Post subject: Reply with quote

Code:

var drops = new Array( "_shuriken", "_kunai", "_konoha", "_kibaCollect" );

function SpawnDrop ()
{
   for (i=0; i<35; i++) {
   var Drop:MovieClip = _root.attachMovie("lol", "Drop",+_root.getNextHighestDepth, _root.getNextHighestDepth)
   Drop._x = Math.random()*Stage.width;
   Drop._y = 0;
   
   
   Drop.onEnterFrame = function() {
  var gravity = 2
 
        this._y += gravity;
        this._y += 2
        if (this.hitTest(_root.tray))
        {
            trace("Item fell");
            this.unloadMovie()
        }
   }
   }
   
   
}
var IntID = setInterval( SpawnDrop, 3000 );


I fixed the ball falling speed for you because it was way to fast.
Back to top
View user's profile Send private message AIM Address
Noz3001
I'm a spammer
Reputation: 26

Joined: 29 May 2006
Posts: 6220
Location: /dev/null

PostPosted: Thu Jul 31, 2008 8:25 am    Post subject: Reply with quote

Thanks! Things actually fall down now but i'm still having problems with my array. Whenever i use trace like this:

Code:
trace(drops[ Math.Random()*3 ])


It outputs "undefined". Any ideas?
Back to top
View user's profile Send private message MSN Messenger
merlin22
Master Cheater
Ban
Reputation: 0

Joined: 29 Mar 2008
Posts: 267

PostPosted: Thu Jul 31, 2008 8:35 am    Post subject: Reply with quote

Code:

trace(drops[Math.round(Math.random()*3)])


An array requires specific values, not 0.10438302 so round it.
Back to top
View user's profile Send private message AIM Address
Noz3001
I'm a spammer
Reputation: 26

Joined: 29 May 2006
Posts: 6220
Location: /dev/null

PostPosted: Thu Jul 31, 2008 8:40 am    Post subject: Reply with quote

That made it output all of the entries at once =|. Also, I want more than one thing to fall at once but why does the movieclip currently on screen dissapear when another is put on?
Back to top
View user's profile Send private message MSN Messenger
merlin22
Master Cheater
Ban
Reputation: 0

Joined: 29 Mar 2008
Posts: 267

PostPosted: Thu Jul 31, 2008 8:46 am    Post subject: Reply with quote

noz3001 wrote:
That made it output all of the entries at once =|.


Code:

nub.onRelease = function() {
trace(drops[Math.round(Math.random()*3)])
}



noz3001 wrote:

Also, I want more than one thing to fall at once but why does the movieclip currently on screen dissapear when another is put on?


remove:
Code:

this.unloadMovie()
Back to top
View user's profile Send private message AIM Address
Noz3001
I'm a spammer
Reputation: 26

Joined: 29 May 2006
Posts: 6220
Location: /dev/null

PostPosted: Thu Jul 31, 2008 9:19 am    Post subject: Reply with quote

Nope, still no luck. It dissapears when the function is called again.
Back to top
View user's profile Send private message MSN Messenger
merlin22
Master Cheater
Ban
Reputation: 0

Joined: 29 Mar 2008
Posts: 267

PostPosted: Thu Jul 31, 2008 9:52 am    Post subject: Reply with quote

Just change the theme of the game. Have it fall into lava, or something where it is impossible to be retrieved if it falls all the way, and just vanishes.
Back to top
View user's profile Send private message AIM Address
Noz3001
I'm a spammer
Reputation: 26

Joined: 29 May 2006
Posts: 6220
Location: /dev/null

PostPosted: Thu Jul 31, 2008 10:04 am    Post subject: Reply with quote

merlin22 wrote:
Just change the theme of the game. Have it fall into lava, or something where it is impossible to be retrieved if it falls all the way, and just vanishes.


It is supposed to fall all the way offscreen but i would like to spawn more than one movieclip at a time. The current code removes the movieclip when it puts another on.
Back to top
View user's profile Send private message MSN Messenger
merlin22
Master Cheater
Ban
Reputation: 0

Joined: 29 Mar 2008
Posts: 267

PostPosted: Thu Jul 31, 2008 10:33 am    Post subject: Reply with quote

Well.. use the exact same code but for a different object, then you have two objects spawning, and use variables to control the rate of falling, etc.
Back to top
View user's profile Send private message AIM Address
Noz3001
I'm a spammer
Reputation: 26

Joined: 29 May 2006
Posts: 6220
Location: /dev/null

PostPosted: Thu Jul 31, 2008 10:48 am    Post subject: Reply with quote

I wanted to achieve something like this:
http://www.ferryhalim.com/orisinal/g2/applegame.htm

The way the apples fall
Back to top
View user's profile Send private message MSN Messenger
merlin22
Master Cheater
Ban
Reputation: 0

Joined: 29 Mar 2008
Posts: 267

PostPosted: Thu Jul 31, 2008 11:07 am    Post subject: Reply with quote

This will end up being practically the exact same game..

The graphics are up to you, this should be all the code you need for the gameplay.

Code:

_root.timer = 10
_root.score = 0
_root.missed = 0
function SpawnDrop ()
{
   
   var Drop:MovieClip = _root.attachMovie("lol", "Drop",+_root.getNextHighestDepth, _root.getNextHighestDepth)
   Drop._x = Math.random()*Stage.width;
   Drop._y = 0;
   
   
   Drop.onEnterFrame = function() {
  var gravity = 9
 
        this._y += gravity;
       
        if (this.hitTest(_root.catcher))
        {
            _root.score += 1
            this.unloadMovie()
        }
      else if (this._y > 400){
         _root.missed += 1
         this.unloadMovie()
      }
      
   }
   
   

}


onEnterFrame = function() {
_root.timer -= .2
   
if (_root.timer <= 0) {
_root.timer = 10
SpawnDrop();
}
}


catcher.onEnterFrame = function() {
this._x = _xmouse
}


-Put frame rate on 40
-Stage size 550 by 400 pixels
Back to top
View user's profile Send private message AIM Address
Noz3001
I'm a spammer
Reputation: 26

Joined: 29 May 2006
Posts: 6220
Location: /dev/null

PostPosted: Thu Jul 31, 2008 11:16 am    Post subject: Reply with quote

It'll be nothing like that, firstly you have a character which you move around and second 2 of the drops kill you and 2 increase score.
Back to top
View user's profile Send private message MSN Messenger
merlin22
Master Cheater
Ban
Reputation: 0

Joined: 29 Mar 2008
Posts: 267

PostPosted: Thu Jul 31, 2008 11:28 am    Post subject: Reply with quote

This code will drop 4 random objects. I will let you decide what the objects will do, and let you program what will happen if it touches the catcher.

Code:

var drops:Array = new Array("1", "2", "3", "4")
_root.timer = 10
_root.score = 0
_root.missed = 0
function SpawnDrop ()
{
   
   var Drop:MovieClip = _root.attachMovie(drops[Math.round(Math.random()*3)]) , "Drop",+_root.getNextHighestDepth, _root.getNextHighestDepth)
   Drop._x = Math.random()*Stage.width;
   Drop._y = 0;
   
   
   Drop.onEnterFrame = function() {
  var gravity = 9
 
        this._y += gravity;
       
        if (this.hitTest(_root.catcher))
        {
            _root.score += 1
            this.unloadMovie()
        }
      else if (this._y > 400){
         _root.missed += 1
         this.unloadMovie()
      }
       
   }
   
   

}


onEnterFrame = function() {
_root.timer -= .2
   
if (_root.timer <= 0) {
_root.timer = 10
SpawnDrop();
}
}


catcher.onEnterFrame = function() {
this._x = _xmouse
}
Back to top
View user's profile Send private message AIM Address
Noz3001
I'm a spammer
Reputation: 26

Joined: 29 May 2006
Posts: 6220
Location: /dev/null

PostPosted: Thu Jul 31, 2008 12:08 pm    Post subject: Reply with quote

I've tried everything. It just isn't working out.

Look at the attached image, it might show what im trying to do.

The star at the top stays still until the next one is drawn and then it disappears.
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites