Skip to content

Instantly share code, notes, and snippets.

@tluyben
tluyben / gist:5472601
Last active December 16, 2015 17:48
Monkey SoundPool repeat trying in a Thread.
// add on top of gxtkAudio
class PlaySampleThread extends Thread {
SoundPool pool;
gxtkSample sample;
gxtkAudio.gxtkChannel chan;
float lv, rv;
int loops;
public PlaySampleThread(SoundPool pool, gxtkSample sample, gxtkAudio.gxtkChannel chan, float lv, float rv, int loops) {
Field parentCache:GuiVector2D
'summary: This returns the rendering position of this control. The result is presented on Device coordinates. (screen pixels)
Method CalculateRenderPosition:GuiVector2D()
If _cacheRenderPosCalcuation = Null Then _cacheRenderPosCalcuation = New GuiVector2D
_cacheRenderPosCalcuation.SetValues (Position.X, Position.Y)
If parentCache = Null
parentCache = New GuiVector2D()
{TRON-LASERBIKES by (c) T.Luyben && J.Straaten 1988, revised for TP7.0 VGA,
THIS GAME IS FREEWARE AND MAY BE COPIED... DO NOT ALTER THIS FILE OR THE
ZIP FILE YOU COPY...
IF YOU CHANGE ANYTHING THEN PLEASE LET ME KNOW! NO PROFIT SHALL BE MADE FROM
THIS LITTLE PROJECT
}
uses crt,dos;
const cdlevel=3; {here you can change the difficulty level; there is a}
Import diddy
Import mojo
Class TestScreen Extends Screen
Method Start:Void()
End
@tluyben
tluyben / GLES return issue
Created March 7, 2013 17:59
OpenPandora GLES return Null for the version; workaround
// Parses the client API version string and extracts the version number
//
static GLboolean parseGLVersion(int* api, int* major, int* minor, int* rev)
{
int i, _api = GLFW_OPENGL_API, _major, _minor = 0, _rev = 0;
const char* version;
const char* prefixes[] =
{
"OpenGL ES-CM ",
"OpenGL ES-CL ",
@tluyben
tluyben / gist:5098910
Created March 6, 2013 12:15
Resize all images in a directory. Images should be of the format xxx_WIDTHxHEIGHT.ext, so bla_2048x1536.png, run as : ./cut50.pl 2048 1536 and all images are resized to 1024x768.
#!/usr/bin/perl
$x = $ARGV[0];
$y = $ARGV[1];
if (not $x or not $y) {
print "./cut50.pl width height\n";
exit;
}
@tluyben
tluyben / gist:5046420
Created February 27, 2013 08:52
Resolution test Monkey
Import mojo
Import diddy
Class TestScreen Extends Screen
Method Start:Void()
End
Method Update:Void()
#!/usr/bin/perl
$f = $ARGV[0];
$pagestart = 0;
$charstart = 0;
$kernstart = 0;
$s = "<?xml version=\"1.0\"?>\n<font>\n";
open(F, $f);
Method DrawWrap(t:String, x:Float, y:Float, width:Float, align:Int = AngelFont.ALIGN_CENTER)
' do some calculations and splitting
Local splits:StringList = New StringList
Local lw := Floor(width / font.TextWidth("W")) ' about how many letters fit in the width?
Local enters:String[] = t.Split("~n")
' check if any split string is too long to fit
For Local i:=0 Until enters.Length
Local s := enters[i]
@tluyben
tluyben / csv Parse
Created February 15, 2013 14:34
Simple Monkey language CVS parser
Method Parse() ' csv parser
Local _inc:Bool = False
Local afc:Bool = False
Local quote:=New Quote
Local c:String, c1:String = ""
raw = raw + "~n" ' make sure we catch the last one
For Local i := 0 To raw.Length
c = raw[i..i+1]
If i+2 < raw.Length
c1 = raw[i+1..i+2]