tumblr-game 1.2.6 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aca34894248585f3753dabcb2093700c4c4c196e
4
- data.tar.gz: 35775065b2818c913cb33808b370298b108be22f
3
+ metadata.gz: ebdcf94506e353243360efc40b2dd2b2a5c09e23
4
+ data.tar.gz: a5e9b6029157b4f3e015ecc1fcab2f0580965204
5
5
  SHA512:
6
- metadata.gz: 5a3bbf087f21767286b2996c8a09e50b7e45d2cf36ddbb9243181e3b96e0e799c5618d27abe457ea3ac11b5821e6e01be599b8a9589352dd2ae34e0ee1545cfb
7
- data.tar.gz: 540c76c487355da51106505c54945ff372028374b2917340c56c82254c1ce658b8f5b502bd2589ccb6ce5cc5d36c1b741f4e4384be1091922ff21f0ce469769b
6
+ metadata.gz: 23bfca9d86a47a10da517f9e23a8c7a6996788571a42349a97d0dd1fa6f1f08fe7e4cd7e6872199ad30bd6f9d46be78aa9429667d8e23a7007b6b24df8c2ee53
7
+ data.tar.gz: 41c0cd929c08ebfd164a154c7a45316d173ee133167df6e9b1df3589f098494b217093a6d9882ea166259212e3a9e71b565b95413d145b15490dd02a15d958c7
data/lib/tumblr-game.rb CHANGED
@@ -1,6 +1,11 @@
1
1
  require_relative 'tumblr-game/gosu.rb'
2
2
  require_relative 'tumblr-game/tumblr.rb'
3
3
 
4
+
5
+ ## GAME CLASS. This class takes care of getting user input from the user, passing it to the appropriate class for error checking, starting the game,
6
+ # and ending the game. A Game object must be created. The user must then call the initialize function, pass it the parameters, and then call start.
7
+ # Those three steps are all that is necessary to start the game.
8
+
4
9
  class Game
5
10
 
6
11
  ## this function will accept the dimensions of the window to be created and initialize a Game object
@@ -35,7 +40,8 @@ class Game
35
40
  end
36
41
  end
37
42
 
38
- ## this function will delete the files that have been made over the course of the game. this must be called after Game.start in the main program file
43
+ ## this function will delete the files that have been made over the course of the game. this function is automatically called by this class after the
44
+ # window is closed
39
45
  def delete
