djice555
3 posts
|
Topic: Game Programming /
[Kongregate API] High Scores
how do i integrate the scores in as3 if im using seperate as class files
|
djice555
3 posts
|
Topic: Game Programming /
[Kongregate API] High Scores
hi im working in as3
wat am i doing wrong
the ghost serv er works but the site won’t do it
heres what i have so far
package
{
import flash.display.MovieClip
import flash.ui.Mouse
import flash.events.*
import flash.events.ProgressEvent
import flash.display.SimpleButton
import com.kongregate.as3.client.KongregateAPI
public class DocumentClass extends MovieClip
{
public var playScreen:ShapeFrogger;
public var gameOver:GameOver;
public var niceOne:NiceOne;
public var i:Number=1
public var menuScreen:MenuScreen
public var kongregate:KongregateAPI
public var upgradeScreen2:upgradeScreen
public var frogSpeed:Number
public var nEL:notEnoughLvls
public var carSpeed:Number
public var upgradePressed:Boolean
public function DocumentClass()
{
upgradePressed=false
carSpeed=0
frogSpeed=.5
kongregate = new KongregateAPI();
addChild(kongregate)
menuScreen=new MenuScreen
menuScreen.addEventListener(NavigationEvent.START, gameStart)
menuScreen.addEventListener(NavigationEvent.COOL, Alright)
menuScreen.x=0
menuScreen.y=0
addChild(menuScreen)
}
public function gameStart(navigationEvent:NavigationEvent):void
{
playScreen=new ShapeFrogger();
playScreen.addEventListener(AvatarEvent.DEAD, onAvatarDeath);
playScreen.addEventListener(AvatarEvent.SAFE, onAvatarSafe);
addChild(playScreen);
playScreen.x=0
playScreen.y=0
playScreen.carSpeed=Math.random() * .05
playScreen.gameScore.setValue(1)
stage.stageFocusRect=false
removeChild(menuScreen)
stage.focus=playScreen.car3
}
public function onAvatarDeath(avatarEvent:AvatarEvent):void
{
gameOver=new GameOver();
gameOver.addEventListener(NavigationEvent.RESTART, onRequestRestart);
addChild(gameOver)
removeChild(playScreen)
kongregate.scores.submit(i)
}
public function reboot()
{
i=1
menuScreen=new MenuScreen
menuScreen.addEventListener(NavigationEvent.START, gameStart)
menuScreen.addEventListener(NavigationEvent.COOL, Alright)
menuScreen.x=0
menuScreen.y=0
addChild(menuScreen)
removeChild (gameOver)
stage.focus= menuScreen
}
public function NextLevel(navigationEvent:NavigationEvent):void
{
playScreen=new ShapeFrogger();
playScreen.addEventListener(AvatarEvent.DEAD, onAvatarDeath);
playScreen.addEventListener(AvatarEvent.SAFE, onAvatarSafe);
playScreen.x=0
playScreen.y=0
addChild(playScreen);
playScreen.frog.speed=frogSpeed
playScreen.car2.car2speed+=carSpeed
playScreen.car3.car3speed+=carSpeed
playScreen.car4.car4speed+=carSpeed
playScreen.car5.car5speed+=carSpeed
playScreen.car6.car6speed+=carSpeed
playScreen.car7.car7speed+=carSpeed
playScreen.car8.car8speed+=carSpeed
playScreen.car9.car9speed+=carSpeed
playScreen.carSpeed=Math.random() * (i / 10)
playScreen.gameScore.setValue(i+1)
i++
removeChild (niceOne)
if (upgradePressed==true)
{
removeChild (upgradeScreen2)
upgradePressed=false
}
stage.focus=playScreen
}
public function onRequestRestart(navigationEvent:NavigationEvent):void
{
reboot();
}
public function onAvatarSafe(avatarEvent:AvatarEvent)
{
niceOne=new NiceOne()
niceOne.addEventListener(NavigationEvent.NEXTLVL, NextLevel)
niceOne.addEventListener(NavigationEvent.UPGRADE, upgrade)
addChild (niceOne)
removeChild (playScreen)
}
public function Alright(navigationEvent:NavigationEvent)
{
i=100000
playScreen=new ShapeFrogger();
playScreen.frog.speed=10
playScreen.addEventListener(AvatarEvent.DEAD, onAvatarDeath);
playScreen.addEventListener(AvatarEvent.SAFE, onAvatarSafeHaHa);
addChild(playScreen);
playScreen.x=0
playScreen.y=0
playScreen.carSpeed=Math.random() * 0
playScreen.gameScore.setValue(-1)
playScreen.gameScore.isPatPlaying=true
stage.stageFocusRect=false
removeChild(menuScreen)
}
public function onAvatarSafeHaHa(avatarEvent:AvatarEvent)
{
niceOne=new NiceOne()
niceOne.addEventListener(NavigationEvent.NEXTLVL, SpecialNextLevel)
niceOne.addEventListener(NavigationEvent.UPGRADE, upgrade)
addChild (niceOne)
removeChild (playScreen)
}
public function SpecialNextLevel(navigationEvent:NavigationEvent)
{
playScreen=new ShapeFrogger();
playScreen.addEventListener(AvatarEvent.DEAD, onAvatarDeath);
playScreen.addEventListener(AvatarEvent.SAFE, onAvatarSafeHaHa);
playScreen.x=0
playScreen.y=0
addChild(playScreen);
playScreen.carSpeed=Math.random() * 0
playScreen.gameScore.setValue(-1)
i++
playScreen.frog.speed=5
removeChild (niceOne)
stage.focus=playScreen
}
public function upgrade(navigationEvent:NavigationEvent)
{
upgradePressed=true
upgradeScreen2=new upgradeScreen()
upgradeScreen2.addEventListener(NavigationEvent.NEXTLVL, NextLevel)
upgradeScreen2.addEventListener(NavigationEvent.FASTER, faster)
upgradeScreen2.addEventListener(NavigationEvent.SLOWER, slower)
upgradeScreen2.addEventListener(NavigationEvent.PIC, pic)
addChild(upgradeScreen2)
}
public function faster(navEvent:NavigationEvent):void
{
if (i>4)
{
frogSpeed=1
}
else
{
nEL=new notEnoughLvls()
addChild(nEL)
nEL.x=0
nEL.y=0
nEL.addEventListener(MouseEvent.CLICK, onClickReturn)
}
}
public function onClickReturn(me:MouseEvent)
{
removeChild(nEL)
}
public function slower(navEvent:NavigationEvent)
{
if (i>9)
{
carSpeed=-1
}
else
{
nEL=new notEnoughLvls()
addChild(nEL)
nEL.x=0
nEL.y=0
nEL.addEventListener(MouseEvent.CLICK, onClickReturn)
}
}
public function pic(navEvent:NavigationEvent)
{
nEL=new notEnoughLvls()
addChild(nEL)
nEL.x=0
nEL.y=0
nEL.addEventListener(MouseEvent.CLICK, onClickReturn)
}
}
}
|