This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // env, kit 為 server 暴露給開發者用的功能物件 | |
| var sys = kit.sys; // 服務管理工具 | |
| var game = kit.game; // 遊戲邏輯工具 | |
| var db = kit.db; // 資料永續儲存介面 | |
| var mem = kit.sharedmem; // shared variable, 跨多個 logic files | |
| var data_ = {}; // user defined local variable | |
| /* | |
| * 1. 覆寫遊戲服務的管理事件, 如 start, stop 等, 沒寫的話 server 會用內建版本 | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- suppose you have a Vec2 and Vec3 type, and a T type which will use them accordingly | |
| -- The Class information should be available out side of this file scope, e.g | |
| -- require 'Vec2' | |
| -- require 'Vec3' | |
| -- require 'Class_with_dimension' | |
| -- I wrote it down here just for simplification | |
| local Vec2 = {} | |
| function Vec2:new(x, y) return setmetatable({x, y}, {__index = self}) end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //igdshare 110220: code provided by hsufong | |
| private int saveGameData(int fIndex){ | |
| String saveFileName = "/data/data/com.mobile_sango/sangoSave"+fIndex+".bin"; | |
| String description = setSaveDescription(); | |
| FileOutputStream fosFile; | |
| OutputStream fosDes; | |
| File saveFile = new File(saveFileName); | |
| if (!saveFile.exists()){ | |
| try { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //igdshare 110220: code provided by hsufong | |
| class MainPlan extends SurfaceView implements SurfaceHolder.Callback { | |
| private DrawPlanThread drawplanThread; | |
| public MainPlan(Context context) { | |
| super(context); | |
| getHolder().addCallback(this); | |
| drawplanThread = new DrawPlanThread(getHolder(), this); | |
| } | |
| private boolean XYInRect(int fX,int fY,Rect fRect){ | |
| boolean tInside = false; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Game:process_dropping(now_t, last_t) | |
| self.cubes:for2d(function(c) | |
| if c:is_waiting() then | |
| if self:is_below_empty(c) then | |
| drop_cube_logical(c, self.cubes) | |
| drop_cube(c, now_t, last_t) | |
| end | |
| elseif c:is_dropping() then | |
| drop_cube(c, now_t, last_t) | |
| if c:arrived_at_logical_position() then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <cstdio> | |
| #include <cstdlib> | |
| extern "C" { | |
| #include "lua.h" | |
| #include "lauxlib.h" | |
| #include "lualib.h" | |
| #include "luajit.h" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local ffi = require 'ffi' | |
| local C = ffi.C | |
| ffi.cdef[[ | |
| typedef struct Simple Simple; | |
| Simple *Simple_Simple(int); | |
| void Simple__gc(Simple *); | |
| int Simple_id(Simple *); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <cstdio> | |
| #include <cstdlib> | |
| extern "C" { | |
| #include "lua.h" | |
| #include "lauxlib.h" | |
| #include "lualib.h" | |
| #include "luajit.h" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local input = arg[1] | |
| math.randomseed(os.time()) | |
| local function random(n) return math.floor(math.random()*n) end | |
| local function chararray(w) | |
| local t = {}; | |
| for i = 1, #w do t[i] = w:sub(i,i) end | |
| return t | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local counter = 0 | |
| local function proc1() | |
| while counter < 100000000 do | |
| counter = counter + 1 | |
| coroutine.yield() | |
| end | |
| end | |
| local function proc2() |