40
46
  File.delete( File.join(Dir.home, 'Desktop/image1.png'),
41
47
  File.join(Dir.home, 'Desktop/image2.png'),
@@ -1,5 +1,10 @@
1
1
  require_relative 'tile.rb'
2
2
 
3
+ ## BOARD CLASS. This class represents the "game board" that each tile is drawn on. The initialize function accepts 10 images that will be stored
4
+ # in the board object's tile_array. This represents the entire game board. This class effectively acts as an interface to the game tiles. The draw board
5
+ # function calls the draw functions for each of the tiles. This class contains various utility functions described below to interface appropriately with
6
+ # the tiles.
7
+
3
8
  class Board
4
9
 
5
10
  ## initialize function of the board class: this will accept 10 parameters that are each a path to an image
@@ -21,39 +26,39 @@ class Board
21
26
  @matchedCount = 0
22
27
  end
23
28
 
24
- # draw function of the board class: this will go through the tile array and draw each tile
29
+ ## draw function of the board class: this will go through the tile array and draw each tile
25
30
  def draw_board
26
31
  for i in 0..9
27
32
  @tile_Array[i].draw
28
33
  end
29
34
  end
30
35
 
31
- # this function will flip a given tile to the face indicated by the parameter bool. false = facedown, true = face up
36
+ ## this function will flip a given tile to the face indicated by the parameter bool. false = facedown, true = face up
32
37
  def flip_tile(ind, bool)
33
38
  @tile_Array[ind].flip(bool)
34
39
  end
35
40
 
36
- # this function will get the id from the desired tile
41
+ ## this function will get the id from the desired tile
37
42
  def get_id(ind)
38
43
  return @tile_Array[ind].return_id
39
44
  end
40
45
 
41
- # this function will set a tile to its "matched" configuration
46
+ ## this function will set a tile to its "matched" configuration
42
47
  def matchTile(ind)
43
48
  @tile_Array[ind].set_match
44
49
  end
45
50
 
46
- # this function will get the matched status of a specific tile and return it
51
+ ## this function will get the matched status of a specific tile and return it
47
52
  def is_matched(ind)
48
53
  return @tile_Array[ind].return_match
49
54
  end
50
55
 
51
- # this function will increment the match counter to reflect a user successfully matching tiles
56
+ ## this function will increment the match counter to reflect a user successfully matching tiles
52
57
  def inc_match
53
58
  @matchedCount += 1
54
59
  end
55
60
 
56
- # this function will return the amount of matched tiles
61
+ ## this function will return the amount of matched tiles
57
62
  def return_count
58
63
  return @matchedCount
59
64
  end
@@ -3,6 +3,10 @@ require_relative 'board.rb'
3
3
  require_relative 'tile.rb'
4
4
  require_relative 'timer.rb'
5
5
 
6
+ ## MY WINDOW CLASS. This class is the main workhorse class of the game. It maintains all of the objects and variables associated with the game, as well
7
+ # as rendering the window and allowing the user to interface with the tiles through picking. Each function is described in a comment block above the
8
+ # function declaration.
9
+
6
10
  class MyWindow < Gosu::Window
7
11
 
8
12
  ## constants that will represent the background color for the window when the user loses
@@ -51,7 +55,7 @@ class MyWindow < Gosu::Window
51
55
  ## initialize a Timer object that will keep track of the time remaining for the given game
52
56
  # also create a Gosu font object that will be passed to the Timer object
53
57
  font = Gosu::Font.new(self, Gosu::default_font_name, 20)
54
- @timer = Timer.new(font, @width/2, @height/2)
58
+ @timer = Timer.new(font, @width/2, @height/2, 30)
55
59
 
56
60
  ## create a font for the end of the game, either win or lose
57
61
  @endFont = Gosu::Font.new(self, Gosu::default_font_name, 20)
@@ -134,11 +138,6 @@ class MyWindow < Gosu::Window
134
138
 
135
139
  ## update the Timer object
136
140
  @timer.update
137
-
138
- #if @timer.return_time == 0 then
139
- # check_win
140
- #end
141
-
142
141
  end
143
142
 
144
143
  ## draw function. this function will draw one of the three backgrounds for the game. if the game is in the LOSE state, if the time has run out and the
@@ -148,7 +147,6 @@ class MyWindow < Gosu::Window
148
147
  def draw
149
148
  if (!@win and @lose) or (@frameCounter == 0 and @game_board.return_count < 5 and @timer.return_time == 0)
150
149
  draw_lose
151
- puts "here"
152
150
  elsif (@win and !@lose)
153
151
  draw_win
154
152
  elsif (!@win and !@lose)
@@ -1,5 +1,10 @@
1
1
  require 'gosu'
2
2
 
3
+ ## TILE CLASS. This class represents each of the pictures in the game window. Each tile is created with the initialize function that accepts a Gosu
4
+ # image for the main picture (img), x- and y-coordinates, an image to display when the tile is face down (img2), and id string, and a completion image
5
+ # that is displayed when the tile is matched (chkImg). The draw function renders the tile to the game window. This class contains various utility
6
+ # functions for tiles.
7
+
3
8
  class Tile
4
9
 
5
10
  ## initialize function of the Tile class: this will create a Tile object with all necessary parameters
@@ -18,7 +23,10 @@ class Tile
18
23
  @chkImage = chkImg
19
24
  end
20
25
 
21
- # draw function of the Tile class: this will draw the image at the Tile's specified location
26
+ ## draw function of the Tile class: this will draw the image at the Tile's specified location.
27
+ # if the tile is not fliped and not matched, then its facedown image is drawn.
28
+ # if the tile is flipped and not matched, then its true image is drawn.
29
+ # if the tile is matched, then the completion image is drawn.
22
30
  def draw
23
31
  if !@flipped and !@matched then
24
32
  @rev.draw(@xLocation, @yLocation, 0)
@@ -29,22 +37,22 @@ class Tile
29
37
  end
30
38
  end
31
39
 
32
- # flip function of the Tile class: this will make the Tile be drawn with its true image
40
+ ## flip function of the Tile class: this will make the Tile be drawn with its true image
33
41
  def flip( bool )
34
42
  @flipped = bool
35
43
  end
36
44
 
37
- # return_id function of the Tile class: this will return the given Tile's id to be used in comparisons
45
+ ## return_id function of the Tile class: this will return the given Tile's id to be used in comparisons
38
46
  def return_id
39
47
  return @idStr
40
48
  end
41
49
 
42
- # sets the matched attribute of a Tile object to true. this will result in the tile displaying a checkmark for completion
50
+ ## sets the matched attribute of a Tile object to true. this will result in the tile displaying a checkmark for completion
43
51
  def set_match
44
52
  @matched = true
45
53
  end
46
54
 
47
- # this function will return a tile's matched status
55
+ ## this function will return a tile's matched status
48
56
  def return_match
49
57
  return @matched
50
58
  end
@@ -1,5 +1,10 @@
1
1
  require 'gosu'
2
2
 
3
+ ## TIMER CLASS. This class handles the timing aspect of the game. The initialize function accepts parameters that pass in a font, the timer location,
4
+ # and the amount of time the game will run for. The update function will increment the frame counter by 1 every frame until it gets to 60. It then resets
5
+ # to zero. The draw function renders the Timer on the game screen at the location established in initialize. The return_time function returns the time
6
+ # left in the game.
7
+
3
8
  class Timer
4
9
 
5
10
  ## initialize function of the timer class
@@ -8,10 +13,10 @@ class Timer
8
13
  # pX = the x coordinate of where the font will display
9
14
  # pY = the y coordinate of where the font will display
10
15
  # the timer object also maintains a frame count and a count of the total time
11
- def initialize(fontParam, pX, pY)
16
+ def initialize(fontParam, pX, pY, time)
12
17
  @font = fontParam
13
18
  @frameCounter = 0
14
- @totalTime = 30
19
+ @totalTime = time
15
20
  @posX = pX
16
21
  @posY = pY
17
22
  end
@@ -1,6 +1,10 @@
1
1
  require 'open-uri'
2
2
  require 'tumblr_client'
3
3
 
4
+ ## TUMBLR API OBJECT CLASS. This class handles all of the interfacing with the Tumblr api. The initialize function will open a connection with the
5
+ # Tumblr API. The query function executes a query to get 5 images from Tumblr's API from the blog indicated in the url. The create images function makes
6
+ # the images that will be used in the game. They are stored on the user's desktop.
7
+
4
8
  class TumblrAPIObject
5
9
 
6
10
  ## creates a new Tumblr API Object that is able to pull information from Tumblr's servers
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tumblr-game
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.6
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe Canero