Skip to content

Commit da35c49

Browse files
committed
Game Class
1 parent e958073 commit da35c49

File tree

10 files changed

+389
-442
lines changed

10 files changed

+389
-442
lines changed

coffee/client/module/AssetLoader.coffee

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,16 @@ import * as THREE from './build/three.module.js'
22
import {FBXLoader} from './jsm/loaders/FBXLoader.js'
33

44
class AssetLoader
5-
constructor: (options)->
5+
constructor: (init)->
66
@assets={}
7+
_this=@
8+
$.get "assets/assetLoader.json", (assets)->
9+
_this.load assets,()->
10+
console.log "AssetLoader: done loading!"
11+
init _this
12+
return
13+
return
14+
return
715
load: (assets,callback) ->
816
_this=@
917
textureLoader = new THREE.TextureLoader

coffee/client/module/Entities.coffee

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,27 @@ class Entities
44
@scene=options.scene
55
@nick=options.nick
66
@TWEEN=options.TWEEN
7-
@mobMeshMaterial = new THREE.MeshBasicMaterial {color: new THREE.Color "red" }
8-
@mobMeshGeometry = new THREE.BoxGeometry 1, 1, 1
9-
@maxCount=200
10-
@mobMesh=new THREE.InstancedMesh @mobMeshGeometry,@mobMeshMaterial,@maxCount
7+
@mobMaterial = new THREE.MeshBasicMaterial {color: new THREE.Color "red" }
8+
@mobGeometry = new THREE.BoxGeometry 1, 1, 1
9+
@mobMaxCount=200
10+
@mobMesh=new THREE.InstancedMesh @mobGeometry,@mobMaterial,@mobMaxCount
1111
@mobMesh.instanceMatrix.setUsage THREE.DynamicDrawUsage
1212
@scene.add @mobMesh
1313
@dummy = new THREE.Object3D()
1414
return
1515
update:(entities)->
1616
offset=[-0.5,16,-0.5]
17-
num=0
17+
mobs=0
1818
for i of entities
1919
if entities[i].type is "mob"
20-
num++
21-
@mobMesh.count=num
22-
num=0
20+
mobs++
21+
@mobMesh.count=mobs
22+
mobs=0
2323
for i of entities
2424
if entities[i].type is "mob"
2525
@dummy.position.set entities[i].position.x+offset[0],entities[i].position.y+offset[1],entities[i].position.z+offset[2]
2626
@dummy.updateMatrix()
27-
@mobMesh.setMatrixAt num++, @dummy.matrix
27+
@mobMesh.setMatrixAt mobs++, @dummy.matrix
2828
@mobMesh.instanceMatrix.needsUpdate = true
2929
return
3030
export {Entities}

coffee/client/module/InventoryBar.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class InventoryBar
77
$(".player_food").append("<span class='food'></span> ")
88
for i in [1..9]
99
$(".inv_bar").append("<span class='inv_box item' data-texture=''></span> ")
10+
@listen()
1011
setHp: (points)->
1112
lista={}
1213
for i in [1..10]
@@ -67,7 +68,6 @@ class InventoryBar
6768
focus=focus %% 9
6869
_this.setFocus focus
6970
tick:()->
70-
#background-image:url('/assets/items/' attr(data-texture) '.png');
7171
list = $(".item")
7272
for i in [0..list.length-1]
7373
if $(list[i]).attr('data-texture') is ""

coffee/client/module/World/World.coffee

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class World
7171
#Ustawianie z defaultu, żeby każdy Mesh był wykasowywany
7272
cellBlackList={}
7373
for k,v of @cellMesh
74-
if v isnt "disposed"
74+
if v isnt "disposed" and v isnt "disposedX"
7575
cellBlackList[k]=true
7676
cell=@cellTerrain.computeCellForVoxel (Math.floor pos.x),(Math.floor pos.y),(Math.floor pos.z)
7777
up=(x,y,z)->
@@ -98,6 +98,7 @@ class World
9898
#Kasowanie Meshy, które mają znacznik .todel
9999
for i of cellBlackList
100100
if cellBlackList[i] is true
101+
console.log @cellMesh[i]
101102
@cellMesh[i].geometry.dispose()
102103
@cellMesh[i].material.dispose()
103104
@scene.remove @cellMesh[i]

0 commit comments

Comments
 (0)