summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorrealtradam <[email protected]>2021-08-08 01:52:47 -0400
committerrealtradam <[email protected]>2021-08-08 01:52:47 -0400
commite9a05cecd41b244977c794931b4706015097774f (patch)
tree21c506d87226dd794635ab944317892eccc42fcb
parent4a759ba2710de0b7335e6cfcd6db8bc16795c13b (diff)
downloadruby2d-camera-e9a05cecd41b244977c794931b4706015097774f.tar.gz
ruby2d-camera-e9a05cecd41b244977c794931b4706015097774f.zip
working copy
-rw-r--r--house.rb32
-rw-r--r--lib/ruby2d/camera.rb3
-rw-r--r--lib/ruby2d/camera/circle.rb10
-rw-r--r--lib/ruby2d/camera/image.rb14
-rw-r--r--lib/ruby2d/camera/line.rb10
-rw-r--r--lib/ruby2d/camera/quad.rb16
-rw-r--r--lib/ruby2d/camera/rectangle.rb46
-rw-r--r--lib/ruby2d/camera/sprite.rb43
-rw-r--r--lib/ruby2d/camera/square.rb36
-rw-r--r--lib/ruby2d/camera/text.rb27
-rw-r--r--lib/ruby2d/camera/triangle.rb11
-rw-r--r--room.rb32
-rw-r--r--run.rb25
13 files changed, 205 insertions, 100 deletions
diff --git a/house.rb b/house.rb
index 1da0d58..b4b495f 100644
--- a/house.rb
+++ b/house.rb
@@ -6,64 +6,64 @@ class House
@objects = []
@x = x
@y = y
- @objects.push Image.new('assets/blobshadow.png',
+ @objects.push Camera::Image.new('assets/blobshadow.png',
width: 320,
height: 250,
x: x - 10,
y: y + 130,
z: 0)
- @objects.push Image.new('assets/bricktexture.png',
+ @objects.push Camera::Image.new('assets/bricktexture.png',
x: x,
y: y,
width: 300,
height: 300)
- @objects.push Square.new(x: 125 + x,
+ @objects.push Camera::Square.new(x: 125 + x,
y: 230 + y,
size: 50,
color: 'black')
- @objects.push Circle.new(x: 125 + x,
+ @objects.push Camera::Circle.new(x: 125 + x,
y: 205 + y,
radius: 25,
color: 'black')
- @objects.push Triangle.new(x1: -5 + x,
+ @objects.push Camera::Triangle.new(x1: -5 + x,
y1: 16 + y,
x2: 310 + x,
y2: 14 + y,
x3: 150 + x,
y3: -75 + y,
color: 'red')
- @objects.push Square.new(x: 160 + x,
+ @objects.push Camera::Square.new(x: 160 + x,
y: 20 + y,
size: 100,
color: 'brown',
z: 1)
- @objects.push Square.new(x: 170 + x,
+ @objects.push Camera::Square.new(x: 170 + x,
y: 25 + y,
size: 80,
opacity: 0.5,
color: 'blue',
z: 2)
- @objects.push Rectangle.new(x: 160 + x,
+ @objects.push Camera::Rectangle.new(x: 160 + x,
y: 105 + y,
width: 100,
height: 20,
color: 'brown',
z: 3)
- @objects.push Line.new(x1: 210 + x,
+ @objects.push Camera::Line.new(x1: 210 + x,
y1: 105 + y,
x2: 210 + x,
y2: 25 + y,
width: 4,
color: 'brown',
z: 3)
- @objects.push Line.new(x1: 250 + x,
+ @objects.push Camera::Line.new(x1: 250 + x,
y1: 65 + y,
x2: 170 + x,
y2: 65 + y,
width: 4,
color: 'brown',
z: 3)
- @objects.push Sprite.new('./assets/sprites/alienpls-56.png',
+ @objects.push Camera::Sprite.new('./assets/sprites/alienpls-56.png',
x: 175 + x,
y: 65 + y,
width: 56,
@@ -73,14 +73,14 @@ class House
time: 35,
z: 1)
@objects.last.play
- @objects.each do |item|
- Camera << item
- end
+ #@objects.each do |item|
+ # Camera << item
+ #end
end
def remove
@objects.each do |item|
- Camera.remove item
+ #Camera.remove item
item.remove
end
end
@@ -89,7 +89,7 @@ class House
x = @x + 80
y = @y + 160
if character.x >= x && character.x <= (x + (character.width * 2)) && character.y > y && character.y <= (y + (character.height * 2))
- Text.new('Press Space To Enter House',
+ Camera::Text.new('Press Space To Enter House',
x: x + 70,
y: y + 30,
color: 'white',
diff --git a/lib/ruby2d/camera.rb b/lib/ruby2d/camera.rb
index 8a628ee..d29609d 100644
--- a/lib/ruby2d/camera.rb
+++ b/lib/ruby2d/camera.rb
@@ -38,6 +38,9 @@ module Ruby2D
# tracked by the Camera
def self.<<(item)
objects.push(item) unless objects.include?(item)
+ objects.sort_by! do |n|
+ n.z
+ end
end
def self.remove(item)
diff --git a/lib/ruby2d/camera/circle.rb b/lib/ruby2d/camera/circle.rb
index ea841f5..c6e1eb0 100644
--- a/lib/ruby2d/camera/circle.rb
+++ b/lib/ruby2d/camera/circle.rb
@@ -8,6 +8,7 @@ module Ruby2D
# Recalculates real coordiantes
# Use after changing variables
def _draw
+ return if @hide
angle = Camera.angle * (Math::PI / 180)
half_width = Window.width * 0.5
half_height = Window.height * 0.5
@@ -23,7 +24,14 @@ module Ruby2D
def initialize(opts= {})
super(opts)
Ruby2D::Camera << self
- self.remove
+ Window.remove(self)
+ end
+ def remove
+ @hide = true
+ end
+
+ def add
+ @hide = false
end
end
end
diff --git a/lib/ruby2d/camera/image.rb b/lib/ruby2d/camera/image.rb
index 19f9084..fe777b3 100644
--- a/lib/ruby2d/camera/image.rb
+++ b/lib/ruby2d/camera/image.rb
@@ -7,6 +7,7 @@ module Camera
# Recalculates real coordiantes
# Use after changing variables
def _draw
+ return if @hide
temp_angle = Camera.angle * (Math::PI / 180)
half_width = Window.width * 0.5
half_height = Window.height * 0.5
@@ -26,10 +27,17 @@ module Camera
color: [self.color.r, self.color.g, self.color.b, self.color.a])
end
- def initialize(opts= {})
- super(opts)
+ def initialize(path, opts= {})
+ super(path, opts)
Ruby2D::Camera << self
- self.remove
+ Window.remove(self)
end
+ def remove
+ @hide = true
+ end
+
+ def add
+ @hide = false
+ end
end
end
diff --git a/lib/ruby2d/camera/line.rb b/lib/ruby2d/camera/line.rb
index e7e7c0f..9113b92 100644
--- a/lib/ruby2d/camera/line.rb
+++ b/lib/ruby2d/camera/line.rb
@@ -8,6 +8,7 @@ module Ruby2D
# Recalculates real coordiantes
# Use after changing variables
def _draw
+ return if @hide
angle = Camera.angle * (Math::PI / 180)
half_width = Window.width * 0.5
half_height = Window.height * 0.5
@@ -31,7 +32,14 @@ module Ruby2D
def initialize(opts= {})
super(opts)
Ruby2D::Camera << self
- self.remove
+ Window.remove(self)
+ end
+ def remove
+ @hide = true
+ end
+
+ def add
+ @hide = false
end
#Methods for moving the shape
diff --git a/lib/ruby2d/camera/quad.rb b/lib/ruby2d/camera/quad.rb
index 5dc52e1..92d858a 100644
--- a/lib/ruby2d/camera/quad.rb
+++ b/lib/ruby2d/camera/quad.rb
@@ -7,7 +7,8 @@ module Ruby2D
class Quad < Ruby2D::Quad
# Recalculates real coordiantes
# Use after changing variables
- def redraw
+ def _draw
+ return if @hide
angle = Camera.angle * (Math::PI / 180)
half_width = Window.width * 0.5
half_height = Window.height * 0.5
@@ -21,8 +22,8 @@ module Ruby2D
temp_y4 = (((x + x4 - Camera.x) * Math.sin(angle)) + ((y + y4 - Camera.y) * Math.cos(angle))) * Camera.zoom + half_height
Ruby2D::Quad.draw(x1: temp_x1, y1: temp_y1,
x2: temp_x2, y2: temp_y2,
- x3: temp_x3, x3: temp_x3,
- x4: temp_x4, x4: temp_x4,
+ x3: temp_x3, y3: temp_y3,
+ x4: temp_x4, y4: temp_y4,
color: [
[self.c1.r, self.c1.g, self.c1.b, self.c1.a],
[self.c2.r, self.c2.g, self.c2.b, self.c2.a],
@@ -36,7 +37,14 @@ module Ruby2D
def initialize(opts= {})
super(opts)
Ruby2D::Camera << self
- self.remove
+ Window.remove(self)
+ end
+ def remove
+ @hide = true
+ end
+
+ def add
+ @hide = false
end
diff --git a/lib/ruby2d/camera/rectangle.rb b/lib/ruby2d/camera/rectangle.rb
index cbedefc..2a3667d 100644
--- a/lib/ruby2d/camera/rectangle.rb
+++ b/lib/ruby2d/camera/rectangle.rb
@@ -4,19 +4,11 @@ module Ruby2D
module Camera
# Wraps existing variables as well as adding new methods
# so that it can be handled by the Camera Module
- module Rectange < Ruby2D::Rectangle
- # Rectangles are part of the exception where
- # their x and y variables need to be reset
- # when wrapped
- #def self.extended(obj)
- # obj.instance_exec do
- # @x = 0
- # @y = 0
- # end
- #end
+ class Rectangle < Ruby2D::Rectangle
# Recalculates real coordiantes
# Use after changing variables
- def redraw
+ def _draw
+ return if @hide
angle = Camera.angle * (Math::PI / 180)
half_width = Window.width * 0.5
half_height = Window.height * 0.5
@@ -28,12 +20,39 @@ module Ruby2D
temp_y3 = (((x + x3 - Camera.x) * Math.sin(angle)) + ((y + y3 - Camera.y) * Math.cos(angle))) * Camera.zoom + half_height
temp_x4 = (((x + x4 - Camera.x) * Math.cos(angle)) - ((y + y4 - Camera.y) * Math.sin(angle))) * Camera.zoom + half_width
temp_y4 = (((x + x4 - Camera.x) * Math.sin(angle)) + ((y + y4 - Camera.y) * Math.cos(angle))) * Camera.zoom + half_height
+ Ruby2D::Quad.draw(x1: temp_x1, y1: temp_y1,
+ x2: temp_x2, y2: temp_y2,
+ x3: temp_x3, y3: temp_y3,
+ x4: temp_x4, y4: temp_y4,
+ color: [
+ [self.c1.r, self.c1.g, self.c1.b, self.c1.a],
+ [self.c2.r, self.c2.g, self.c2.b, self.c2.a],
+ [self.c3.r, self.c3.g, self.c3.b, self.c3.a],
+ [self.c4.r, self.c4.g, self.c4.b, self.c4.a]
+ ],
+ z: self.z
+ )
end
def initialize(opts= {})
- super(otps)
+ super(opts)
Ruby2D::Camera << self
- self.remove
+ Window.remove(self)
+ @x1 -= @x
+ @x2 -= @x
+ @x3 -= @x
+ @x4 -= @x
+ @y1 -= @y
+ @y2 -= @y
+ @y3 -= @y
+ @y4 -= @y
+ end
+ def remove
+ @hide = true
+ end
+
+ def add
+ @hide = false
end
#Methods for moving the shape
def x
@@ -51,7 +70,6 @@ module Ruby2D
def y=(y)
@y = y
end
-
end
end
end
diff --git a/lib/ruby2d/camera/sprite.rb b/lib/ruby2d/camera/sprite.rb
index 4ad5bca..0d239a1 100644
--- a/lib/ruby2d/camera/sprite.rb
+++ b/lib/ruby2d/camera/sprite.rb
@@ -7,41 +7,52 @@ module Ruby2D
# Recalculates real coordiantes
# Use after changing variables
def _draw
+ return if @hide
angle = Camera.angle * (Math::PI / 180)
half_width = Window.width * 0.5
half_height = Window.height * 0.5
- offset_x = x + (width / 2)
- offset_y = y + (height / 2)
- temp_x = @flip_x = (((offset_x - Camera.x) * Math.cos(angle)) - ((offset_y - Camera.y) * Math.sin(angle))) \
+ offset_x = @x + (width / 2)
+ offset_y = @y + (height / 2)
+ temp_x = (((offset_x - Camera.x) * Math.cos(angle)) - ((offset_y - Camera.y) * Math.sin(angle))) \
* Camera.zoom + half_width - (width * Camera.zoom / 2)
- temp_y = @flip_y = (((offset_x - Camera.x) * Math.sin(angle)) + ((offset_y - Camera.y) * Math.cos(angle))) \
+ temp_y = (((offset_x - Camera.x) * Math.sin(angle)) + ((offset_y - Camera.y) * Math.cos(angle))) \
* Camera.zoom + half_height - (height * Camera.zoom / 2)
temp_rotate = rotate + Camera.angle
- temp_width = @flip_width = width * Camera.zoom
- temp_height = @flip_height = height * Camera.zoom
+ temp_width = width * Camera.zoom
+ temp_height = height * Camera.zoom
case @flip
when :both
- @flip_x = @x + @height
- @flip_width = -@width
- @flip_y = @y + @width
- @flip_height = -@height
+ temp_x = temp_x + temp_height
+ temp_y = temp_y + temp_width
+ temp_width = -temp_width
+ temp_height = -temp_height
+ puts 'both'
when :horizontal
- @flip_y = @y + @width
- @flip_height = -@height
+ temp_y = temp_y + temp_width
+ temp_height = -temp_height
when :vertical
- @flip_x = @x + @height
- @flip_width = -@width
+ temp_width = -temp_width
+ temp_x = temp_x + temp_height
end
- self.draw(x: temp_x, y: temp_x,
+ self.draw(x: temp_x, y: temp_y,
width: temp_width,
height: temp_height,
rotate: temp_rotate)
+ self.update
end
def initialize(path, opts= {})
super(path, opts)
Ruby2D::Camera << self
- self.remove
+ Window.remove(self)
+ end
+
+ def remove
+ @hide = true
+ end
+
+ def add
+ @hide = false
end
end
end
diff --git a/lib/ruby2d/camera/square.rb b/lib/ruby2d/camera/square.rb
index d013e56..584af03 100644
--- a/lib/ruby2d/camera/square.rb
+++ b/lib/ruby2d/camera/square.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-class Ruby2D
+module Ruby2D
module Camera
# Wraps existing variables as well as adding new methods
# so that it can be handled by the Camera Module
@@ -8,17 +8,18 @@ class Ruby2D
# Recalculates real coordiantes
# Use after changing variables
def _draw
+ return if @hide
angle = Camera.angle * (Math::PI / 180)
half_width = Window.width * 0.5
half_height = Window.height * 0.5
- @x1 = (((x + x1 - Camera.x) * Math.cos(angle)) - ((y + y1 - Camera.y) * Math.sin(angle))) * Camera.zoom + half_width
- @y1 = (((x + x1 - Camera.x) * Math.sin(angle)) + ((y + y1 - Camera.y) * Math.cos(angle))) * Camera.zoom + half_height
- @x2 = (((x + x2 - Camera.x) * Math.cos(angle)) - ((y + y2 - Camera.y) * Math.sin(angle))) * Camera.zoom + half_width
- @y2 = (((x + x2 - Camera.x) * Math.sin(angle)) + ((y + y2 - Camera.y) * Math.cos(angle))) * Camera.zoom + half_height
- @x3 = (((x + x3 - Camera.x) * Math.cos(angle)) - ((y + y3 - Camera.y) * Math.sin(angle))) * Camera.zoom + half_width
- @y3 = (((x + x3 - Camera.x) * Math.sin(angle)) + ((y + y3 - Camera.y) * Math.cos(angle))) * Camera.zoom + half_height
- @x4 = (((x + x4 - Camera.x) * Math.cos(angle)) - ((y + y4 - Camera.y) * Math.sin(angle))) * Camera.zoom + half_width
- @y4 = (((x + x4 - Camera.x) * Math.sin(angle)) + ((y + y4 - Camera.y) * Math.cos(angle))) * Camera.zoom + half_height
+ temp_x1 = (((x + x1 - Camera.x) * Math.cos(angle)) - ((y + y1 - Camera.y) * Math.sin(angle))) * Camera.zoom + half_width
+ temp_y1 = (((x + x1 - Camera.x) * Math.sin(angle)) + ((y + y1 - Camera.y) * Math.cos(angle))) * Camera.zoom + half_height
+ temp_x2 = (((x + x2 - Camera.x) * Math.cos(angle)) - ((y + y2 - Camera.y) * Math.sin(angle))) * Camera.zoom + half_width
+ temp_y2 = (((x + x2 - Camera.x) * Math.sin(angle)) + ((y + y2 - Camera.y) * Math.cos(angle))) * Camera.zoom + half_height
+ temp_x3 = (((x + x3 - Camera.x) * Math.cos(angle)) - ((y + y3 - Camera.y) * Math.sin(angle))) * Camera.zoom + half_width
+ temp_y3 = (((x + x3 - Camera.x) * Math.sin(angle)) + ((y + y3 - Camera.y) * Math.cos(angle))) * Camera.zoom + half_height
+ temp_x4 = (((x + x4 - Camera.x) * Math.cos(angle)) - ((y + y4 - Camera.y) * Math.sin(angle))) * Camera.zoom + half_width
+ temp_y4 = (((x + x4 - Camera.x) * Math.sin(angle)) + ((y + y4 - Camera.y) * Math.cos(angle))) * Camera.zoom + half_height
Ruby2D::Quad.draw(x1: temp_x1, y1: temp_y1,
x2: temp_x2, y2: temp_y2,
x3: temp_x3, y3: temp_y3,
@@ -36,9 +37,24 @@ class Ruby2D
def initialize(opts= {})
super(opts)
Ruby2D::Camera << self
- self.remove
+ Window.remove(self)
+ @x1 -= @x
+ @x2 -= @x
+ @x3 -= @x
+ @x4 -= @x
+ @y1 -= @y
+ @y2 -= @y
+ @y3 -= @y
+ @y4 -= @y
end
+ def remove
+ @hide = true
+ end
+
+ def add
+ @hide = false
+ end
#Methods for moving the shape
def x
@x ||= 0
diff --git a/lib/ruby2d/camera/text.rb b/lib/ruby2d/camera/text.rb
index 21c9e1b..6966a86 100644
--- a/lib/ruby2d/camera/text.rb
+++ b/lib/ruby2d/camera/text.rb
@@ -10,11 +10,10 @@ module Ruby2D
# to be corrected again(see image_wrapper.rb for reference, that has
# math that allows for resizing)
class Text < Ruby2D::Text
- @center = false
-
# Recalculates real coordiantes
# Use after changing variables
def _draw
+ return if @hide
angle = Camera.angle * (Math::PI / 180)
half_width = Window.width * 0.5
half_height = Window.height * 0.5
@@ -31,18 +30,34 @@ module Ruby2D
* Camera.zoom + half_height - (height / 2)
temp_rotate = rotate + Camera.angle
# Workaround for resizing text
+ # TODO: resizing doesnt work at all even with workaround
temp_size = size# * Camera.zoom
self.size *= Camera.zoom
self.draw(x: temp_x, y: temp_y,
rotate: temp_rotate,
- color: self.color)
+ color: [self.color.r, self.color.g, self.color.b, self.color.a])
self.size = temp_size
end
- def initialize(opts = {})
- super(opts)
+ def initialize(text, opts= {})
+ super(text, opts)
Ruby2D::Camera << self
- self.remove
+ Window.remove(self)
+ end
+ def remove
+ @hide = true
+ end
+
+ def add
+ @hide = false
+ end
+
+ def center
+ @center
+ end
+
+ def center=(center)
+ @center = center
end
end
end
diff --git a/lib/ruby2d/camera/triangle.rb b/lib/ruby2d/camera/triangle.rb
index 356222b..4065b62 100644
--- a/lib/ruby2d/camera/triangle.rb
+++ b/lib/ruby2d/camera/triangle.rb
@@ -6,6 +6,7 @@ module Ruby2D
# Recalculates real coordiantes
# Use after changing variables
def _draw
+ return if @hide
angle = Ruby2D::Camera.angle * (Math::PI / 180)
half_width = Window.width * 0.5
half_height = Window.height * 0.5
@@ -29,7 +30,15 @@ module Ruby2D
def initialize(opts= {})
super(opts)
Ruby2D::Camera << self
- self.remove
+ Window.remove(self)
+ self.add
+ end
+ def remove
+ @hide = true
+ end
+
+ def add
+ @hide = false
end
#Methods for moving the shape
diff --git a/room.rb b/room.rb
index 0366b36..4a4be4e 100644
--- a/room.rb
+++ b/room.rb
@@ -7,18 +7,18 @@ class Room
@x = x
@y = y
roomy = 155
- @objects.push Square.new(x: 125 + x,
+ @objects.push Camera::Square.new(x: 125 + x,
y: 230 + y,
size: 50,
color: 'blue',
z: 3)
- @objects.push Circle.new(x: 125 + x,
+ @objects.push Camera::Circle.new(x: 125 + x,
y: 205 + y,
radius: 25,
sectors: 64,
color: 'blue',
z: 3)
- @objects.push Quad.new(x1: 50 + x,
+ @objects.push Camera::Quad.new(x1: 50 + x,
y1: 130 + y + roomy,
x2: 125 + x,
y2: 180 + y + roomy,
@@ -28,7 +28,7 @@ class Room
y4: 130 + y + roomy,
color: 'aqua',
z: 1)
- @objects.push Quad.new(x1: 50 + x,
+ @objects.push Camera::Quad.new(x1: 50 + x,
y1: 45 + y + roomy,
x2: 50 + x,
y2: 125 + y + roomy,
@@ -38,7 +38,7 @@ class Room
y4: 45 + y + roomy,
color: 'orange',
z: 1)
- @objects.push Quad.new(x1: 255 + x,
+ @objects.push Camera::Quad.new(x1: 255 + x,
y1: 45 + y + roomy,
x2: 255 + x,
y2: 125 + y + roomy,
@@ -48,7 +48,7 @@ class Room
y4: 95 + y + roomy,
color: 'olive',
z: 1)
- @objects.push Sprite.new('./assets/sprites/blobdance-128.png',
+ @objects.push Camera::Sprite.new('./assets/sprites/blobdance-128.png',
x: 250 + x,
y: 135 + y + roomy,
width: 40,
@@ -58,7 +58,7 @@ class Room
time: 24,
z: 5)
@objects.last.play
- @objects.push Image.new(
+ @objects.push Camera::Image.new(
'assets/blobshadow.png',
x: 250 + x - 2 - 5,
y: 135 + y + roomy + 42 - 15,
@@ -66,7 +66,7 @@ class Room
height: 10,
z: 4
)
- @objects.push Sprite.new('./assets/sprites/dance2-112.png',
+ @objects.push Camera::Sprite.new('./assets/sprites/dance2-112.png',
x: 95 + x,
y: 115 + y + roomy,
width: 40,
@@ -76,7 +76,7 @@ class Room
time: 13,
z: 5)
@objects.last.play
- @objects.push Image.new(
+ @objects.push Camera::Image.new(
'assets/blobshadow.png',
x: 95 + x - 2 - 5,
y: 115 + y + roomy + 42 - 10,
@@ -84,7 +84,7 @@ class Room
height: 10,
z: 4
)
- @objects.push Sprite.new('./assets/sprites/dancer-128.png',
+ @objects.push Camera::Sprite.new('./assets/sprites/dancer-128.png',
x: 175 + x,
y: 120 + y + roomy,
width: 45,
@@ -94,7 +94,7 @@ class Room
time: 60,
z: 5)
@objects.last.play
- @objects.push Image.new(
+ @objects.push Camera::Image.new(
'assets/blobshadow.png',
x: 175 + x - 2 - 5,
y: 120 + y + roomy + 42 - 5,
@@ -102,14 +102,14 @@ class Room
height: 10,
z: 4
)
- @objects.each do |item|
- Camera << item
- end
+ #@objects.each do |item|
+ # Camera << item
+ #end
end
def remove
@objects.each do |item|
- Camera.remove item
+ #Camera.remove item
item.remove
end
end
@@ -118,7 +118,7 @@ class Room
x = @x + 80
y = @y + 160
if character.x >= x && character.x <= (x + (character.width * 2)) && character.y > y && character.y <= (y + (character.height * 2))
- Text.new('Press Space To Exit House',
+ Camera::Text.new('Press Space To Exit House',
x: x + 70,
y: y + 30,
color: 'white',
diff --git a/run.rb b/run.rb
index 30881df..69f22f8 100644
--- a/run.rb
+++ b/run.rb
@@ -1,7 +1,8 @@
# frozen_string_literal: true
require 'ruby2d'
-require_relative 'lib/camera/camera'
+#require_relative 'lib/camera/camera'
+require 'ruby2d/camera'
require_relative 'house'
require_relative 'room'
@@ -11,7 +12,7 @@ Window.set(icon: './assets/blobcoolthink.png',
background: 'blue')
-@player = Sprite.new('./assets/sprites/mainblob-128.png',
+@player = Camera::Sprite.new('./assets/sprites/mainblob-128.png',
x: 1920 / 1.1,
y: 1080 / 1.1,
width: 50,
@@ -24,15 +25,15 @@ Window.set(icon: './assets/blobcoolthink.png',
walk: 0...60,
stand: 60...61
})
-@shadow = Image.new(
+@shadow = Camera::Image.new(
'assets/blobshadow.png',
width: 52,
height: 10,
z: 4
)
-Camera << @shadow
+#Camera << @shadow
@player.play animation: :walk, loop: true
-Camera << @player
+#Camera << @player
# UI
Rectangle.new(
@@ -181,7 +182,7 @@ update do
@room = nil
@indoors = false
end
- Camera.remove @background
+ #Camera.remove @background
@background.remove
@background = nil
end
@@ -198,15 +199,15 @@ update do
if @house.nil? && !@indoors
@house = House.new(750, 300)
- @background = Image.new(
+ @background = Camera::Image.new(
'assets/background.png',
x: 100, y: 100,
z: -1
)
- Camera << @background
+ #Camera << @background
elsif @room.nil? && @indoors
@room = Room.new(750,300)
- @background = Rectangle.new(
+ @background = Camera::Rectangle.new(
color: 'black',
x: 0,
y: 0,
@@ -218,7 +219,7 @@ update do
@shadow.x = @player.x - 2
@shadow.y = @player.y + 42
- Camera.remove @house_text
+ #Camera.remove @house_text
@house_text&.remove
if @indoors
@house_text = @room.visted_by?(@player)
@@ -226,7 +227,7 @@ update do
@house_text = @house.visted_by?(@player)
end
unless @house_text.nil?
- Camera << @house_text
+ #Camera << @house_text
@house_text.center = true
end
if !@house_text.nil? && @pressed_space && !@scene_transition_into && !@scene_transition_out
@@ -243,6 +244,6 @@ update do
@player_movement_y = 0
@pressed_space = false
- Camera.redraw
+ #Camera.redraw
end
show