PageRenderTime 11ms CodeModel.GetById 2ms app.highlight 6ms RepoModel.GetById 2ms app.codeStats 0ms

/game/scripts/main.lua

https://bitbucket.org/vivkin/gam3b00bs/
Lua | 89 lines | 64 code | 21 blank | 4 comment | 4 complexity | 27f38c3115b45382707810ee7de6b5e4 MD5 | raw file
 1--
 2-- main.lua - entry point
 3--
 4
 5include "nil.lua"
 6
 7
 8print "main.lua"
 9
10print "-----------------------------------"
11
12
13if app.init() then
14
15    print "app init ok"
16    print "\nRunning main loop, close the render window to exit.\n\n"
17
18    local vis_desc = 
19    { 
20        Mesh = "boobs",
21        Texture = 
22		{	
23			[1] = "..\\textures\\solid.dds",
24			[2] = "..\\textures\\LakeRem.dds",
25		},
26        Material = 
27        {
28            Ambient = {0.1, 0.1, 0.1, 0.1},
29            Diffuse = {1, 1, 1, 1},
30            Specular = {1, 1, 1, 1},
31            Emissive = {0, 0, 0, 0},
32            Power = 1
33        }
34    }
35    local vis = renderer.visual_create( vis_desc )
36    
37    local vis_desc2 = 
38    { 
39        Mesh = "scene",
40        Texture =
41		{
42			[1] = "..\\textures\\plate.dds",
43		},
44        Material = 
45        {
46            Ambient = {1.0, 1.0, 1.0, 1.0},
47            Diffuse = {1, 1, 1, 1},
48            Specular = {1, 1, 1, 1},
49            Emissive = {0, 0, 0, 0},
50            Power = 1
51        }
52    }
53    local vis2 = renderer.visual_create( vis_desc2 )
54    
55    local yaw = 0.0
56    
57    while app.tick() do
58        local time = app.time()
59        local x, y = input.get_cursor_rel()
60        
61        io.write( "xr = ", x, " yr = ", y, " T = ", time.T, "  dt = ", time.dt, " \r" )
62--        io.write( "T = ", time.T, "  dt = ", time.dt, "    \r" )
63        yaw = yaw + time.dt
64        renderer.visual_set_rotation(vis, 0, yaw, 0)
65        renderer.visual_set_scale(vis, 0.9)
66        renderer.visual_set_position( vis, 0.0, -0.0, 0.0 )
67        renderer.visual_render(vis)
68        
69        renderer.visual_render(vis2)
70        
71        if input.get_key_state(27) == input.DOWN then
72            break
73        end
74        
75        renderer.tick()
76        input.tick()
77    end
78    
79    print ""
80    
81    app.term()
82    
83    print "app term ok"
84else
85    error( "app init failed." )
86end
87
88
89