Skip to content

Instantly share code, notes, and snippets.

@FlyingJester
Created July 28, 2014 08:02
Show Gist options
  • Select an option

  • Save FlyingJester/581a869db053b56d3f20 to your computer and use it in GitHub Desktop.

Select an option

Save FlyingJester/581a869db053b56d3f20 to your computer and use it in GitHub Desktop.
Sapphire BMPFont RFN example
RequireSystemScript("colors.js");
var s = new Surface(64, 64, Black);
var Fonty = GetSystemFont();
s.drawText(Fonty, 0, 0, "Sphere");
s.drawText(Fonty, 4, 16, "Fonts!");
var PointerImage = new Image(s);
var LogoImage = new Image(new Surface("sphere.png"));
var DefaultShader = GetDefaultShaderProgram();
var Vertices1 = [new Vertex(0, 0), new Vertex(64, 0), new Vertex(64, 64), new Vertex(0, 64) ];
var Vertices2 = [new Vertex(64, 0), new Vertex(128,0), new Vertex(128,64), new Vertex(64, 64) ];
var Vertices3 = [new Vertex(128,0), new Vertex(192,0), new Vertex(192,64), new Vertex(128,64) ];
var Vertices4 = [new Vertex(0,128), new Vertex(64,128), new Vertex(64,192), new Vertex(0, 192) ];
var Shape1 = new Shape(Vertices1, PointerImage);
var Shape2 = new Shape(Vertices2, PointerImage);
var Shape3 = new Shape(Vertices3, PointerImage);
var Shape4 = new Shape(Vertices4, PointerImage);
var PointerGroup = new Group([Shape1, Shape2, Shape3, Shape4], DefaultShader);
var LogoShapes =[];
for(var j = 0; j<GetScreenWidth()/32; j++){
var k = j+1;
for(var i = 0; i<GetScreenHeight()/32; i++){
var e = i+1;
var Vertices = [new Vertex(j*32, i*32), new Vertex(k*32, i*32), new Vertex(k*32, e*32), new Vertex(j*32, e*32)];
if(e>GetScreenHeight()/32){
for(var f in Vertices)
Vertices[f].x+=16;
}
LogoShapes.push(new Shape(Vertices, LogoImage));
}
}
var LogoGroup = new Group(LogoShapes, DefaultShader);
var CursorShape = new Shape(Vertices1, PointerImage);
var Cursor = new Group(CursorShape, DefaultShader);
function game(){
var Live = true;
while(Live){
if(AreKeysLeft()){
var k = GetKey();
if(k==KEY_Q)
Live = false;
}
PointerGroup.Draw();
LogoGroup.Draw();
Cursor.setPosition(GetMouseX(), GetMouseY());
Cursor.Draw();
FlipScreen();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment