It's a habit i picked up at work when i had a job
. There was a work experience kid that turned up one day and he started doing that. It seemed to make more sense and sometimes it made the code easier to read so we all started to do it.

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts Menu
//main global script file
int gold;
gold = 300;
export gold;
String goldAsText = String.Format("%d", gold);
export goldAsText;
Quote from: Snarky on Tue 23/09/2014 14:42:39
You don't need a plugin for that. The hardest part is probably to make the physical code wheel. In the game itself, you just need a few arrays of codes, two of sprites, and a random number generator. Something like this (very rough, probably buggy):Code: AGS // Header: #define CODEWHEEL_SIZE 15 #define CODEWHEEL_SLOTS 7 struct CodeSlot { String name; int code[CODEWHEEL_SIZE]; }; struct CodePos { int faceTop; int faceBottom; int slot; import function InitRandom(); import function Check(int code); }; int faceTop[CODEWHEEL_SIZE]; int faceBottom[CODEWHEEL_SIZE]; CodeSlot codeSlot[CODEWHEEL_SLOTS]; // Script: function CodePos::InitRandom() { this.faceTop = Random(CODEWHEEL_SIZE); this.faceBottom = Random(CODEWHEEL_SIZE); this.slot = Random(CODEWHEEL_SLOTS); } function CodePos::Check(int code) { int spin = (this.faceBottom - this.faceTop + CODEWHEEL_SIZE) % CODEWHEEL_SIZE; return int == codeSlot[this.slot].code[spin]; }
Then you just have to populate the CodeSlot arrays with codes (and names) and the faceTop/faceBottom arrays with sprite indexes to match the code wheel. To put up a code challenge on screen, make an instance of CodePos and initialize it, then display the faceTop/faceBottom graphics and the name of the code slot (Antigua, Bermuda, etc.).
By continuing to use this site you agree to the use of cookies. Please visit this page to see exactly how we use these.
Page created in 0.063 seconds with 14 queries.