Advertisement
xerpi

RBM V1

Jul 17th, 2011
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.43 KB | None | 0 0
  1. mode={}
  2.     mode["Cube"] ={}
  3.     mode["3D"] ={}
  4.     mode["Classic"] ={}
  5.     mode["Connect-4"] ={}
  6.  
  7. ----CUBE MODE
  8.     mode["Cube"].draw_board = function()
  9.         -----Blit the board --------
  10.                     --timers.rot = timers.rot + 0.02 --Increase this variable for rotating models
  11.                     local pos={}; local rot={}; local depth = 0
  12.                     local nd = board.depth-board.depth/2+0.5
  13.                     local ny = board.height -board.height/2+0.5
  14.                     for d = 1, board.depth do
  15.                         --The distance between "layers" of the cube
  16.                             depth = (d-nd)*10                      
  17.                         for y = 1, board.height do
  18.                             for x = 1, board.width do  
  19.                                 --Calculate the position of empty models
  20.                                     pos.x = board.pos.x +((x-1)*board.w)
  21.                                     pos.y = board.pos.y + math.sin(-board.rot.x)*(y-ny)*board.w +math.sin(1.57-board.rot.x)*depth
  22.                                     pos.z = board.pos.z + math.cos(-board.rot.x)*(y-ny)*board.w +math.cos(1.57-board.rot.x)*depth
  23.                                 --Blit the empty models
  24.                                     models.empty_cube.model:rotation(board.rot.x ,board.rot.y, board.rot.z)
  25.                                     models.empty_cube.model:position(pos.x, pos.y, pos.z)                              
  26.                                     models.empty_cube.model:blit() 
  27.                                 if board.table[d][y][x] == "" then continue end
  28.                                 --If the current "chip" is not empty then
  29.                                
  30.                                     --Blit the model depending the player
  31.                                     if board.table[d][y][x] == board.player[1].st then  --Player 1
  32.                                         -- Model rotation
  33.                                             rot.x = board.rot.x + board.player[1].model.turning.x * timers.rot
  34.                                             rot.y = board.rot.y + board.player[1].model.turning.y * timers.rot
  35.                                             rot.z = board.rot.z + board.player[1].model.turning.z * timers.rot
  36.                                             board.player[1].model.model:position(pos.x, pos.y, pos.z)
  37.                                             board.player[1].model.model:rotation(rot.x, rot.y, rot.z)
  38.                                             board.player[1].model.model:blit()         
  39.                                     else                                            --Player 2 
  40.                                         -- Model rotation
  41.                                             rot.x = board.rot.x + board.player[2].model.turning.x * timers.rot
  42.                                             rot.y = board.rot.y + board.player[2].model.turning.y * timers.rot
  43.                                             rot.z = board.rot.z + board.player[2].model.turning.z * timers.rot
  44.                                             board.player[2].model.model:position(pos.x, pos.y, pos.z)
  45.                                             board.player[2].model.model:rotation(rot.x, rot.y, rot.z)
  46.                                             board.player[2].model.model:blit()             
  47.                                     end    
  48.                             end
  49.                         end
  50.                     end
  51.     end
  52.    
  53.  
  54.    
  55.    
  56.    
  57.    
  58.    
  59.    
  60.    
  61.    
  62.    
  63.    
  64.    
  65.    
  66.    
  67.    
  68.    
  69.    
  70.    
  71.    
  72.    
  73.    
  74.    
  75.    
  76.    
  77.    
  78.    
  79.    
  80.    
  81.    
  82.    
  83.    
  84. dofile("src/game.lua")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement