Posted: 14th Sep 2011 4:45
We've got 'em for DBPro, so how's about community challenges for AppGameKit?

Here's one to start... take this code and run with it!

+ Code Snippet
SetVirtualResolution(480, 640)
AddVirtualJoystick (1, 85, 560, 150)

for star = 1 to 100
    starSize = Random(1,3)
    tempSpr = CreateSprite(0)
    SetSpriteSize(tempSpr, starSize, starSize)
    SetSpritePosition(tempSpr, Random(0, 480), Random(0, 480))
    SetSpriteDepth(tempSpr, 15)
next star

groundSpr = CreateSprite(0)
SetSpriteColor(groundSpr, 155, 155, 155, 255)
SetSpriteSize(groundSpr, 480, 250)
SetSpritePosition(groundSpr, 0, 480)
SetSpriteShape(groundSpr, 2)
SetSpritePhysicsOn(groundSpr, 1)
SetSpritePhysicsMass(groundSpr, 100000)

hillSpr1 = CreateSprite(0)
SetSpriteColor(hillSpr1, 125, 125, 125, 255)
SetSpriteSize(hillSpr1, 320, 240)
SetSpritePosition(hillSpr1, 260, 400 + Random(0, 50))
SetSpriteDepth(hillSpr1, 12)
SetSpriteAngle(hillSpr1, 35.0 + Random(0, 20.0))
SetSpriteShape(hillSpr1, 2)
SetSpritePhysicsOn(hillSpr1, 1)

hillSpr2 = CreateSprite(0)
SetSpriteColor(hillSpr2, 125, 125, 125, 255)
SetSpriteSize(hillSpr2, 320, 240)
SetSpritePosition(hillSpr2, -180, 400 + Random(0, 50))
SetSpriteDepth(hillSpr2, 12)
SetSpriteAngle(hillSpr2, -35.0 + Random(0, 20.0))
SetSpriteShape(hillSpr2, 2)
SetSpritePhysicsOn(hillSpr2, 1)

landerSpr = CreateSprite(0)
SetSpriteSize(landerSpr, 32, 32)
SetSpritePosition(landerSpr, 320, 0)
SetSpriteOffset(landerSpr, GetSpriteWidth(landerSpr)/2, GetSpriteHeight(landerSpr)/2)
SetSpriteShape(landerSpr, 2)
SetSpritePhysicsOn(landerSpr, 2)
SetSpritePhysicsCanRotate(landerSpr, 0)
SetSpritePhysicsRestitution(landerSpr, 0.5)

leftLeg = CloneSprite(landerSpr)
SetSpriteSize(leftLeg, 18, 8)
SetSpritePosition(leftLeg, 308, 32)
SetSpriteShape(leftLeg, 2)
SetSpritePhysicsOn(leftLeg, 2)
SetSpritePhysicsCanRotate(leftLeg, 0)
SetSpritePhysicsRestitution(leftLeg, 0.5)
leftJoint = CreateRevoluteJoint(landerSpr, leftLeg, 0, 0, 0)

rightLeg = CloneSprite(leftLeg)
SetSpritePosition(rightLeg, 346, 32)
SetSpriteShape(rightLeg, 2)
SetSpritePhysicsOn(rightLeg, 2)
SetSpritePhysicsCanRotate(rightLeg, 0)
SetSpritePhysicsRestitution(rightLeg, 0.5)
rightJoint = CreateRevoluteJoint(landerSpr, rightLeg, 0, 0, 0)

SetSpritePhysicsMass(landerSpr, 40.0)
SetSpritePositionByOffset(landerSpr, 223.0, 0.0)

SetTextDefaultFontImage(LoadImage("Arial.png"))
altitudeTxt = CreateText("")
altitudeShadowTxt = CreateText("")
SetTextSize(altitudeTxt, 30)
SetTextSize(altitudeShadowTxt, 30)
SetTextPosition(altitudeTxt, 180, 530)
SetTextPosition(altitudeShadowTxt, 182, 532)
SetTextDepth(altitudeTxt, 0)
SetTextDepth(altitudeShadowTxt, 1)
SetTextColor(altitudeTxt, 255, 255, 255, 255)
SetTextColor(altitudeShadowTxt, 0, 0, 0, 255)

