mutands
This commit is contained in:
parent
7ee7b680c7
commit
923106effb
|
@ -25,45 +25,10 @@ class Bot extends Pushable
|
||||||
@climb_orientation = new Quaternion
|
@climb_orientation = new Quaternion
|
||||||
@rest_orientation = new Quaternion
|
@rest_orientation = new Quaternion
|
||||||
|
|
||||||
tireRadius = 0.05
|
|
||||||
|
|
||||||
nose = new THREE.ConeGeometry 0.404, 0.5, 32, 16, true
|
|
||||||
geom = new THREE.SphereGeometry 0.5, 32, 32, 16, Math.PI
|
|
||||||
geom = new THREE.SphereGeometry 0.5, 32, 32, 0, 2*Math.PI, 0, 2.2
|
|
||||||
|
|
||||||
nmatr = new THREE.Matrix4()
|
|
||||||
trans = new THREE.Vector3 0,-0.543,0
|
|
||||||
rot = new THREE.Quaternion().setFromEuler new THREE.Euler Vector.DEG2RAD(180), 0, 0
|
|
||||||
|
|
||||||
nmatr.compose trans, rot, new THREE.Vector3 1,1,1
|
|
||||||
geom.merge nose, nmatr
|
|
||||||
geom.rotateX Vector.DEG2RAD -90
|
|
||||||
geom.scale 0.7, 0.7, 0.7
|
|
||||||
|
|
||||||
@mesh = new THREE.Mesh geom, Material.bot
|
|
||||||
|
|
||||||
geom = new THREE.TorusGeometry 0.5-tireRadius, tireRadius, 16, 32
|
|
||||||
geom.scale 1,1,2.5
|
|
||||||
|
|
||||||
@leftTire = new THREE.Mesh geom, Material.tire
|
|
||||||
@leftTire.position.set 0.35,0,0
|
|
||||||
@leftTire.rotation.set 0, Vector.DEG2RAD(90), 0
|
|
||||||
@mesh.add @leftTire
|
|
||||||
|
|
||||||
@rightTire = new THREE.Mesh geom, Material.tire
|
|
||||||
@rightTire.position.set -0.35,0,0
|
|
||||||
@rightTire.rotation.set 0, Vector.DEG2RAD(-90), 0
|
|
||||||
@mesh.add @rightTire
|
|
||||||
|
|
||||||
@mesh.castShadow = @rightTire.castShadow = @leftTire.castShadow = true
|
|
||||||
@mesh.receiveShadow = @leftTire.receiveShadow = @rightTire.receiveShadow = true
|
|
||||||
|
|
||||||
@left_tire_rot = 0.0
|
@left_tire_rot = 0.0
|
||||||
@right_tire_rot = 0.0
|
@right_tire_rot = 0.0
|
||||||
@last_fume = 0
|
@last_fume = 0
|
||||||
|
|
||||||
@moves = 0
|
|
||||||
@health = 1
|
|
||||||
@minMoves = 100
|
@minMoves = 100
|
||||||
|
|
||||||
@move = false
|
@move = false
|
||||||
|
@ -96,12 +61,49 @@ class Bot extends Pushable
|
||||||
|
|
||||||
@startTimedAction @getActionWithId(Action.NOOP), 500
|
@startTimedAction @getActionWithId(Action.NOOP), 500
|
||||||
|
|
||||||
|
createMesh: ->
|
||||||
|
tireRadius = 0.05
|
||||||
|
nose = new THREE.ConeGeometry 0.404, 0.5, 32, 16, true
|
||||||
|
geom = new THREE.SphereGeometry 0.5, 32, 32, 16, Math.PI
|
||||||
|
geom = new THREE.SphereGeometry 0.5, 32, 32, 0, 2*Math.PI, 0, 2.2
|
||||||
|
|
||||||
|
nmatr = new THREE.Matrix4()
|
||||||
|
trans = new THREE.Vector3 0,-0.543,0
|
||||||
|
rot = new THREE.Quaternion().setFromEuler new THREE.Euler Vector.DEG2RAD(180), 0, 0
|
||||||
|
|
||||||
|
nmatr.compose trans, rot, new THREE.Vector3 1,1,1
|
||||||
|
geom.merge nose, nmatr
|
||||||
|
geom.rotateX Vector.DEG2RAD -90
|
||||||
|
geom.scale 0.7, 0.7, 0.7
|
||||||
|
|
||||||
|
Mutant = require './mutant'
|
||||||
|
mutant = @ instanceof Mutant
|
||||||
|
@mesh = new THREE.Mesh geom, mutant and Material.mutant.clone() or Material.bot
|
||||||
|
|
||||||
|
geom = new THREE.TorusGeometry 0.5-tireRadius, tireRadius, 16, 32
|
||||||
|
geom.scale 1,1,2.5
|
||||||
|
tireMat = mutant and Material.mutant_tire.clone() or Material.tire
|
||||||
|
@leftTire = new THREE.Mesh geom, tireMat
|
||||||
|
@leftTire.position.set 0.35,0,0
|
||||||
|
@leftTire.rotation.set 0, Vector.DEG2RAD(90), 0
|
||||||
|
@mesh.add @leftTire
|
||||||
|
|
||||||
|
@rightTire = new THREE.Mesh geom, tireMat
|
||||||
|
@rightTire.position.set -0.35,0,0
|
||||||
|
@rightTire.rotation.set 0, Vector.DEG2RAD(-90), 0
|
||||||
|
@mesh.add @rightTire
|
||||||
|
|
||||||
|
@mesh.castShadow = @rightTire.castShadow = @leftTire.castShadow = true
|
||||||
|
@mesh.receiveShadow = @leftTire.receiveShadow = @rightTire.receiveShadow = true
|
||||||
|
|
||||||
setOpacity: (opacity) ->
|
setOpacity: (opacity) ->
|
||||||
Material.tire.visible = opacity > 0
|
tireMat = @leftTire.material
|
||||||
Material.tire.depthWrite = opacity > 0.5
|
botMat = @mesh.material
|
||||||
Material.bot.depthWrite = opacity > 0.5
|
tireMat.visible = opacity > 0
|
||||||
Material.bot.opacity = opacity
|
tireMat.depthWrite = opacity > 0.5
|
||||||
Material.tire.opacity = opacity
|
botMat.depthWrite = opacity > 0.5
|
||||||
|
botMat.opacity = opacity
|
||||||
|
tireMat.opacity = opacity
|
||||||
|
|
||||||
# 0000000 000 00000000 00000000 0000000 000000000 000 0000000 000 000
|
# 0000000 000 00000000 00000000 0000000 000000000 000 0000000 000 000
|
||||||
# 000 000 000 000 000 000 000 000 000 000 000 0000 000
|
# 000 000 000 000 000 000 000 000 000 000 000 0000 000
|
||||||
|
@ -117,9 +119,6 @@ class Bot extends Pushable
|
||||||
getCurrentUp: -> @current_orientation.rotate(Vector.unitY).normal()
|
getCurrentUp: -> @current_orientation.rotate(Vector.unitY).normal()
|
||||||
getCurrentLeft: -> @current_orientation.rotate(Vector.unitX).normal()
|
getCurrentLeft: -> @current_orientation.rotate(Vector.unitX).normal()
|
||||||
|
|
||||||
addMoves: (m) -> @moves += m
|
|
||||||
addHealth: (h) -> @health = Math.max @health+h
|
|
||||||
|
|
||||||
# 0000000 000 00000000
|
# 0000000 000 00000000
|
||||||
# 000 000 000 000
|
# 000 000 000 000
|
||||||
# 000 000 000 0000000
|
# 000 000 000 0000000
|
||||||
|
@ -362,13 +361,6 @@ class Bot extends Pushable
|
||||||
actionFinished: (action) ->
|
actionFinished: (action) ->
|
||||||
# log "bot.actionFinished #{action.name} #{action.id}"
|
# log "bot.actionFinished #{action.name} #{action.id}"
|
||||||
|
|
||||||
# if @isDead()
|
|
||||||
# log "DIE!"
|
|
||||||
# @die()
|
|
||||||
# if action.id != Action.PUSH and action.id != Action.FALL
|
|
||||||
# # dead player may only fall, nothing else
|
|
||||||
# return
|
|
||||||
|
|
||||||
if @spiked
|
if @spiked
|
||||||
log 'spiked!'
|
log 'spiked!'
|
||||||
@move_action = null
|
@move_action = null
|
||||||
|
|
|
@ -4,11 +4,10 @@
|
||||||
# 000 000 000 000 000 000 000 000
|
# 000 000 000 000 000 000 000 000
|
||||||
# 0000000 0000000 0000000 0000000 00000000 000
|
# 0000000 0000000 0000000 0000000 00000000 000
|
||||||
|
|
||||||
log = require '/Users/kodi/s/ko/js/tools/log'
|
|
||||||
|
|
||||||
Item = require './item'
|
Item = require './item'
|
||||||
Action = require './action'
|
Action = require './action'
|
||||||
Timer = require './timer'
|
Timer = require './timer'
|
||||||
|
Material = require './material'
|
||||||
|
|
||||||
class Bullet extends Item
|
class Bullet extends Item
|
||||||
|
|
||||||
|
@ -16,27 +15,22 @@ class Bullet extends Item
|
||||||
@size = 0.2
|
@size = 0.2
|
||||||
@src_object = null
|
@src_object = null
|
||||||
|
|
||||||
geom = new THREE.SphereGeometry 1, 16, 16
|
|
||||||
mat = new THREE.MeshPhongMaterial
|
|
||||||
color: 0x2222ff
|
|
||||||
side: THREE.FrontSide
|
|
||||||
shading: THREE.SmoothShading
|
|
||||||
transparent: true
|
|
||||||
opacity: 0.8
|
|
||||||
shininess: 5
|
|
||||||
@mesh = new THREE.Mesh geom, mat
|
|
||||||
@mesh.scale.set @size, @size, @size
|
|
||||||
super
|
super
|
||||||
@addAction new Action @, Action.FLY, "fly", 40
|
@addAction new Action @, Action.FLY, "fly", 40
|
||||||
@addAction new Action @, Action.EXPLODE, "explode", 200
|
@addAction new Action @, Action.EXPLODE, "explode", 200
|
||||||
|
|
||||||
|
createMesh: ->
|
||||||
|
geom = new THREE.SphereGeometry 1, 16, 16
|
||||||
|
@mesh = new THREE.Mesh geom, Material.bullet.clone()
|
||||||
|
@mesh.scale.set @size, @size, @size
|
||||||
|
|
||||||
@shootFromBot: (bot) ->
|
@shootFromBot: (bot) ->
|
||||||
bullet = new Bullet()
|
bullet = new Bullet()
|
||||||
world.addObject bullet
|
world.addObject bullet
|
||||||
bullet.direction = bot.getCurrentDir()
|
bullet.direction = bot.getCurrentDir()
|
||||||
bullet.setPosition bot.position.plus bullet.direction.mul 1/2.0
|
bullet.setPosition bot.position.plus bullet.direction #.mul 1/2.0
|
||||||
bullet.src_object = bot
|
bullet.src_object = bot
|
||||||
# log 'shootFromBot', bullet.direction, bullet.position
|
bullet.mesh.material.color.set bot.mesh.material.color
|
||||||
world.playSound 'BULLET_SHOT', bot.getPos()
|
world.playSound 'BULLET_SHOT', bot.getPos()
|
||||||
|
|
||||||
return if bullet.hitObjectAtPos bullet.position.plus bullet.direction.mul 1/2.0
|
return if bullet.hitObjectAtPos bullet.position.plus bullet.direction.mul 1/2.0
|
||||||
|
@ -49,7 +43,7 @@ class Bullet extends Item
|
||||||
@current_position = @position.plus @direction.mul relTime
|
@current_position = @position.plus @direction.mul relTime
|
||||||
else if action.id == Action.EXPLODE
|
else if action.id == Action.EXPLODE
|
||||||
@size = 0.2 + relTime/2.0
|
@size = 0.2 + relTime/2.0
|
||||||
# color.setAlpha(0.8 * (1.0-relTime))
|
@mesh.material.opacity = 0.8 * (1.0-relTime)
|
||||||
|
|
||||||
step: (step) ->
|
step: (step) ->
|
||||||
@mesh.position.copy @current_position
|
@mesh.position.copy @current_position
|
||||||
|
@ -62,12 +56,6 @@ class Bullet extends Item
|
||||||
if hitObject?
|
if hitObject?
|
||||||
hitObject.bulletImpact()
|
hitObject.bulletImpact()
|
||||||
world.playSound hitObject.bulletHitSound?() ? 'BULLET_HIT_OBJECT'
|
world.playSound hitObject.bulletHitSound?() ? 'BULLET_HIT_OBJECT'
|
||||||
# if hitObject instanceof Mutant and not hitObject.isDead()
|
|
||||||
# world.playSound 'BULLET_HIT_MUTANT', pos
|
|
||||||
# else if hitObject == world.player
|
|
||||||
# world.playSound 'BULLET_HIT_PLAYER', pos
|
|
||||||
# else
|
|
||||||
# world.playSound 'BULLET_HIT_OBJECT', pos
|
|
||||||
else
|
else
|
||||||
world.playSound 'BULLET_HIT_WALL', pos
|
world.playSound 'BULLET_HIT_WALL', pos
|
||||||
Timer.addAction @getActionWithId Action.EXPLODE
|
Timer.addAction @getActionWithId Action.EXPLODE
|
||||||
|
|
|
@ -32,7 +32,7 @@ class Levels
|
||||||
# "sandbox",
|
# "sandbox",
|
||||||
# "energy",
|
# "energy",
|
||||||
# "maze",
|
# "maze",
|
||||||
# "love",
|
"love",
|
||||||
# --- medium
|
# --- medium
|
||||||
# "towers",
|
# "towers",
|
||||||
# "edge",
|
# "edge",
|
||||||
|
|
|
@ -35,6 +35,10 @@ class Pos
|
||||||
div: (d) -> new Pos Math.floor(@x/d), Math.floor(@y/d), Math.floor(@z/d)
|
div: (d) -> new Pos Math.floor(@x/d), Math.floor(@y/d), Math.floor(@z/d)
|
||||||
eql: (p) -> @x==p.x and @y==p.y and @z==p.z
|
eql: (p) -> @x==p.x and @y==p.y and @z==p.z
|
||||||
|
|
||||||
|
reset: ->
|
||||||
|
@x = @y = @z = 0
|
||||||
|
@
|
||||||
|
|
||||||
add: (p) ->
|
add: (p) ->
|
||||||
@x = Math.round @x + p.x
|
@x = Math.round @x + p.x
|
||||||
@y = Math.round @y + p.y
|
@y = Math.round @y + p.y
|
||||||
|
|
|
@ -24,11 +24,34 @@ module.exports =
|
||||||
opacity: 1
|
opacity: 1
|
||||||
shininess: 4
|
shininess: 4
|
||||||
|
|
||||||
|
mutant: new THREE.MeshPhongMaterial
|
||||||
|
color: 0x888888
|
||||||
|
side: THREE.FrontSide
|
||||||
|
shading: THREE.SmoothShading
|
||||||
|
transparent: true
|
||||||
|
opacity: 1
|
||||||
|
shininess: 5
|
||||||
|
|
||||||
|
mutant_tire: new THREE.MeshPhongMaterial
|
||||||
|
color: 0x555555
|
||||||
|
specular: 0x222222
|
||||||
|
side: THREE.FrontSide
|
||||||
|
shading: THREE.FlatShading
|
||||||
|
transparent: true
|
||||||
|
opacity: 1
|
||||||
|
shininess: 4
|
||||||
|
|
||||||
|
bullet: new THREE.MeshPhongMaterial
|
||||||
|
side: THREE.FrontSide
|
||||||
|
shading: THREE.SmoothShading
|
||||||
|
transparent: true
|
||||||
|
opacity: 0.8
|
||||||
|
shininess: 5
|
||||||
|
depthWrite: false
|
||||||
|
|
||||||
glow: new THREE.SpriteMaterial
|
glow: new THREE.SpriteMaterial
|
||||||
map: new THREE.TextureLoader().load "#{__dirname}/../img/glow.png"
|
map: new THREE.TextureLoader().load "#{__dirname}/../img/glow.png"
|
||||||
color: 0xffff00
|
color: 0xffff00
|
||||||
# transparent: true
|
|
||||||
# opacity: 0.8
|
|
||||||
id: 999
|
id: 999
|
||||||
|
|
||||||
gear: new THREE.MeshPhongMaterial
|
gear: new THREE.MeshPhongMaterial
|
||||||
|
|
|
@ -13,13 +13,25 @@ class Mutant extends Bot
|
||||||
|
|
||||||
constructor: () ->
|
constructor: () ->
|
||||||
super
|
super
|
||||||
|
@health = 1
|
||||||
@move = true
|
@move = true
|
||||||
|
|
||||||
die: ->
|
die: ->
|
||||||
world.playSound 'BOT_DEATH'
|
world.playSound 'BOT_DEATH'
|
||||||
super()
|
super()
|
||||||
|
@setOpacity 0.6
|
||||||
@getActionWithId(Action.FALL).duration = 40
|
@getActionWithId(Action.FALL).duration = 40
|
||||||
|
|
||||||
|
bulletImpact: -> @health -= 0.1
|
||||||
|
bulletHitSound: -> @health > 0 and 'BULLET_HIT_MUTANT' or 'BULLET_HIT_OBJECT'
|
||||||
|
|
||||||
|
actionFinished: (action) ->
|
||||||
|
if @health <= 0 and not @died
|
||||||
|
@die()
|
||||||
|
if action.id != Action.PUSH and action.id != Action.FALL # dead player may only fall, nothing else
|
||||||
|
return
|
||||||
|
super action
|
||||||
|
|
||||||
moveBot: ->
|
moveBot: ->
|
||||||
changeOrientation = Math.random() < 0.3
|
changeOrientation = Math.random() < 0.3
|
||||||
changeJumpMode = Math.random() < 0.3
|
changeJumpMode = Math.random() < 0.3
|
||||||
|
|
|
@ -50,6 +50,8 @@ class Player extends Bot
|
||||||
@projection = new Perspective 90.0
|
@projection = new Perspective 90.0
|
||||||
@projection.updateViewport()
|
@projection.updateViewport()
|
||||||
|
|
||||||
|
bulletHitSound: -> 'BULLET_HIT_PLAYER'
|
||||||
|
|
||||||
# 00000000 00000000 0000000 000 00000000 0000000 000000000 000 0000000 000 000
|
# 00000000 00000000 0000000 000 00000000 0000000 000000000 000 0000000 000 000
|
||||||
# 000 000 000 000 000 000 000 000 000 000 000 000 000 0000 000
|
# 000 000 000 000 000 000 000 000 000 000 000 000 000 0000 000
|
||||||
# 00000000 0000000 000 000 000 0000000 000 000 000 000 000 000 0 000
|
# 00000000 0000000 000 000 000 0000000 000 000 000 000 000 000 0 000
|
||||||
|
@ -226,8 +228,7 @@ class Player extends Bot
|
||||||
initAction: (action) ->
|
initAction: (action) ->
|
||||||
# log "initAction #{action.id} #{action.name}"
|
# log "initAction #{action.id} #{action.name}"
|
||||||
switch action.id
|
switch action.id
|
||||||
# when Action.CLIMB_DOWN, Action.FORWARD
|
# when Action.CLIMB_DOWN, Action.FORWARD then @addMoves 1
|
||||||
# @status.addMoves 1
|
|
||||||
when Action.TURN_LEFT, Action.TURN_RIGHT
|
when Action.TURN_LEFT, Action.TURN_RIGHT
|
||||||
world.playSound 'BOT_MOVE'
|
world.playSound 'BOT_MOVE'
|
||||||
when Action.JUMP
|
when Action.JUMP
|
||||||
|
@ -236,11 +237,6 @@ class Player extends Bot
|
||||||
|
|
||||||
super action
|
super action
|
||||||
|
|
||||||
# finishRotateAction: () ->
|
|
||||||
# if @rotate_action
|
|
||||||
# @rotate = false
|
|
||||||
# @finishAction @rotate_action
|
|
||||||
|
|
||||||
# 00000000 00000000 00000000 00000000 0000000 00000000 00 00
|
# 00000000 00000000 00000000 00000000 0000000 00000000 00 00
|
||||||
# 000 000 000 000 000 000 000 000 000 000 000 000
|
# 000 000 000 000 000 000 000 000 000 000 000 000
|
||||||
# 00000000 0000000 0000000 000000 000 000 0000000 000000000
|
# 00000000 0000000 0000000 000000 000 000 0000000 000000000
|
||||||
|
|
|
@ -168,12 +168,15 @@ class World extends Actor
|
||||||
|
|
||||||
if worldDict
|
if worldDict
|
||||||
if _.isString worldDict
|
if _.isString worldDict
|
||||||
@level_index = World.levels.list.indexOf worldDict
|
|
||||||
@level_name = worldDict
|
@level_name = worldDict
|
||||||
@dict = World.levels.dict[worldDict]
|
@dict = World.levels.dict[worldDict]
|
||||||
else
|
else
|
||||||
|
@level_name = worldDict.name
|
||||||
@dict = worldDict
|
@dict = worldDict
|
||||||
|
|
||||||
|
@level_index = World.levels.list.indexOf @level_name
|
||||||
|
log "World.create #{@level_index} #{@level_name}"
|
||||||
|
|
||||||
# ............................................................ appearance
|
# ............................................................ appearance
|
||||||
|
|
||||||
@setSize @dict["size"] # this removes all objects
|
@setSize @dict["size"] # this removes all objects
|
||||||
|
|
BIN
img/shot04.png
Normal file
BIN
img/shot04.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 706 KiB |
Loading…
Reference in New Issue
Block a user