Compare commits

..

1 Commits

Author SHA1 Message Date
bionickatana 4ce0dc3c18 Fixed coordinate system and finally got zoom working 2026-06-14 11:07:39 -06:00
+5 -60
View File
@@ -24,7 +24,7 @@ GAME_PRODUCER_BASE_SPEED = 1
# Camera settings # Camera settings
CAMERA_MOVE_RANGE = 10 CAMERA_MOVE_RANGE = 10
CAMERA_MOVE_SPEED = 1 CAMERA_MOVE_SPEED = 1
CAMERA_MOVE_MAX_SPEED = 1 # (CAMERA_MOVE_RANGE * CAMERA_MOVE_SPEED / 3).to_i CAMERA_MOVE_MAX_SPEED = 5
CAMERA_MIN_ZOOM = 16 # Boxes across CAMERA_MIN_ZOOM = 16 # Boxes across
CAMERA_MAX_ZOOM = 80 # Boxes across CAMERA_MAX_ZOOM = 80 # Boxes across
@@ -92,61 +92,6 @@ class NumFactory < Gosu::Window
end end
end end
end end
@producers.append(
Producer.new(
0,
0,
(Math.sqrt((0 - center_x)**2 + (0 - center_y) ** 2) * GAME_PRODUCER_VALUE_MULT).to_i,
GAME_PRODUCER_BASE_SPEED,
BOX_SIZE,
WIDTH,
HEIGHT,
)
)
@producers.append(
Producer.new(
2,
2,
(Math.sqrt((2 - center_x)**2 + (2 - center_y) ** 2) * GAME_PRODUCER_VALUE_MULT).to_i,
GAME_PRODUCER_BASE_SPEED,
BOX_SIZE,
WIDTH,
HEIGHT,
)
)
@producers.append(
Producer.new(
2,
0,
(Math.sqrt((2 - center_x)**2 + (0 - center_y) ** 2) * GAME_PRODUCER_VALUE_MULT).to_i,
GAME_PRODUCER_BASE_SPEED,
BOX_SIZE,
WIDTH,
HEIGHT,
)
)
@producers.append(
Producer.new(
0,
2,
(Math.sqrt((0 - center_x)**2 + (2 - center_y) ** 2) * GAME_PRODUCER_VALUE_MULT).to_i,
GAME_PRODUCER_BASE_SPEED,
BOX_SIZE,
WIDTH,
HEIGHT,
)
)
@producers.append(
Producer.new(
10,
10,
1000,
GAME_PRODUCER_BASE_SPEED,
BOX_SIZE,
WIDTH,
HEIGHT,
)
)
end # End file loading end # End file loading
# Move the camera to the center of the map: # Move the camera to the center of the map:
@@ -219,15 +164,15 @@ class NumFactory < Gosu::Window
### CAMERA ### ### CAMERA ###
# Move the camera if needed # Move the camera if needed
if self.mouse_x < CAMERA_MOVE_RANGE if self.mouse_x < CAMERA_MOVE_RANGE
@camera_x -= 1#([(CAMERA_MOVE_SPEED * ((CAMERA_MOVE_RANGE - self.mouse_x ) / 2)).to_i, CAMERA_MOVE_MAX_SPEED].min * delta_mult) @camera_x -= ([(CAMERA_MOVE_SPEED * ((CAMERA_MOVE_RANGE - self.mouse_x ) / 5)).to_i, CAMERA_MOVE_MAX_SPEED].min * delta_mult)
elsif self.mouse_x > WIDTH - CAMERA_MOVE_RANGE elsif self.mouse_x > WIDTH - CAMERA_MOVE_RANGE
@camera_x += 1#([(CAMERA_MOVE_SPEED * ((CAMERA_MOVE_RANGE - (WIDTH - self.mouse_x) ) / 2)).to_i, CAMERA_MOVE_MAX_SPEED].min * delta_mult) @camera_x += ([(CAMERA_MOVE_SPEED * ((CAMERA_MOVE_RANGE - (WIDTH - self.mouse_x) ) / 2)).to_i, CAMERA_MOVE_MAX_SPEED].min * delta_mult)
end end
if self.mouse_y < CAMERA_MOVE_RANGE if self.mouse_y < CAMERA_MOVE_RANGE
@camera_y -= 1#([(CAMERA_MOVE_SPEED * ((CAMERA_MOVE_RANGE - self.mouse_y ) / 2)).to_i, CAMERA_MOVE_MAX_SPEED].min * delta_mult) @camera_y -= ([(CAMERA_MOVE_SPEED * ((CAMERA_MOVE_RANGE - self.mouse_y ) / 2)).to_i, CAMERA_MOVE_MAX_SPEED].min * delta_mult)
elsif self.mouse_y > HEIGHT - CAMERA_MOVE_RANGE elsif self.mouse_y > HEIGHT - CAMERA_MOVE_RANGE
@camera_y += 1#([(CAMERA_MOVE_SPEED * ((CAMERA_MOVE_RANGE - (HEIGHT - (self.mouse_y + 1)) ) / 2)).to_i, CAMERA_MOVE_MAX_SPEED].min * delta_mult) @camera_y += ([(CAMERA_MOVE_SPEED * ((CAMERA_MOVE_RANGE - (HEIGHT - (self.mouse_y + 1)) ) / 2)).to_i, CAMERA_MOVE_MAX_SPEED].min * delta_mult)
end end
# Prevent camera from leaving the screen # Prevent camera from leaving the screen