forceAdded = 5000.0

do
    x# = GetVirtualJoystickX(1)
    y# = GetVirtualJoystickY(1)
    SetTextString(altitudeTxt, "Altitude: " + (str(abs(GetSpriteYByOffset(landerSpr) - 455.9), 1)))
    SetTextString(altitudeShadowTxt, "Altitude: " + (str(abs(GetSpriteYByOffset(landerSpr) - 455.9), 1)))

    if GetParticlesExists(jetPrt)
        SetParticlesPosition(jetPrt, GetSpriteXByOffset(landerSpr), GetSpriteYByOffset(landerSpr) + 16)
    endif

    if GetParticlesExists(rightJetPrt)
        SetParticlesPosition(rightJetPrt, GetSpriteXByOffset(landerSpr) + 16, GetSpriteYByOffset(landerSpr))
    endif

    if GetParticlesExists(leftJetPrt)
        SetParticlesPosition(leftJetPrt, GetSpriteXByOffset(landerSpr) - 16, GetSpriteYByOffset(landerSpr))
    endif

    if x# < -0.3
        SetSpritePhysicsForce(landerSpr, GetSpriteXByOffset(landerSpr), GetSpriteYByOffset(landerSpr), -1.0 * forceAdded, 0)
        if rightJetFlag = 0
            rightJetPrt = CreateParticles(GetSpriteXByOffset(landerSpr) + 16, GetSpriteYByOffset(landerSpr))
            SetParticlesSize(rightJetPrt, 6)
            SetParticlesAngle(rightJetPrt, 25.0)
            SetParticlesDirection(rightJetPrt, 100.0, 0)
            SetParticlesFrequency(rightJetPrt, 60.0)
            SetParticlesLife(rightJetPrt, 0.2)
            SetParticlesDepth(rightJetPrt, 11)
            AddParticlesColorKeyFrame(rightJetPrt, 0.0, 255, 255, 255, 155)
            AddParticlesColorKeyFrame(rightJetPrt, 0.2, 255, 255, 255, 0)
            SetParticlesColorInterpolation(rightJetPrt, 1)
            rightJetFlag = 1
        endif
    else
        DeleteParticles(rightJetPrt)
        rightJetFlag = 0
    endif

    if x# > 0.3
        SetSpritePhysicsForce(landerSpr, GetSpriteXByOffset(landerSpr), GetSpriteYByOffset(landerSpr), forceAdded, 0)
        if leftJetFlag = 0
            leftJetPrt = CreateParticles(GetSpriteXByOffset(landerSpr) - 16, GetSpriteYByOffset(landerSpr))
            SetParticlesSize(leftJetPrt, 6)
            SetParticlesAngle(leftJetPrt, 25.0)
            SetParticlesDirection(leftJetPrt, -100.0, 0)
            SetParticlesFrequency(leftJetPrt, 60.0)
            SetParticlesLife(leftJetPrt, 0.2)
            SetParticlesDepth(leftJetPrt, 11)
            AddParticlesColorKeyFrame(leftJetPrt, 0.0, 255, 255, 255, 155)
            AddParticlesColorKeyFrame(leftJetPrt, 0.2, 255, 255, 255, 0)
            SetParticlesColorInterpolation(leftJetPrt, 1)
            leftJetFlag = 1
        endif
    else
        DeleteParticles(leftJetPrt)
        leftJetFlag = 0
    endif

    if y# < -0.3
        SetSpritePhysicsForce(landerSpr, GetSpriteXByOffset(landerSpr), GetSpriteYByOffset(landerSpr), 0, -1.0 * forceAdded)
        if jetFlag = 0
            jetPrt = CreateParticles(GetSpriteXByOffset(landerSpr), GetSpriteYByOffset(landerSpr) + 18)
            SetParticlesSize(jetPrt, 6)
            SetParticlesAngle(jetPrt, 25.0)
            SetParticlesDirection(jetPrt, 0.0, 100.0)
            SetParticlesFrequency(jetPrt, 160.0)
            SetParticlesLife(jetPrt, 0.5)
            SetParticlesDepth(jetPrt, 11)
            AddParticlesColorKeyFrame(jetPrt, 0.0, 255, 0, 0, 255)
            AddParticlesColorKeyFrame(jetPrt, 0.3, 255, 255, 0, 50)
            AddParticlesColorKeyFrame(jetPrt, 0.5, 255, 255, 0, 0)
            SetParticlesColorInterpolation(jetPrt, 1)
            jetFlag = 1
        endif
    else
        DeleteParticles(jetPrt)
        jetFlag = 0
    endif

    Sync()
