Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
first commiiiit
- Loading branch information
txusty
committed
May 13, 2009
1 parent
0a015a3
commit 99b18a1
Showing
37 changed files
with
1,662 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Copyright (c) 2009 txusty | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
= txustris | ||
|
||
Description goes here. | ||
|
||
== Copyright | ||
|
||
Copyright (c) 2009 txusty. See LICENSE for details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
require 'rubygems' | ||
require 'rake' | ||
|
||
begin | ||
require 'jeweler' | ||
Jeweler::Tasks.new do |gem| | ||
gem.name = "txustris" | ||
gem.summary = %Q{TODO} | ||
gem.email = "josep.m.bach@gmail.com" | ||
gem.homepage = "http://github.com/txusty/txustris" | ||
gem.authors = ["txusty"] | ||
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings | ||
end | ||
|
||
rescue LoadError | ||
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler" | ||
end | ||
|
||
require 'spec/rake/spectask' | ||
Spec::Rake::SpecTask.new(:spec) do |spec| | ||
spec.libs << 'lib' << 'spec' | ||
spec.spec_files = FileList['spec/**/*_spec.rb'] | ||
end | ||
|
||
Spec::Rake::SpecTask.new(:rcov) do |spec| | ||
spec.libs << 'lib' << 'spec' | ||
spec.pattern = 'spec/**/*_spec.rb' | ||
spec.rcov = true | ||
end | ||
|
||
begin | ||
require 'cucumber/rake/task' | ||
Cucumber::Rake::Task.new(:features) | ||
rescue LoadError | ||
task :features do | ||
abort "Cucumber is not available. In order to run features, you must: sudo gem install cucumber" | ||
end | ||
end | ||
|
||
task :default => :spec | ||
|
||
require 'rake/rdoctask' | ||
Rake::RDocTask.new do |rdoc| | ||
if File.exist?('VERSION.yml') | ||
config = YAML.load(File.read('VERSION.yml')) | ||
version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}" | ||
else | ||
version = "" | ||
end | ||
|
||
rdoc.rdoc_dir = 'rdoc' | ||
rdoc.title = "txustris #{version}" | ||
rdoc.rdoc_files.include('README*') | ||
rdoc.rdoc_files.include('lib/**/*.rb') | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Feature: Start | ||
In order to something something | ||
A user something something | ||
something something something | ||
|
||
Scenario: something something | ||
Given inspiration | ||
When I start application | ||
Then I should see "shown" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Given /^inspiration$/ do | ||
"" | ||
end | ||
|
||
When /^I start application$/ do | ||
"" | ||
end | ||
|
||
Then /^I should see "([^\"]*)"$/ do |arg1| | ||
"" | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib') | ||
require 'txustris' | ||
|
||
require 'spec/expectations' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
class GameWindow < Gosu::Window | ||
def initialize(w = 640, h = 480) | ||
# Set window size and caption | ||
super(w, h, false, 20) | ||
@width = w | ||
@height = h | ||
self.caption = "Txustris" | ||
|
||
# Create a GUI for score and other data to be displayed during the game | ||
@GUI = GUI.new | ||
|
||
# Create a Menu of options | ||
@menu = Menu.new | ||
|
||
# Create a Player | ||
@player = Player.new | ||
|
||
# Create a tetris Grid | ||
@grid = Grid.new | ||
|
||
# Create a Hall Of Fame for records to be shown and stored | ||
@hall_of_fame = HallOfFame.new | ||
|
||
# Set keyboard sensitivity to human standards | ||
@rotation_sensitivity = 100 | ||
@moving_sensitivity = 30 | ||
|
||
# Set last time of all events to now | ||
@last_drop = @last_rotation = @last_move = @last_space = @last_esc = Gosu::milliseconds | ||
|
||
# Set starting level to 1 and lines to 0 by default | ||
@lines = 0 | ||
@level = 1 | ||
|
||
# Determine speed for each level according to ACCELERATION_FACTOR | ||
set_level_speeds | ||
|
||
end | ||
def show | ||
|
||
end | ||
|
||
private | ||
|
||
def set_level_speeds | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class Grid | ||
def initialize | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class GUI | ||
def initialize | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class HallOfFame | ||
def initialize | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class Menu | ||
def initialize | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class Player | ||
def initialize | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class Settings | ||
|
||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module ZOrder | ||
Background, Grid, Blocks, UI = *0..3 | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
require 'rubygems' | ||
require 'gosu' | ||
require 'classes/settings' | ||
require 'classes/game_window' | ||
require 'classes/player' | ||
require 'classes/gui' | ||
require 'classes/menu' | ||
require 'classes/hall_of_fame' | ||
require 'classes/grid' | ||
require 'classes/z_order' | ||
|
||
window = GameWindow.new | ||
|
||
window.show | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
class Block | ||
attr_accessor :x, :y, :colnum, :rownum, :fake | ||
@@blocks = [] | ||
def initialize(window,grid,color,size,parent_x,parent_y,colnum,rownum, fake = nil) | ||
@color = color | ||
@width = size | ||
@height = size | ||
@colnum = colnum | ||
@rownum = rownum | ||
@x = parent_x + @colnum * @width | ||
@y = parent_y + @rownum * @height | ||
@img = Gosu::Image.new(window,"media/block.png",true) | ||
@fake = false | ||
|
||
|
||
if fake then | ||
@fake = true | ||
end | ||
|
||
@@blocks << self | ||
|
||
@grid = grid | ||
|
||
end | ||
def draw | ||
@img.draw(@x,@y,1,1,1,@color, :additive) | ||
end | ||
def self.instances(filter = nil) | ||
if filter == :fake then | ||
a = @@blocks.dup.reject! do |block| | ||
block.fake == false | ||
end | ||
return a | ||
end | ||
return @@blocks | ||
end | ||
|
||
|
||
def destroy | ||
@@blocks.reject! do |block| | ||
block == self | ||
end | ||
end | ||
def revive | ||
@@blocks << self unless @@blocks.include? self | ||
end | ||
|
||
def self.destroy_fakes | ||
@@blocks.reject! do |block| | ||
block.fake == true | ||
end | ||
end | ||
def self.destroy_all | ||
@@blocks = [] | ||
end | ||
def self.unfake_all | ||
@@blocks.each do |block| | ||
block.fake = false | ||
end | ||
end | ||
|
||
def drop | ||
@y += BLOCK_SIZE | ||
end | ||
|
||
def is_above_row?(row) | ||
return true if @y < @grid.y + row*BLOCK_SIZE | ||
end | ||
|
||
def trespasses_grid? | ||
return true if @x < @grid.x or @x >= @grid.border_right or @y < @grid.y or @y >= @grid.border_bottom | ||
false | ||
end | ||
|
||
def overlaps_block? | ||
blocks = @@blocks.dup | ||
blocks.reject! do |block| | ||
block.fake == true | ||
end | ||
blocks.each do |block| | ||
if @x == block.x and @y == block.y then | ||
puts "Can't move!" | ||
return true | ||
end | ||
end | ||
false | ||
end | ||
end |
Oops, something went wrong.