home *** CD-ROM | disk | FTP | other *** search
- class disney.rabbitRivalry.GameCamera extends smashing.keithm.BaseCamera
- {
- var __groundY;
- var __state;
- var __moveRate;
- var __delay;
- var isZooming;
- var __zoomHeadedOut;
- var x;
- var y;
- var z;
- var __zoomTimer;
- var xdiff;
- var ydiff;
- var updateChangeX;
- var updateChangeY;
- var __ZOOM_RATE = 0.03;
- var __ZOOMOUT_POINT = {x:1340,y:850,z:-3500};
- var __MOVE_RATE = 400;
- var __MOVE_DECAY = 100;
- var __Y_OFFSET = 100;
- function GameCamera(t_data)
- {
- super(t_data);
- this.__groundY = t_data.ground;
- this.__state = disney.rabbitRivalry.GameState.getInstance();
- this.__moveRate = this.__MOVE_RATE;
- this.setBounds(0,3550,0,this.__groundY + 60);
- this.__delay = 0;
- this.isZooming = false;
- this.__zoomHeadedOut = true;
- }
- function setDelay(num)
- {
- this.__delay = num;
- }
- function zoomOut()
- {
- this.isZooming = this.__zoomHeadedOut = true;
- this.x -= (this.x - this.__ZOOMOUT_POINT.x) / 2;
- this.y -= (this.y - this.__ZOOMOUT_POINT.y) / 2;
- this.z = this.__ZOOMOUT_POINT.z / 2;
- this.enforceBounds();
- this.__zoomTimer = this.__ZOOM_RATE;
- }
- function zoomIn(player)
- {
- this.x -= (this.x - player.x) / 2;
- this.y -= (this.y - player.y) / 2;
- this.z = this.__ZOOMOUT_POINT.z / 2;
- this.enforceBounds();
- this.__zoomTimer = this.__ZOOM_RATE;
- this.__zoomHeadedOut = false;
- }
- function endZoomOut()
- {
- this.x = this.__ZOOMOUT_POINT.x;
- this.y = this.__ZOOMOUT_POINT.y;
- this.z = this.__ZOOMOUT_POINT.z;
- this.enforceBounds();
- }
- function endZoomIn(player)
- {
- this.x = player.nextX;
- this.y = player.y;
- this.z = 0;
- this.enforceBounds();
- this.isZooming = false;
- }
- function update(dt, player)
- {
- if(this.isZooming)
- {
- if(this.__zoomHeadedOut)
- {
- if(this.__zoomTimer > 0)
- {
- this.__zoomTimer -= dt;
- if(this.__zoomTimer <= 0)
- {
- this.endZoomOut();
- }
- }
- }
- else
- {
- this.__zoomTimer -= dt;
- if(this.__zoomTimer <= 0)
- {
- this.endZoomIn(player);
- }
- }
- }
- else
- {
- if(this.__delay > 0)
- {
- this.__delay -= dt;
- if(this.__delay > 0)
- {
- return undefined;
- }
- this.__moveRate = this.__MOVE_RATE * 3;
- }
- if(this.__moveRate > this.__MOVE_RATE)
- {
- this.__moveRate -= this.__MOVE_DECAY * dt;
- if(this.__moveRate < this.__MOVE_RATE)
- {
- this.__moveRate = this.__MOVE_RATE;
- }
- }
- if(player.isAttacking || player.isCharging)
- {
- this.xdiff = player.nextX + 150 - this.x;
- this.ydiff = player.nextY - this.y - this.__Y_OFFSET;
- }
- else if(this.__state.actionState <= 3)
- {
- this.xdiff = player.nextX - this.x + 60;
- this.ydiff = player.nextY - this.y - this.__Y_OFFSET + 25;
- }
- else
- {
- this.xdiff = player.nextX - this.x;
- this.ydiff = player.nextY - this.y - this.__Y_OFFSET;
- }
- dt *= 2;
- this.updateChangeX = this.updateChangeY = this.__moveRate * dt;
- if(this.xdiff < - this.updateChangeX)
- {
- this.x -= this.updateChangeX;
- }
- else if(this.xdiff > this.updateChangeX)
- {
- this.x += this.updateChangeX;
- }
- else if(player.isAttacking || player.isCharging)
- {
- this.x = player.nextX + 150;
- }
- else if(this.__state.actionState <= 3)
- {
- this.x = player.nextX + 60;
- }
- else
- {
- this.x = player.nextX;
- }
- if(this.ydiff < - this.updateChangeY)
- {
- this.y -= this.updateChangeY;
- }
- else if(this.ydiff > this.updateChangeY)
- {
- this.y += this.updateChangeY;
- }
- else if(this.__state.actionState <= 3)
- {
- this.y = player.nextY - this.__Y_OFFSET + 25;
- }
- else
- {
- this.y = player.nextY - this.__Y_OFFSET;
- }
- }
- this.enforceBounds();
- this.refreshEdges();
- }
- }
-