loop


It's the bare bones start on a Lunar Lander game.

What can you do with it?

High scores?
Crash landings?
Limited fuel?
Collision with mountains?
Scrolling background?

It's up to you!

This first AppGameKit Coding Challenge will run until Sunday, September 25th at midnight. I'll judge the entries, and the winner can pick the next challenge.

Let's have some really good entries for Lee to gawk at when he gets back from San Francisco!

Judging criteria:

1. Completeness. How far did you run with the code? Did you make a finished game? Does the player have a goal? Does the player get rewarded for achieving that goal? (40% of score)

2. Originality. Did you make the game your own? Did you put your own unique twist to the code? Is it "your baby"? (20% of score)

3. Shock and Awe. Does the player laugh out loud? Weep like a child? Stare at the screen with a glazed look in their eye, and drool running down their chin? (20% of score)

4. Media. Did you use some cool graphics? Add any sound effects? (20% of score)

Posted: 14th Sep 2011 10:38
Excellent idea Rich! Wish I had time for this, I have some nice ideas what to do with this
Posted: 14th Sep 2011 14:48
darn for some reason this crashes my computer when I try to run it. Anybody else having the same problem?
Posted: 14th Sep 2011 16:17
malospam - your whole computer crashes? Or just the compiler or project when you run it?

I'd hate to think AppGameKit has a sequence of commands that can crash an operating system. Yikes!

Some things to try - are you running the updated AppGameKit? Can you compile and run the physics/Box2D and particles examples that came bundled with AppGameKit? Do you have an older video card or driver?

Hmmm, can't think of anything else right now.
Posted: 14th Sep 2011 17:19
Works fine here.

I've just added a fuel guage that changes colour as you get lower on fuel, and when it's out, that's it. No more thrusting for you!

I've also added a blue button on the screen that you can click to randomise the terrain, reposition the lander and refill the fuel tank.

+ Code Snippet
SetVirtualResolution(480, 640)
AddVirtualJoystick (1, 85, 560, 150)

// new code by Bursar
AddVirtualButton(1, 400, 560, 50)
SetVirtualButtonColor(1, 32, 32, 255)
//

for star = 1 to 100
    starSize = Random(1,3)
    tempSpr = CreateSprite(0)
    SetSpriteSize(tempSpr, starSize, starSize)
    SetSpritePosition(tempSpr, Random(0, 480), Random(0, 480))
    SetSpriteDepth(tempSpr, 15)
next star

groundSpr = CreateSprite(0)
SetSpriteColor(groundSpr, 155, 155, 155, 255)
SetSpriteSize(groundSpr, 480, 250)
SetSpritePosition(groundSpr, 0, 480)
SetSpriteShape(groundSpr, 2)
SetSpritePhysicsOn(groundSpr, 1)
SetSpritePhysicsMass(groundSpr, 100000)

hillSpr1 = CreateSprite(0)
SetSpriteColor(hillSpr1, 125, 125, 125, 255)
SetSpriteSize(hillSpr1, 320, 240)
SetSpritePosition(hillSpr1, 260, 400 + Random(0, 50))
SetSpriteDepth(hillSpr1, 12)
SetSpriteAngle(hillSpr1, 35.0 + Random(0, 20.0))
SetSpriteShape(hillSpr1, 2)
SetSpritePhysicsOn(hillSpr1, 1)

hillSpr2 = CreateSprite(0)
SetSpriteColor(hillSpr2, 125, 125, 125, 255)
SetSpriteSize(hillSpr2, 320, 240)
SetSpritePosition(hillSpr2, -180, 400 + Random(0, 50))
SetSpriteDepth(hillSpr2, 12)
SetSpriteAngle(hillSpr2, -35.0 + Random(0, 20.0))
SetSpriteShape(hillSpr2, 2)
SetSpritePhysicsOn(hillSpr2, 1)

