summaryrefslogtreecommitdiffhomepage
path: root/example/old_example/house.rb
blob: c6257ee660df9546c0b99836e56e38f639132355 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# frozen_string_literal: true

# Is a house
class House
  def initialize(x, y)
    @objects = []
    @x = x
    @y = y
    @objects.push Camera::Image.new('assets/blobshadow.png',
                                    width: 320,
                                    height: 250,
                                    x: x - 10,
                                    y: y + 130,
                                    z: 0)
    @objects.push Camera::Image.new('assets/bricktexture.png',
                                    x: x,
                                    y: y,
                                    width: 300,
                                    height: 300)
    @objects.push Camera::Square.new(x: 125 + x,
                                     y: 230 + y,
                                     size: 50,
                                     color: 'black')
    @objects.push Camera::Circle.new(x: 125 + x,
                                     y: 205 + y,
                                     radius: 25,
                                     color: 'black')
    @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 Camera::Square.new(x: 160 + x,
                                     y: 20 + y,
                                     size: 100,
                                     color: 'brown',
                                     z: 1)
    @objects.push Camera::Square.new(x: 170 + x,
                                     y: 25 + y,
                                     size: 80,
                                     opacity: 0.5,
                                     color: 'blue',
                                     z: 2)
    @objects.push Camera::Rectangle.new(x: 160 + x,
                                        y: 105 + y,
                                        width: 100,
                                        height: 20,
                                        color: 'brown',
                                        z: 3)
    @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 Camera::Line.new(x1: 250 + x,
                                   y1: 65 + y,
                                   x2: 170 + x,
                                   y2: 65 + y,
                                   width: 4,
                                   color: 'brown',
                                   z: 3)
    @objects.push Camera::Sprite.new('./assets/sprites/alienpls-56.png',
                                     x: 175 + x,
                                     y: 65 + y,
                                     width: 56,
                                     height: 56,
                                     clip_width: 56,
                                     loop: true,
                                     time: 35,
                                     z: 1)
    @objects.last.play
    # @objects.each do |item|
    #  Camera << item
    # end
  end

  def remove
    @objects.each do |item|
      # Camera.remove item
      item.remove
    end
  end

  def visted_by?(character)
    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))
      Camera::Text.new('Press Space To Enter House',
                       x: x + 70,
                       y: y + 30,
                       color: 'white',
                       z: 98,
                       size: 25.0)
    end
  end
end