Quote: "Any chance you can show us?"
It's lengthy as but here it is.
// main.agc
InitalSetup()
Type Shape
img as integer
spr as integer
EndType
Shapes as Shape[63]
GoSub InitalVariables
GoSub LoadGameMusic
GoSub LoadSounds
GoSub LoadFonts
GoSub LoadBackground
GoSub LoadUI
GoSub LoadShapes
GoSub CreateSprites
GoSub CreateLabels
// media.agc
LoadGameMusic:
// Load menu and game music
Return
LoadSounds:
// Load menu and game sounds
sndPlaceShape = LoadSound( "Assets/Sounds/Place-Shape.wav" )
Return
LoadFonts:
// Load Game Font
imgBlackArcade = LoadImage( "Assets/Fonts/Black-Arcade.png" )
imgWhiteArcade = LoadImage( "Assets/Fonts/White-Arcade.png" )
SetTextDefaultFontImage( imgBlackArcade )
Return
LoadBackground:
// Load Game Backgrounds
imgBackground = LoadImage( "Assets/Backgrounds/Default.png" )
sprBackground = CreateSprite( imgBackground )
Return
LoadUI:
//Load UI Elements
imgTimerBack = LoadImage( "Assets/UI/Timer-Bar-Back.png" )
imgTimerFront = LoadImage( "Assets/UI/Timer-Bar-Front.png" )
imgGoalLine = LoadImage( "Assets/UI/Black-Goal-Line.png" )
// Create UI Elements
sprTimerBack = CreateSprite( imgTimerBack )
SetSpritePosition( sprTimerBack, 0, 1100 )
SetSpritePhysicsOn( sprTimerBack, 1 )
SprTimerFront = CreateSprite( imgTimerFront )
SetSpritePosition( sprTimerFront, 0, 1100 )
sprGoalLine = CreateSprite( imgGoalLine )
SetSpritePosition( sprGoalLine, 0, rnd )
Return
LoadShapes:
// Load Octagon Images
Shapes[0].img = LoadImage( "Assets/Sprites/Octagons/Black-Octagon-Edged.png" )
Shapes[1].img = LoadImage( "Assets/Sprites/Octagons/Black-Octagon-Rounded.png" )
Shapes[2].img = LoadImage( "Assets/Sprites/Octagons/Blue-Octagon-Edged.png" )
Shapes[3].img = LoadImage( "Assets/Sprites/Octagons/Blue-Octagon-Rounded.png" )
Shapes[4].img = LoadImage( "Assets/Sprites/Octagons/Cyan-Octagon-Edged.png" )
Shapes[5].img = LoadImage( "Assets/Sprites/Octagons/Cyan-Octagon-Rounded.png" )
Shapes[6].img = LoadImage( "Assets/Sprites/Octagons/Green-Octagon-Edged.png" )
Shapes[7].img = LoadImage( "Assets/Sprites/Octagons/Green-Octagon-Rounded.png" )
Shapes[8].img = LoadImage( "Assets/Sprites/Octagons/Orange-Octagon-Edged.png" )
Shapes[9].img = LoadImage( "Assets/Sprites/Octagons/Orange-Octagon-Rounded.png" )
Shapes[10].img = LoadImage( "Assets/Sprites/Octagons/Purple-Octagon-Edged.png" )
Shapes[11].img = LoadImage( "Assets/Sprites/Octagons/Purple-Octagon-Rounded.png" )
Shapes[12].img = LoadImage( "Assets/Sprites/Octagons/White-Octagon-Edged.png" )
Shapes[13].img = LoadImage( "Assets/Sprites/Octagons/White-Octagon-Rounded.png" )
Shapes[14].img = LoadImage( "Assets/Sprites/Octagons/Yellow-Octagon-Edged.png" )
Shapes[15].img = LoadImage( "Assets/Sprites/Octagons/Yellow-Octagon-Rounded.png" )
//Load Rectangle Images
Shapes[16].img = LoadImage( "Assets/Sprites/Rectangles/Black-Rectangle-Horizontal.png" )
Shapes[17].img = LoadImage( "Assets/Sprites/Rectangles/Black-Rectangle-Vertical.png" )
Shapes[18].img = LoadImage( "Assets/Sprites/Rectangles/Blue-Rectangle-Horizontal.png" )
Shapes[19].img = LoadImage( "Assets/Sprites/Rectangles/Blue-Rectangle-Vertical.png" )
Shapes[20].img = LoadImage( "Assets/Sprites/Rectangles/Cyan-Rectangle-Horizontal.png" )
Shapes[21].img = LoadImage( "Assets/Sprites/Rectangles/Cyan-Rectangle-Vertical.png" )
Shapes[22].img = LoadImage( "Assets/Sprites/Rectangles/Green-Rectangle-Horizontal.png" )
Shapes[23].img = LoadImage( "Assets/Sprites/Rectangles/Green-Rectangle-Vertical.png" )
Shapes[24].img = LoadImage( "Assets/Sprites/Rectangles/Orange-Rectangle-Horizontal.png" )
Shapes[25].img = LoadImage( "Assets/Sprites/Rectangles/Orange-Rectangle-Vertical.png" )
Shapes[26].img = LoadImage( "Assets/Sprites/Rectangles/Purple-Rectangle-Horizontal.png" )
Shapes[27].img = LoadImage( "Assets/Sprites/Rectangles/Purple-Rectangle-Vertical.png" )
Shapes[28].img = LoadImage( "Assets/Sprites/Rectangles/White-Rectangle-Horizontal.png" )
Shapes[29].img = LoadImage( "Assets/Sprites/Rectangles/White-Rectangle-Vertical.png" )
Shapes[30].img = LoadImage( "Assets/Sprites/Rectangles/Yellow-Rectangle-Horizontal.png" )
Shapes[31].img = LoadImage( "Assets/Sprites/Rectangles/Yellow-Rectangle-Vertical.png" )
//Load Square Images
Shapes[32].img = LoadImage( "Assets/Sprites/Squares/Black-Square-Large.png" )
Shapes[33].img = LoadImage( "Assets/Sprites/Squares/Black-Square-Medium.png" )
Shapes[34].img = LoadImage( "Assets/Sprites/Squares/Blue-Square-Large.png" )
Shapes[35].img = LoadImage( "Assets/Sprites/Squares/Blue-Square-Medium.png" )
Shapes[36].img = LoadImage( "Assets/Sprites/Squares/Cyan-Square-Large.png" )
Shapes[37].img = LoadImage( "Assets/Sprites/Squares/Cyan-Square-Medium.png" )
Shapes[38].img = LoadImage( "Assets/Sprites/Squares/Green-Square-Large.png" )
Shapes[39].img = LoadImage( "Assets/Sprites/Squares/Green-Square-Medium.png" )
Shapes[40].img = LoadImage( "Assets/Sprites/Squares/Orange-Square-Large.png" )
Shapes[41].img = LoadImage( "Assets/Sprites/Squares/Orange-Square-Medium.png" )
Shapes[42].img = LoadImage( "Assets/Sprites/Squares/Purple-Square-Large.png" )
Shapes[43].img = LoadImage( "Assets/Sprites/Squares/Purple-Square-Medium.png" )
Shapes[44].img = LoadImage( "Assets/Sprites/Squares/White-Square-Large.png" )
Shapes[45].img = LoadImage( "Assets/Sprites/Squares/White-Square-Medium.png" )
Shapes[46].img = LoadImage( "Assets/Sprites/Squares/Yellow-Square-Large.png" )
Shapes[47].img = LoadImage( "Assets/Sprites/Squares/Yellow-Square-Medium.png" )
//Load Trapezoid Images
Shapes[48].img = LoadImage( "Assets/Sprites/Trapezoids/Black-Trapezium-Small.png" )
Shapes[49].img = LoadImage( "Assets/Sprites/Trapezoids/Black-Trapezium-Tall.png" )
Shapes[50].img = LoadImage( "Assets/Sprites/Trapezoids/Blue-Trapezium-Small.png" )
Shapes[51].img = LoadImage( "Assets/Sprites/Trapezoids/Blue-Trapezium-Tall.png" )
Shapes[52].img = LoadImage( "Assets/Sprites/Trapezoids/Cyan-Trapezium-Small.png" )
Shapes[53].img = LoadImage( "Assets/Sprites/Trapezoids/Cyan-Trapezium-Tall.png" )
Shapes[54].img = LoadImage( "Assets/Sprites/Trapezoids/Green-Trapezium-Small.png" )
Shapes[55].img = LoadImage( "Assets/Sprites/Trapezoids/Green-Trapezium-Tall.png" )
Shapes[56].img = LoadImage( "Assets/Sprites/Trapezoids/Orange-Trapezium-Small.png" )
Shapes[57].img = LoadImage( "Assets/Sprites/Trapezoids/Orange-Trapezium-Tall.png" )
Shapes[58].img = LoadImage( "Assets/Sprites/Trapezoids/Purple-Trapezium-Small.png" )
Shapes[59].img = LoadImage( "Assets/Sprites/Trapezoids/Purple-Trapezium-Tall.png" )
Shapes[60].img = LoadImage( "Assets/Sprites/Trapezoids/White-Trapezium-Small.png" )
Shapes[61].img = LoadImage( "Assets/Sprites/Trapezoids/White-Trapezium-Tall.png" )
Shapes[62].img = LoadImage( "Assets/Sprites/Trapezoids/Yellow-Trapezium-Small.png" )
Shapes[63].img = LoadImage( "Assets/Sprites/Trapezoids/Yellow-Trapezium-Tall.png" )
Return
CreateSprites:
// Create Shapes Sprites -- Added extra code for testing ( DELETE LONG LINE )
For i = 0 to 63
Shapes[i].spr = CreateSprite( Shapes[i].img )
SetSpriteOffset( Shapes[i].spr, ShapeWidth( Shapes, i ), ShapeHeight( Shapes, i ) )
SetSpriteScaleByOffset( Shapes[i].spr, 1.5, 1.5 )
SetSpriteVisible( Shapes[i].spr, 0 )
Next i
// Create Next Shape
imgNext = 0
sprNext = CreateSprite( 0 )
SetSpriteOffset( sprNext, GetSpriteWidth( sprNext )/2, GetSpriteHeight( sprNext )/2 )
SetSpritePositionByOffset( sprNext, 60, 60 )
Return
CreateLabels:
txtTimeText = CreateText( "0" )
SetTextSize( txtTimeText, 20 )
SetTextPosition( txtTimeText, 20, 20 )
txtGoalLine = CreateText( "Goal Line" )
SetTextSize( txtGoalLine, 20 )
SetTextPosition( txtGoalLine, 440, rnd - 40 )
Return
Function ShapeHeight( shape as Shape[], i as integer )
// Function gets the height of a shape and halves the number
height = GetSpriteHeight( shape[i].spr )/2
Endfunction height
Function ShapeWidth( shape as Shape[], i as integer )
// Function gets the width of a shape and halves the number
width = GetSpriteWidth( shape[i].spr )/2
Endfunction width
As for your second question:
// main.agc *****Inside Do Loop*****
ShapeNumber = GetTimer( Shapes, sprTimerFront, txtTimeText, ShapeNumber )
ShapeNumber = PlaceShape( Shapes, sprTimerFront, txtTimeText, sndPlaceShape, ShapeNumber )
NextShape( Shapes, sprNext, ShapeNumber )
timer.agc
// THIS CODE IS TEMPORARY WHILST TESTING
Function GetTimer( shape as Shape[], spr, txt, num )
time = Timer() // Couldn't figure out why timer doesn't tick without this being inside the loop
if ( time <= 41 )
SetSpriteSize( spr, 640 - ( time * 16 ), 100 )
else
ResetTimer() // Left this in because of the "time = Timer()" issue, will deal with later
SetShapesNotVisible( shape )
num = 0
endif
SetTextString( txt, "Timer: " + str( 41 - time ) )
EndFunction num // Function can only return a single value, my suspension suggests that i need to return time in order for "time = Timer()" issue to work.
And finally, here is where I put my GetTimer() function:
shapes.agc
Function PlaceShape( shape as Shape[], spr, txt, snd, num )
While ( GetPointerState() = 1 )
GetTimer( shape, spr, txt, num )
DrawEllipse( GetPointerX(), GetPointerY(), 10, 10, 0, 0, 1)
DrawLine( GetPointerX(), GetPointerY(), GetPointerX(), 1100, 0, 0, 0 )
if ( num < 64 )
SetSpritePhysicsOff( shape[num].spr )
SetSpriteScaleByOffset( shape[num].spr, 3, 3 )
SetSpriteVisible( shape[num].spr, 1 )
SetSpriteColorAlpha( shape[num].spr, 100 )
SetSpritePositionByOffset( shape[num].spr, GetPointerX(), GetPointerY() )
endif
Sync()
EndWhile
if ( GetPointerReleased() = 1 )
if ( num < 64 )
PlaySound( snd )
SetSpriteScaleByOffset( shape[num].spr, 1.5, 1.5 )
SetSpritePhysicsOn( shape[num].spr, 2 )
SetSpriteColorAlpha( shape[num].spr, 255 )
num = num + 1
endif
endif
EndFunction num
Quote: " I personally create type 'objects' "
That's incredibly helpful, I'm use to C# and creating objects. The agk language makes it way too easy to collect bad habits.
Real programmers don't comment their code, because if it was hard to write it must be hard to read!
- PixHil Entertainment
Download Pixel Smasher on the App Store today!