landerSpr = CreateSprite(0)
SetSpriteSize(landerSpr, 32, 32)

SetSpriteOffset(landerSpr, GetSpriteWidth(landerSpr)/2, GetSpriteHeight(landerSpr)/2)
SetSpritePosition(landerSpr, 320, 0)
SetSpriteShape(landerSpr, 2)
SetSpritePhysicsOn(landerSpr, 2)
SetSpritePhysicsCanRotate(landerSpr, 0)
SetSpritePhysicsRestitution(landerSpr, 0.5)

leftLeg = CloneSprite(landerSpr)
SetSpriteSize(leftLeg, 18, 8)
SetSpritePosition(leftLeg, 308, 32)
SetSpriteShape(leftLeg, 2)
SetSpritePhysicsOn(leftLeg, 2)
SetSpritePhysicsCanRotate(leftLeg, 0)
SetSpritePhysicsRestitution(leftLeg, 0.5)
leftJoint = CreateRevoluteJoint(landerSpr, leftLeg, 0, 0, 0)

rightLeg = CloneSprite(leftLeg)
SetSpritePosition(rightLeg, 346, 32)
SetSpriteShape(rightLeg, 2)
SetSpritePhysicsOn(rightLeg, 2)
SetSpritePhysicsCanRotate(rightLeg, 0)
SetSpritePhysicsRestitution(rightLeg, 0.5)
rightJoint = CreateRevoluteJoint(landerSpr, rightLeg, 0, 0, 0)

SetSpritePhysicsMass(landerSpr, 40.0)
SetSpritePositionByOffset(landerSpr, 223.0, 0.0)

SetTextDefaultFontImage(LoadImage("Arial.png"))
altitudeTxt = CreateText("")
altitudeShadowTxt = CreateText("")
SetTextSize(altitudeTxt, 30)
SetTextSize(altitudeShadowTxt, 30)
SetTextPosition(altitudeTxt, 180, 530)
SetTextPosition(altitudeShadowTxt, 182, 532)
SetTextDepth(altitudeTxt, 0)
SetTextDepth(altitudeShadowTxt, 1)
SetTextColor(altitudeTxt, 255, 255, 255, 255)
SetTextColor(altitudeShadowTxt, 0, 0, 0, 255)

forceAdded = 5000.0

// Additions By Bursar //
maxFuel = 200
currentFuel = maxFuel

fuelOutLineBox = CreateSprite(0)
SetSpriteSize(fuelOutLineBox, 204, 27)
SetSpriteDepth(fuelOutLineBox, 100)
SetSpritePositionByOffset (fuelOutLineBox, (GetDeviceWidth()/2), (GetSpriteWidth(fuelOutLineBox)/6))

fuelGuage = CreateSprite(0)
SetSpriteSize(fuelGuage, currentFuel*2, 25)
SetSpriteDepth(fuelGuage, 99)
SetSpriteColor(fuelGuage, 0, 255, 0, 255)
SetSpritePositionByOffset (fuelGuage, (GetDeviceWidth()/2), (GetSpriteWidth(fuelOutLineBox)/6))

