Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mode={}
- mode["Cube"] ={}
- mode["3D"] ={}
- mode["Classic"] ={}
- mode["Connect-4"] ={}
- ----CUBE MODE
- mode["Cube"].draw_board = function()
- -----Blit the board --------
- --timers.rot = timers.rot + 0.02 --Increase this variable for rotating models
- local pos={}; local rot={}; local depth = 0
- local nd = board.depth-board.depth/2+0.5
- local ny = board.height -board.height/2+0.5
- for d = 1, board.depth do
- --The distance between "layers" of the cube
- depth = (d-nd)*10
- for y = 1, board.height do
- for x = 1, board.width do
- --Calculate the position of empty models
- pos.x = board.pos.x +((x-1)*board.w)
- pos.y = board.pos.y + math.sin(-board.rot.x)*(y-ny)*board.w +math.sin(1.57-board.rot.x)*depth
- pos.z = board.pos.z + math.cos(-board.rot.x)*(y-ny)*board.w +math.cos(1.57-board.rot.x)*depth
- --Blit the empty models
- models.empty_cube.model:rotation(board.rot.x ,board.rot.y, board.rot.z)
- models.empty_cube.model:position(pos.x, pos.y, pos.z)
- models.empty_cube.model:blit()
- if board.table[d][y][x] == "" then continue end
- --If the current "chip" is not empty then
- --Blit the model depending the player
- if board.table[d][y][x] == board.player[1].st then --Player 1
- -- Model rotation
- rot.x = board.rot.x + board.player[1].model.turning.x * timers.rot
- rot.y = board.rot.y + board.player[1].model.turning.y * timers.rot
- rot.z = board.rot.z + board.player[1].model.turning.z * timers.rot
- board.player[1].model.model:position(pos.x, pos.y, pos.z)
- board.player[1].model.model:rotation(rot.x, rot.y, rot.z)
- board.player[1].model.model:blit()
- else --Player 2
- -- Model rotation
- rot.x = board.rot.x + board.player[2].model.turning.x * timers.rot
- rot.y = board.rot.y + board.player[2].model.turning.y * timers.rot
- rot.z = board.rot.z + board.player[2].model.turning.z * timers.rot
- board.player[2].model.model:position(pos.x, pos.y, pos.z)
- board.player[2].model.model:rotation(rot.x, rot.y, rot.z)
- board.player[2].model.model:blit()
- end
- end
- end
- end
- end
- dofile("src/game.lua")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement