Skip to content

Commit

Permalink
moved some stuff around. game is sorta playable
Browse files Browse the repository at this point in the history
  • Loading branch information
jwoertink committed May 22, 2013
1 parent 28a22c6 commit ff8538f
Show file tree
Hide file tree
Showing 20 changed files with 157 additions and 70 deletions.
31 changes: 19 additions & 12 deletions README.rdoc → README.md
@@ -1,44 +1,51 @@
= MazeCraze
# MazeCraze
dynamic maze game built with [jMonkeyEngine](http://jmonkeyengine.org) and [JRuby](http://jruby.org)

== Installation & Requirements
## Installation & Requirements
Currently only tested on Mac OSX 10.6+
* Open up your terminal on OSX
* Install JRuby (1.7+)

rvm install jruby-head
```rvm install jruby-head```

* Download MazeCraze

git clone git://github.com/jwoertink/maze_craze.git
```git clone git://github.com/jwoertink/maze_craze.git```

* cd into the directory

cd maze_craze
```cd maze_craze```

* Install bundler

gem install bundler
```gem install bundler```

* Bundle the gems

bundle
```bundle```

You should be good at this point.

== Running MazeCraze
## Running MazeCraze
Just run this command from the terminal
jruby bin/maze_craze
```jruby bin/maze_craze```

== Game Play
## Game Play
The object of the game is to find your way through the maze. There are some targets hidden within the maze. You must find them all, and destroy them before completing the maze.

== Road Map
## Road Map
* Add a working timer
* Add more levels
* Add a better generated maze
* Add Monsters
* Add a HUD GUI

== Copyright
## Structure (WIP)
*Actors* - The objects that interact within the game. Could be characters and props
*Scenes* - The views and layouts.
*Controllers* - The logic behind the views and layouts
*App* - Structure for the stage


## Copyright
Copyright (c) 2012 Jeremy Woertink. You can download the game, and change the source code all you want. If you sell it, and make money, you have to give me credit :)
28 changes: 13 additions & 15 deletions models/maze.rb → actors/maze.rb
@@ -1,11 +1,9 @@
class Maze < Game::Base
class Maze < Game::Window

attr_accessor :playtime, :playing, :bullet_app_state, :player, :mark, :shootables, :gun_sound, :ambient_noise

def initialize
super
[:up, :down, :left, :right].each { |direction| self.instance_variable_set("@#{direction}", false) }
@walk_direction = Vector3f.new
@floor = {:width => 200, :height => 100}
@wall = {:width => 10, :height => 20}
self.playing = false
Expand Down Expand Up @@ -125,7 +123,7 @@ def setup_floor!
floor = Box.new(Vector3f::ZERO, @floor[:width], 0.2, @floor[:height])
floor.scale_texture_coordinates(Vector2f.new(3, 6))
floor_mat = Material.new(asset_manager, File.join("Common", "MatDefs", "Misc", "Unshaded.j3md"))
key = TextureKey.new(File.join('assets', 'images', 'hardwood.jpg'))
key = TextureKey.new(Game.asset_path('rock.jpg'))
key.generate_mips = true
texture = asset_manager.load_texture(key)
texture.wrap = Texture::WrapMode::Repeat
Expand Down Expand Up @@ -157,10 +155,10 @@ def setup_light!
def setup_keys!
input_manager.add_mapping("Left", KeyTrigger.new(KeyInput::KEY_A))
input_manager.add_mapping("Right", KeyTrigger.new(KeyInput::KEY_D))
input_manager.add_mapping("Up", KeyTrigger.new(KeyInput::KEY_W))
input_manager.add_mapping("Down", KeyTrigger.new(KeyInput::KEY_S))
input_manager.add_mapping("Forward", KeyTrigger.new(KeyInput::KEY_W))
input_manager.add_mapping("Backward", KeyTrigger.new(KeyInput::KEY_S))
input_manager.add_mapping("Shoot", KeyTrigger.new(KeyInput::KEY_SPACE))
input_manager.add_listener(ControllerAction.new(self), ["Left", "Right", "Up", "Down", "Shoot"].to_java(:string))
input_manager.add_listener(ControllerAction.new(self), ["Left", "Right", "Forward", "Backward", "Shoot"].to_java(:string))
end

def setup_text!
Expand Down Expand Up @@ -200,13 +198,13 @@ def simpleUpdate(tpf)
#@time_text.text = "PLAY TIME: #{(@counter += 1) / 1000}" if playing?
cam_dir = cam.direction.clone.mult_local(0.6)
cam_left = cam.left.clone.mult_local(0.4)
@walk_direction.set(0, 0, 0)
@walk_direction.add_local(cam_left) if @left
@walk_direction.add_local(cam_left.negate) if @right
@walk_direction.add_local(cam_dir) if @up
@walk_direction.add_local(cam_dir.negate) if @down
player.walk_direction = @walk_direction
cam.location = player.physics_location
player.direction.set(0, 0, 0)
player.direction.add_local(cam_left) if player.left?
player.direction.add_local(cam_left.negate) if player.right?
player.direction.add_local(cam_dir) if player.forward?
player.direction.add_local(cam_dir.negate) if player.backward?
player.move_direction = player.direction # this is weird... do not like
cam.location = player.location
if cam.location.x > (@floor[:width]) && cam.location.z > (@floor[:height] - 20) && playing?
if @targets.empty? && @targets_generated > 0
@time_text.text = "YOU MUST SHOOT A TARGET FIRST!"
Expand Down Expand Up @@ -239,7 +237,7 @@ def initialize(obj)
end

