Skip to content

Commit eaf686c

Browse files
committed
Widgets and icons prototype
1 parent e728074 commit eaf686c

36 files changed

+186
-292
lines changed
Lines changed: 28 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,45 @@
11
class InventoryBar
2-
constructor: (options)->
3-
@boxSize=options.boxSize
4-
@div=options.div
5-
@padding=options.padding
6-
@boxes=9
7-
@activeBox=1
8-
document.querySelector(@div).style="position:fixed;bottom:50px;left:50%;width:#{(@boxSize+2)*@boxes}px;margin-left:-#{@boxSize*@boxes/2}px;height:#{@boxSize}px;"
9-
setBox: (number,imageSrc)->
10-
if imageSrc is null
11-
imageSrc = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="
12-
$(".inv_box").eq(number-1).attr("src",imageSrc)
13-
return
14-
setFocus: (number,state)->
15-
if state
16-
$(".inv_box").eq(number-1).css("background","rgba(0,0,0,0.7)")
17-
$(".inv_box").eq(number-1).css("border","1px solid black")
18-
else
19-
$(".inv_box").eq(number-1).css("background","rgba(54,54,54,0.5)")
20-
$(".inv_box").eq(number-1).css("border","1px solid #363636")
21-
return
22-
setFocusOnly: (number)->
23-
for i in [1..@boxes]
24-
@setFocus i, i is number
25-
@activeBox=number
26-
return @
27-
moveBoxMinus: ->
28-
if @activeBox + 1 > @boxes
29-
@setFocusOnly 1
30-
else
31-
@setFocusOnly @activeBox + 1
32-
return
33-
moveBoxPlus: ->
34-
if @activeBox - 1 is 0
35-
@setFocusOnly @boxes
36-
else
37-
@setFocusOnly @activeBox - 1
38-
directBoxChange: (event)->
39-
code = event.keyCode
40-
if code >= 49 and code < 49 + @boxes
41-
@setFocusOnly code - 48
42-
setBoxes: (images)->
43-
for i in [0..images.length-1]
44-
@setBox i+1,images[i]
45-
return @
462
setHp: (points)->
3+
lista={}
474
for i in [1..10]
48-
$(".hp").eq(i-1).attr("src","assets/images/heart/black.png")
5+
lista[i-1]="empty"
6+
$(".hp").eq(i-1).removeClass("empty")
7+
$(".hp").eq(i-1).removeClass("full")
8+
$(".hp").eq(i-1).removeClass("half")
499
if points isnt 0
5010
for i in [1..(points+points%2)/2]
51-
$(".hp").eq(i-1).attr("src","assets/images/heart/red.png")
11+
lista[i-1]="full"
5212
if points%2 is 1
53-
$(".hp").eq((points+points%2)/2-1).attr("src","assets/images/heart/half.png")
13+
lista[(points+points%2)/2-1]="half"
14+
for i in [1..10]
15+
$(".hp").eq(i-1).addClass(lista[i-1])
5416
return
5517
setFood: (points)->
18+
lista={}
5619
for i in [1..10]
57-
$(".food").eq(10-i).attr("src","assets/images/hunger/black.png")
20+
lista[10-i]="empty"
21+
$(".food").eq(10-i).removeClass("empty")
22+
$(".food").eq(10-i).removeClass("full")
23+
$(".food").eq(10-i).removeClass("half")
5824
if points isnt 0
5925
for i in [1..(points+points%2)/2]
60-
$(".food").eq(10-i).attr("src","assets/images/hunger/full.png")
26+
lista[10-i]="full"
6127
if points%2 is 1
62-
$(".food").eq(10-(points+points%2)/2).attr("src","assets/images/hunger/half.png")
28+
lista[10-(points+points%2)/2]="half"
29+
for i in [1..10]
30+
$(".food").eq(10-i).addClass(lista[10-i])
6331
return
32+
setXp: (level,progress)->
33+
$(".player_xp").text level
34+
$(".xp_bar").css "width","#{500*progress}px"
6435
listen: ->
6536
_this=@
66-
$(window).on 'wheel', (event) ->
67-
if event.originalEvent.deltaY < 0
68-
_this.moveBoxPlus()
69-
else
70-
_this.moveBoxMinus()
71-
$(document).keydown (z) ->
72-
_this.directBoxChange(z)
37+
# $(window).on 'wheel', (event) ->
38+
# if event.originalEvent.deltaY < 0
39+
# _this.moveBoxPlus()
40+
# else
41+
# _this.moveBoxMinus()
42+
# $(document).keydown (z) ->
43+
# _this.directBoxChange(z)
7344
return @
7445
export {InventoryBar}