do
    x# = GetVirtualJoystickX(1)
    y# = GetVirtualJoystickY(1)
    SetTextString(altitudeTxt, "Altitude: " + (str(abs(GetSpriteYByOffset(landerSpr) - 455.9), 1)))
    SetTextString(altitudeShadowTxt, "Altitude: " + (str(abs(GetSpriteYByOffset(landerSpr) - 455.9), 1)))

    if GetParticlesExists(jetPrt)
        SetParticlesPosition(jetPrt, GetSpriteXByOffset(landerSpr), GetSpriteYByOffset(landerSpr) + 16)
    endif

    if GetParticlesExists(rightJetPrt)
        SetParticlesPosition(rightJetPrt, GetSpriteXByOffset(landerSpr) + 16, GetSpriteYByOffset(landerSpr))
    endif

    if GetParticlesExists(leftJetPrt)
        SetParticlesPosition(leftJetPrt, GetSpriteXByOffset(landerSpr) - 16, GetSpriteYByOffset(landerSpr))
    endif

    if x# < -0.3
        If currentFuel > 0
            SetSpritePhysicsForce(landerSpr, GetSpriteXByOffset(landerSpr), GetSpriteYByOffset(landerSpr), -1.0 * forceAdded, 0)

            // new code by Bursar
            currentFuel=currentFuel - 1
            //

            if rightJetFlag = 0 and currentFuel > 0
                rightJetPrt = CreateParticles(GetSpriteXByOffset(landerSpr) + 16, GetSpriteYByOffset(landerSpr))
                SetParticlesSize(rightJetPrt, 6)
                SetParticlesAngle(rightJetPrt, 25.0)
                SetParticlesDirection(rightJetPrt, 100.0, 0)
                SetParticlesFrequency(rightJetPrt, 60.0)
                SetParticlesLife(rightJetPrt, 0.2)
                SetParticlesDepth(rightJetPrt, 11)
                AddParticlesColorKeyFrame(rightJetPrt, 0.0, 255, 255, 255, 155)
                AddParticlesColorKeyFrame(rightJetPrt, 0.2, 255, 255, 255, 0)
                SetParticlesColorInterpolation(rightJetPrt, 1)
                rightJetFlag = 1
            endif
        EndIf
    else
        DeleteParticles(rightJetPrt)
        rightJetFlag = 0
    endif

    if x# > 0.3
        If currentFuel > 0
            SetSpritePhysicsForce(landerSpr, GetSpriteXByOffset(landerSpr), GetSpriteYByOffset(landerSpr), forceAdded, 0)

            // new code by Bursar
            currentFuel=currentFuel - 1
            //

            if leftJetFlag = 0
                leftJetPrt = CreateParticles(GetSpriteXByOffset(landerSpr) - 16, GetSpriteYByOffset(landerSpr))
                SetParticlesSize(leftJetPrt, 6)
                SetParticlesAngle(leftJetPrt, 25.0)
                SetParticlesDirection(leftJetPrt, -100.0, 0)
                SetParticlesFrequency(leftJetPrt, 60.0)
                SetParticlesLife(leftJetPrt, 0.2)
                SetParticlesDepth(leftJetPrt, 11)
                AddParticlesColorKeyFrame(leftJetPrt, 0.0, 255, 255, 255, 155)
                AddParticlesColorKeyFrame(leftJetPrt, 0.2, 255, 255, 255, 0)
                SetParticlesColorInterpolation(leftJetPrt, 1)
                leftJetFlag = 1
            endif
        EndIf
    else
        DeleteParticles(leftJetPrt)
        leftJetFlag = 0
    endif

    if y# < -0.3
        If currentFuel > 0
            SetSpritePhysicsForce(landerSpr, GetSpriteXByOffset(landerSpr), GetSpriteYByOffset(landerSpr), 0, -1.0 * forceAdded)

            // new code by Bursar
            currentFuel=currentFuel - 1
            //

            if jetFlag = 0
                jetPrt = CreateParticles(GetSpriteXByOffset(landerSpr), GetSpriteYByOffset(landerSpr) + 18)
                SetParticlesSize(jetPrt, 6)
                SetParticlesAngle(jetPrt, 25.0)
                SetParticlesDirection(jetPrt, 0.0, 100.0)
                SetParticlesFrequency(jetPrt, 160.0)
                SetParticlesLife(jetPrt, 0.5)
                SetParticlesDepth(jetPrt, 11)
                AddParticlesColorKeyFrame(jetPrt, 0.0, 255, 0, 0, 255)
                AddParticlesColorKeyFrame(jetPrt, 0.3, 255, 255, 0, 50)
                AddParticlesColorKeyFrame(jetPrt, 0.5, 255, 255, 0, 0)
                SetParticlesColorInterpolation(jetPrt, 1)
                jetFlag = 1
            endif
        EndIf

    else
        DeleteParticles(jetPrt)
        jetFlag = 0
    endif

    // new code by Bursar
    If GetVirtualButtonPressed(1) = 1
        SetSpritePosition(hillSpr1, 260, 400 + Random(0, 50))
        SetSpriteAngle(hillSpr1, 35.0 + Random(0, 20.0))
        SetSpritePosition(hillSpr2, -180, 400 + Random(0, 50))
        SetSpriteAngle(hillSpr2, -35.0 + Random(0, 20.0))

        SetSpritePositionByOffset(landerSpr, GetDeviceWidth()/2, 0)
        currentFuel = maxFuel
        SetSpriteColor(fuelGuage, 0, 255, 0, 255)
    EndIf

    SetSpriteSize(fuelGuage, currentFuel, 25)
    SetSpritePosition(fuelGuage, 140, 21.5)
    If currentFuel <= maxFuel/2 Then SetSpriteColor(fuelGuage, 255, 106, 0, 255)
    If currentFuel <= maxFuel/4 Then SetSpriteColor(fuelGuage, 255, 0, 0, 255)
    //

    Sync()