def on_action(binding, value, tpf)
@parent.instance_variable_set("@#{binding.downcase}", value)
@parent.player.send("#{binding.downcase}=", value) if @parent.player.respond_to?("#{binding.downcase}=")
if binding.eql?("Shoot") && !value
@parent.gun_sound.play_instance
results = CollisionResults.new
Expand Down
18 changes: 18 additions & 0 deletions actors/player.rb
@@ -0,0 +1,18 @@
require 'app/movable'

class Player < PhysicalObject
include Movable

def initialize(app_state)
super
# This isn't being used yet.
@model = $asset_manager.load_model(File.join("Models", "Oto", "Oto.mesh.xml"))
@model.local_scale = 0.5
@model.local_translation = Vector3f.new(-185, 15, -95)
@model.add_control(object)
app_state.physics_space.add(@model)
end



end
File renamed without changes.
21 changes: 21 additions & 0 deletions app/graphics.rb
@@ -0,0 +1,21 @@
module Graphics

def self.included(base)
java_import "java.awt.DisplayMode"
java_import "java.awt.GraphicsDevice"
java_import "java.awt.GraphicsEnvironment"
end

def graphics_device
@device ||= GraphicsEnvironment.local_graphics_environment.default_screen_device
end

##
# display_modes.each do |mode|
# puts "#{mode.width}x#{mode.height} #{mode.bit_depth}bit"
# end
def display_modes
graphics_device.display_modes
end

end
39 changes: 39 additions & 0 deletions app/movable.rb
@@ -0,0 +1,39 @@
module Movable

def direction
@direction ||= Vector3f.new
end

def left?
@left
end

def left=(moving_left = false)
@left = moving_left
end

def right?
@right
end

def right=(moving_right = false)
@right = moving_right
end

def forward?
@forward
end

def forward=(moving_forward = false)
@forward = moving_forward
end

def backward?
@backward
end

def backward=(moving_backward = false)
@backward = moving_backward
end

end
37 changes: 37 additions & 0 deletions app/physical_object.rb
@@ -0,0 +1,37 @@
class PhysicalObject
attr_accessor :object, :model

def initialize(app_state)
capsule_shape = CapsuleCollisionShape.new(1.5, 15.0, 1)
@object = CharacterControl.new(capsule_shape, 0.05)
@object.jump_speed = 20
@object.fall_speed = 30
@object.gravity = 30
@object.physics_location = Vector3f.new(-185, 15, -95)
end

def move_direction=(direction)
@object.walk_direction = direction
end

def move_direction
@object.walk_direction
end

def location
@object.physics_location
end

def jump_speed
@object.jump_speed
end

def fall_speed
@object.fall_speed
end

def gravity
@object.gravity
end

end
8 changes: 4 additions & 4 deletions models/game/base.rb → app/window.rb
@@ -1,16 +1,16 @@
module Game
class Base < SimpleApplication
class Window < SimpleApplication
include ActionListener
field_accessor :flyCam, :paused
field_reader :cam, :settings

def initialize
super
# Is there a better way to do this?
self.settings = Game.settings
self.show_settings = false
end

def simpleInitApp
self.timer = NanoTimer.new
$root_node = root_node
Expand All @@ -20,6 +20,6 @@ def simpleInitApp
$audio_renderer = audio_renderer
$gui_view_port = gui_view_port
end

end
end
Binary file modified assets/images/brickwall.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/hardwood.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/maze_craze_logo.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/rock.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/start-background.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/start.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/stop.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/target.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion bin/maze_craze
@@ -1,6 +1,6 @@
#!/usr/bin/ruby
# -*- coding: utf-8 -*-
GAME_ROOT_PATH = File.expand_path('../maze_craze')
GAME_ROOT_PATH = File.join(File.dirname(__FILE__), '..')

require File.join(GAME_ROOT_PATH, 'config', 'boot')
require File.join(GAME_ROOT_PATH, 'config', 'game')
Expand Down
8 changes: 0 additions & 8 deletions config/game.rb
@@ -1,9 +1,6 @@
java_import "com.jme3.system.AppSettings"
java_import "java.util.logging.Level"
java_import "java.util.logging.Logger"
# java_import "java.awt.DisplayMode"
# java_import "java.awt.GraphicsDevice"
# java_import "java.awt.GraphicsEnvironment"

module Game
VERSION = '1.0'
Expand All @@ -16,11 +13,6 @@ def configure
yield self
#should move this into the actual initializer
Logger.get_logger("").level = Level::WARNING
# device = GraphicsEnvironment.local_graphics_environment.default_screen_device
# modes = device.display_modes
# modes.each do |mode|
# puts "#{mode.width}x#{mode.height} #{mode.bit_depth}bit"
# end
# self.stop
end

Expand Down
9 changes: 5 additions & 4 deletions config/imports.rb
Expand Up @@ -41,7 +41,8 @@
# java_import "PauseScreenController"
# java_import "EndScreenController"

require 'models/game/base' # This belongs somewhere else
require 'models/wall'
require 'models/player'
require 'models/maze'
require 'app/window' # This belongs somewhere else
require 'app/physical_object'
require 'actors/wall'
require 'actors/player'
require 'actors/maze'
26 changes: 0 additions & 26 deletions models/player.rb

This file was deleted.

0 comments on commit ff8538f

Please sign in to comment.