Browse Source

doors demo, nearly complete station demo and scripts used

master
Sam Black 11 years ago
parent
commit
3f6f8e4d69
5 changed files with 251 additions and 0 deletions
  1. BIN
      ee4a/doors.blend
  2. +79
    -0
      ee4a/scripts/mono_door_control.py
  3. +68
    -0
      ee4a/scripts/mono_speed_control.py
  4. +104
    -0
      ee4a/scripts/mouselook.py
  5. BIN
      ee4a/station.blend

BIN
ee4a/doors.blend View File


+ 79
- 0
ee4a/scripts/mono_door_control.py View File

@@ -0,0 +1,79 @@
#!/usr/bin/env python
# mono_door_control.py
#
# Copyright 2009 Sam Black <samwwwblack@lapwing.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.

import time
#import Blender

# Controller
controller = GameLogic.getCurrentController()

# Sensors
#proximity = controller.getSensor("door_proximity")
activate = controller.getSensor("door_activate")
#activate = controller.getSensor("door_open_act")

# Objects
#ldoor = Blender.Object.Get("l_door")
#print(ldoor.loc)
#rdoor = Blender.Object.Get("r_door")
#print(rdoor.loc)

# Actuators
#ldoor_act = controller.getActuator("l_door_move")
#rdoor_act = controller.getActuator("r_door_move")
open_snd = controller.getActuator("mono_door_open_snd")
close_snd = controller.getActuator("mono_door_close_snd")

#door_step = 0.001
doors_open = False

#open_snd.stopSound()
#close_snd.stopSound()

#if proximity.triggered:
# print("Proximity")
#else:
# print("Proximity false")

#if activate.triggered:
print("Door open triggered")
open_snd.startSound()
#for steps in range(0,10000):
# ldoor_act.setDLoc(0.0, 0.0, door_step, True)
# rdoor_act.setDLoc(0.0, 0.0, (0 - door_step), True)
doors_open = True
print("Doors opened")

time.sleep(3)

if doors_open:
print("Doors triggered shut")
close_snd.startSound()
#for steps in range(0,10000):
# ldoor_act.setDLoc( 0.0, 0.0, (ldoor.loc[0] - door_step), True)
# rdoor_act.setDLoc( 0.0, 0.0, (rdoor.loc[0] + door_step), True)
doors_open = False
print("Doors closed")

# Use them
#GameLogic.addActiveActuator(ldoor_act, True)
#GameLogic.addActiveActuator(rdoor_act, True)
GameLogic.addActiveActuator(open_snd, True)
GameLogic.addActiveActuator(close_snd, True)

+ 68
- 0
ee4a/scripts/mono_speed_control.py View File

@@ -0,0 +1,68 @@
#!/usr/bin/env python
# mono_speed_control.py
#
# Copyright 2009 Sam Black <samwwwblack@lapwing.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.

controller = GameLogic.getCurrentController()
owner = controller.getOwner()

updownact = controller.getSensor("mono_train_updown")
#up = controller.getSensor("mono_train_ud_up")
#down = controller.getSensor("mono_train_ud_down")
slow = controller.getSensor("mono_train_msg_slow")
stop = controller.getSensor("mono_train_msg_stop")
full = controller.getSensor("mono_train_msg_full")
restart = controller.getSensor("mono_train_msg_restart")

setspeed = controller.getActuator("mono_train_move_motion")

if updownact.triggered:
print("updown triggered")
if owner.updown == "down":
print("down")
speed_norm = -0.20
speed_slow = -0.10
if owner.updown == "up":
print("up")
speed_norm = 0.20
speed_slow = 0.10
else:
speed_norm = -0.20
speed_slow = -0.10

if not stop.triggered and not slow.triggered and not restart.triggered and not full.triggered and not updown.triggered:
print("running normally")
setspeed.setDLoc(0.0, speed_norm, 0.0, True)
else:
if restart.triggered:
print("Restarting train")
setspeed.setDLoc(0.0, speed_slow, 0.0, True)

if slow.triggered:
print("slow triggered")
setspeed.setDLoc(0.0, speed_slow, 0.0, True)

if full.triggered:
print("full line speed")
setspeed.setDLoc(0.0, speed_norm, 0.0, True)

if stop.triggered:
print("stop triggered")
setspeed.setDLoc(0.0, 0.0, 0.0, True)

GameLogic.addActiveActuator(setspeed, True)

+ 104
- 0
ee4a/scripts/mouselook.py View File

@@ -0,0 +1,104 @@
#!/usr/bin/env python
# mouselook.py
#
# Copyright 2009 Sam Black <samwwwblack@lapwing.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.

################################################## ####
#
# MouseLook.py Blender 2.45
#
# Clark R Thames
# Released under Creative Commons Attribution License
#
# Tutorial for using MouseLook.py can be found at
#
# www.tutorialsforblender3D.com
#
################################################## ####


########################### Logic Bricks

# Get controller
controller = GameLogic.getCurrentController()

# Get sensor named Mouse
mouse = controller.getSensor("Mouse")

# Get the actuators
rotLeftRight = controller.getActuator("LookLeftRight")
rotUpDown = controller.getActuator("LookUpDown")


############################## Need the size of the game window

import Rasterizer

width = Rasterizer.getWindowWidth()
height = Rasterizer.getWindowHeight()


############################### Get the mouse movement

def mouseMove():

# distance moved from screen center
#x = width/2 - mouse.getXPosition()
#y = height/2 - mouse.getYPosition()
x = width/2 - mouse.position[0]
y = height/2 - mouse.position[1]

# intialize mouse so it doesn't jerk first time
if hasattr(GameLogic, 'init') == False:
x = 0
y = 0
GameLogic.init = True

return (x, y)

pos = mouseMove()


######## Figure out how much to rotate camera and player ########

# Mouse sensitivity
sensitivity = 0.0005

# Amount, direction and sensitivity
leftRight = pos[0] * sensitivity
upDown = pos[1] * sensitivity

# invert upDown
#upDown = -upDown


######### Use actuators to rotate camera and player #############

# Set the rotation values
rotLeftRight.setDRot( 0.0, 0.0, leftRight, False)
rotUpDown.setDRot( upDown, 0.0, 0.0, True)

# Use them
GameLogic.addActiveActuator(rotLeftRight, True)
GameLogic.addActiveActuator(rotUpDown, True)


############# Center mouse pointer in game window ###############

# Center mouse in game window
Rasterizer.setMousePosition(width/2, height/2)

BIN
ee4a/station.blend View File


Loading…
Cancel
Save