coffee/client/module/World/World.coffee

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@ class World
2727
@chunkWorker.postMessage {
2828
type:'init'
2929
data:{
30-
models:{
31-
anvil:{
32-
@al.get("anvil").children[0].geometry.attributes...
33-
}
34-
}
3530
blocksMapping: @al.get "blocksMapping"
3631
toxelSize: @toxelSize
3732
cellSize: @cellSize

coffee/client/module/index.coffee

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,6 @@ init = ()->
3838
#Informacja o gpu komputera
3939
console.warn gpuInfo()
4040

41-
#Chmury
42-
clouds=al.get "clouds"
43-
clouds.scale.x=0.1
44-
clouds.scale.y=0.1
45-
clouds.scale.z=0.1
46-
clouds.position.y=170
47-
scene.add clouds
48-
4941
#FPSy
5042
stats = new Stats()
5143
stats.showPanel 0
@@ -89,8 +81,7 @@ init = ()->
8981
socket.on "msg",(msg)->
9082
$(".chat").append(msg+"<br>")
9183
socket.on "xp",(xp)->
92-
$(".player_xp").text(xp.level)
93-
$(".progress-bar").css("width",xp.progress*100+"%")
84+
inv_bar.setXp xp.level,xp.progress
9485
socket.on "move", (pos)->
9586
to={x:pos.x-0.5,y:pos.y+17,z:pos.z-0.5}
9687
new TWEEN.Tween camera.position
@@ -103,17 +94,7 @@ init = ()->
10394
boxSize: 60
10495
padding: 4
10596
div: ".inventoryBar"
106-
}).setBoxes([
107-
"assets/images/grass_block.png",
108-
"assets/images/stone.png",
109-
"assets/images/oak_planks.png",
110-
"assets/images/smoker.gif",
111-
"assets/images/anvil.png",
112-
"assets/images/brick.png",
113-
"assets/images/furnace.png",
114-
"assets/images/bookshelf.png",
115-
"assets/images/tnt.png"
116-
]).setFocusOnly(1).listen()
97+
}).listen()
11798

11899
#Kontrolki gracza
119100
FPC = new FirstPersonControls {

src/client/assets/assetLoader.json

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,8 @@
11
{
2-
"steve":{
3-
"path":"assets/textures/steve.png",
4-
"type":"texture"
5-
},
6-
"ghast":{
7-
"path":"assets/textures/ghast.png",
8-
"type":"texture"
9-
},
10-
"ghastS":{
11-
"path":"assets/textures/ghast_shooting.png",
12-
"type":"texture"
13-
},
142
"blocksMapping":{
153
"path":"assets/blocks/blocksMapping.json",
164
"type":"text"
175
},
18-
"blocks":{
19-
"path":"assets/blocks/blocks.json",
20-
"type":"text"
21-
},
226
"blocksAtlasFull":{
237
"path":"assets/blocks/blocksAtlas-full.png",
248
"type":"image"
@@ -27,22 +11,6 @@
2711
"path":"assets/blocks/blocksMapping-full.json",
2812
"type":"text"
2913
},
30-
"clouds":{
31-
"path":"assets/models/clouds/clouds.fbx",
32-
"type":"fbx"
33-
},
34-
"ghastF":{
35-
"path":"assets/models/ghast/ghast.fbx",
36-
"type":"fbx"
37-
},
38-
"player":{
39-
"path":"assets/models/player/player.fbx",
40-
"type":"fbx"
41-
},
42-
"anvil":{
43-
"path":"assets/models/anvil/anvil.fbx",
44-
"type":"fbx"
45-
},
4614
"skybox":{
4715
"path":"assets/images/skybox.jpg",
4816
"type":"texture"

src/client/assets/gui/icons.png

7.73 KB
Loading

src/client/assets/gui/widgets.png

15.1 KB
Loading
-589 Bytes
Binary file not shown.
-667 Bytes
Binary file not shown.
-665 Bytes
Binary file not shown.
-588 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)