Languages & Coding > AGK

AGK includes...

(1/4) > >>

therevills:
So I'm playing with AGK and trying to have a nice clean approach with files using includes... but I cant get my "colours" working when defined in another file. The code compiles, but the box doesnt have a colour assigned, if I define them in main.agc it works  ???

Any ideas?

Files:

* main.agc
* includes.agc
* functions.agc
* constants.agc
* colors.agc
main.agc:

--- Code: ---#include "includes.agc"

Init("Testing AGK", 1024, 768)

type BoxType
x as integer
y as integer
w as integer
h as integer
color as integer
endtype

box as BoxType
box.x = Random(0, 1000)
box.y = Random(0, 700)
box.w = Random(10, 100)
box.h = Random(10, 100)
box.color = red

do
DrawBox(box.x, box.y, box.x + box.w, box.y + box.h, box.color, box.color, box.color, box.color, TRUE)
Sync()
loop

--- End code ---

includes.agc

--- Code: ---#include "common/constants.agc"
#include "common/functions.agc"
#include "colors.agc"
--- End code ---

functions.agc

--- Code: ---function Init(name as string, width as integer, height as integer)
// show all errors
SetErrorMode(2)

// set window properties
SetWindowTitle(name)
SetWindowSize(width, height, FALSE)
SetWindowAllowResize(TRUE) // allow the user to resize the window

// set display properties
SetVirtualResolution(1024, 768) // doesn't have to match the window
SetOrientationAllowed(TRUE, TRUE, TRUE, TRUE) // allow both portrait and landscape on mobile devices
SetSyncRate(30, 0) // 30fps instead of 60 to save battery
SetScissor(0, 0, 0, 0) // use the maximum available screen space, no black borders
UseNewDefaultFonts(TRUE)
endfunction
--- End code ---

constants.agc

--- Code: ---#constant FALSE 0
#constant TRUE 1

--- End code ---

colors.agc

--- Code: ---red = MakeColor( 255, 0, 0 )
green = MakeColor( 0, 255, 0 )
blue = MakeColor( 0, 0, 255 )
--- End code ---

Steve Elliott:
Use a constant and it works.


--- Quote ---#Constant red = MakeColor( 255, 0, 0 )

--- End quote ---

Qube:
Don't use #Include, it's evil as it can add the code anywhere :o

Use #Insert which places the code exactly at that spot. <<<--- top tip of the day ;D

Steve Elliott:
https://www.appgamekit.com/documentation/language/36_insert.htm

Amon.:
Dude, this better be the beginning of a diddy framework for agk...... :)
A scene manager would be the bizniz.

Navigation

[0] Message Index

[#] Next page

Go to full version