Skip to content

Instantly share code, notes, and snippets.

View kengonakajima's full-sized avatar
🏠
Working from home

Kengo Nakajima kengonakajima

🏠
Working from home
View GitHub Profile
@kengonakajima
kengonakajima / blogtest.md
Created January 1, 2012 07:55
blog test

これはmdなのか?


AAA

bbb

@kengonakajima
kengonakajima / moai_3d_simple_bench.lua
Created January 8, 2012 00:25
moai 3D simple benchmark from samples/test/cube-3d/main.lua
--[[---
Simple 3D benchmark based on samples/test/cube-3d.
- Video: http://www.youtube.com/watch?v=Fn54jJYw5y8&list=UUtHX3tIuYEScozlr4GqfF1Q
- Machine: macbook pro 2.53GHz i5, NVIDIA GeForce GT 330M 256 MB
- Benchmark spec
- num of props: 150
- cube per prop : 8x8x8 = 512
- total num of triangles: 12 x 512 x 150 = 921K
- frame rate: 60fps
@kengonakajima
kengonakajima / livecoding_menu_20120111.md
Created January 11, 2012 06:36
livecoding menu on 20120111
  • 2D: xevious shooter demo
  • 用意しておいた部分のコピペで説明
  • 敵種類でも追加してみる
  • 3D: three-dee
  • 見るだけ
  • luvit - moai combination via msgpack
  • 説明
  • RPCなんか追加してみる
@kengonakajima
kengonakajima / moai_delay_setTexture.lua
Created January 15, 2012 03:25
Moai: delaying setTexture
----------------------------------------------------------------
-- Copyright (c) 2010-2011 Zipline Games, Inc.
-- All Rights Reserved.
-- http://getmoai.com
----------------------------------------------------------------
MOAISim.openWindow ( "test", 320, 480 )
viewport = MOAIViewport.new ()
viewport:setSize ( 320, 480 )
@kengonakajima
kengonakajima / moai_delay_soundLoad.lua
Created January 15, 2012 21:31
Moai allows delayed audio file loading
----------------------------------------------------------------
-- Copyright (c) 2010-2011 Zipline Games, Inc.
-- All Rights Reserved.
-- http://getmoai.com
----------------------------------------------------------------
MOAISim.openWindow ( "test", 320, 480 )
viewport = MOAIViewport.new ()
viewport:setSize ( 320, 480 )
@kengonakajima
kengonakajima / moai_write_file_in_cachedir.lua
Created January 18, 2012 09:10
moai: exammple of ios cache file writing
if MOAIInputMgr.device.touch then
local path = MOAIEnvironment.getCacheDirectory() .. "/hogehoge.txt"
local f,msg = io.open(path, "wb")
if not f then
error("cannot open file:",msg)
end
f:write(body)
f:close()
end
@kengonakajima
kengonakajima / luvit_oop.lua
Created February 9, 2012 07:15
oop system from luvit
-- OOP system from luvit
local Object = {}
Object.meta = {__index = Object}
function Object:create()
local meta = rawget(self, "meta")
if not meta then error("Cannot inherit from instance object") end
return setmetatable({}, meta)
end
@kengonakajima
kengonakajima / setPenWidth_not_working.lua
Created February 20, 2012 22:30
demonstration of setPenWidth() bug. it is not working.
-- Demonstration of MOAIMesh:setPenWidth(), MOAIGfxDevice.setPenWidth() not-working bug
MOAISim.openWindow ( "test", 320, 480 )
MOAIGfxDevice.setClearDepth ( true )
MOAIGfxDevice.setPenWidth( 5)
viewport = MOAIViewport.new ()
viewport:setSize ( 320, 480 )
viewport:setScale ( 320, 480 )
@kengonakajima
kengonakajima / luvit_net_emu.lua
Created February 22, 2012 23:38
emulate luvit's net module on luasocket (usable for MoaiSDK)
-- luvit net emulator by luasocket.
local socket = require("socket")
function net_connect(ip,port)
print("net_connect called.", ip, port )
local conn = {}
return conn
end
@kengonakajima
kengonakajima / moai_check_within_view_frustum.lua
Created February 24, 2012 09:44
check any object is displayed in the window on MoaiSDK (3d and 2d)
local winx1,winy1 = fieldLayer:worldToWnd(x,y,z)
local winx2,winy2 = fieldLayer:worldToWnd(x+CELLUNITSZ*CHUNKSZ,y,z+CELLUNITSZ*CHUNKSZ)
if winx2 >= 0 and winy2 >= 0 and winx1 <= SCRW and winy1 <= SCRH then