loop

It's not perfect, as if you're thrusting when you run out of fuel, then the particles are still created. Also, the code could be split up into functions to make it more reusable, but it was a 5 minute hack job when the boss wasn't looking
Posted: 15th Sep 2011 17:55
Rich,

Just AppGameKit crashes. Yes, I have run other apps fine, even ones that are graphic and processor intensive and no problems. Graphics card drivers updated (newest NVIDIA about 6 months ago). Strange.....
Posted: 15th Sep 2011 20:25
8th at midnight.


Are you sure about that?
Posted: 15th Sep 2011 20:32
This first AppGameKit Coding Challenge will run until Sunday, August 18th at midnight.


Crapp iam to late

Great idea

Will have to see if i can get the time for this?
Posted: 15th Sep 2011 21:00
Will have to see if i can get the time for this?


Not unless you have a TARDIS...
Posted: 15th Sep 2011 21:01
Well, OOPS!

I meant September 18, of course.

But hey, let's extend the deadline to September 25th, maybe more folks will enter.
Posted: 19th Sep 2011 20:39
No entries yet? C'mon!

Again, the deadline has been extended to September 25th, plenty of time to put your finishing touch on the code I've posted.
Posted: 27th Sep 2011 11:30
Well, Bursar was the only one who posted any code, so YOU WIN, BURSAR!

I guess most folks don't have time for this kind of thing, being busy on their own projects.
Posted: 27th Sep 2011 15:14
I think it was a bit too early to do a competition Rich, I would love to have another one in a few months, when people really get to know AppGameKit, and the system is stable. Maybe an x-mas speccial?
Posted: 27th Sep 2011 15:18
Definatley have another one, christmas themed would be good. Didnt have time to enter the last one.

Coding challenges are a good thing to have.
Posted: 28th Sep 2011 16:44
YOU WIN, BURSAR!

Yay me!

It's normally my luck to come second, even when competing against myself!!

I think a Christmas themed compo is a good idea. Maybe have a list of specific things that can be included to get extra points (but only a maximum of two of the things on the list count for judging purposes).
Posted: 28th Sep 2011 17:02
Maybe have a list of items you MUST add, totally unlogical, items like a fish, an umbrella and a dishwasher machine :-P and see what whacky uses people finds for it in the game
Posted: 18th Oct 2011 15:33
Christmas Themed would be good. That will give me time to finish my game before I do a competition.
The lunar lander game was a good idea though but didn't catch it till now.
Posted: 3rd Nov 2011 0:30
Rich, sorry if this is not OK to post here but there is also a coding competition for AppGameKit basic (and DBPro) with the top prizes being:

1st
-$100 TGC Voucher
-ADG Codemaster Badge (Gold) - For the best code to be used by the winner on the (ADG) forums or in their game art for perpetuity
-5 Hours recording studio time provided by JRNTexas
-Animated sprite pack from TheSlayer
-Bespoke music track from TheSlayer

2nd
-$50 TGC Voucher
-ADG Codemaster Badge (Silver) - For the best code to be used by the winner on the (ADG) forums or in their game art for perpetuity
-500 Lines of bespoke code from baxslash
-Animated sprite pack from TheSlayer

Runners up (x3)
-$20 TGC Voucher
-ADG Codemaster Badge (Bronze) - For the best code to be used by the winner on the (ADG) forums or in their game art for perpetuity
-Full Catalogue of apps from baxslash (including as yet unreleased software)
-Animated sprite pack from TheSlayer

Details can be found here: ADG Coding Competition

Hope you don't mind me posting this here Rich!
Posted: 3rd Nov 2011 7:33
No prob baxslash! Looks like an exciting competition!
Posted: 3rd Nov 2011 12:04
Thanks Rich!