Various adding : camera, ground texture...
This commit is contained in:
34
scripts/camera.gd
Normal file
34
scripts/camera.gd
Normal file
@@ -0,0 +1,34 @@
|
||||
extends Camera2D
|
||||
|
||||
const MOVEMENT_SPEED = 200
|
||||
const ZOOM_SPEED = 10
|
||||
const ZOOM_WINDOW = [0.5, 2]
|
||||
const BORDER_THRESHOLD = 50
|
||||
|
||||
var movement = Vector2()
|
||||
var zoom_change = 0
|
||||
|
||||
|
||||
func _process(delta):
|
||||
movement = Vector2()
|
||||
zoom_change = 0
|
||||
|
||||
if Input.is_action_pressed("ui_right"):
|
||||
movement.x = 1
|
||||
if Input.is_action_pressed("ui_left"):
|
||||
movement.x = -1
|
||||
if Input.is_action_pressed("ui_up"):
|
||||
movement.y = -1
|
||||
if Input.is_action_pressed("ui_down"):
|
||||
movement.y = 1
|
||||
|
||||
if Input.is_action_just_pressed("zoom"):
|
||||
zoom_change = 1
|
||||
if Input.is_action_just_pressed("dezoom"):
|
||||
zoom_change = -1
|
||||
|
||||
movement = movement.normalized()
|
||||
|
||||
var zoom_value = max(min(zoom.x + zoom_change*ZOOM_SPEED*delta, ZOOM_WINDOW[1]), ZOOM_WINDOW[0])
|
||||
zoom = Vector2(zoom_value, zoom_value)
|
||||
position = position+movement*MOVEMENT_SPEED*delta
|
||||
@@ -1,6 +1,15 @@
|
||||
class_name Map
|
||||
extends Node2D
|
||||
|
||||
func _ready():
|
||||
var map_size = GameTerrain.TERRAIN_SIZE * GameTerrain.MAP_RATIO
|
||||
|
||||
$Ground.set_polygon(PackedVector2Array([
|
||||
Vector2(0,0),
|
||||
Vector2(map_size.x, 0),
|
||||
Vector2(map_size.x, map_size.y),
|
||||
Vector2(0, map_size.y),
|
||||
]))
|
||||
|
||||
func _on_gui_scanner_selected(type : Scanners.Type):
|
||||
$Scanners.select_scanner(type)
|
||||
|
||||
@@ -6,7 +6,7 @@ shader_type canvas_item;
|
||||
uniform sampler2D gradient : source_color, filter_nearest;
|
||||
uniform int dimension;
|
||||
|
||||
const float alpha = 0.3;
|
||||
const float alpha = 0.5;
|
||||
const float strength = 0.5;
|
||||
const float pi = atan(1.0) * 4.0;
|
||||
const int samples = 35;
|
||||
|
||||
@@ -4,7 +4,7 @@ enum Stats {WATER, FERTILITY, PRESENCE}
|
||||
|
||||
const TERRAIN_SIZE = Vector2i(300, 300)
|
||||
const LEVELS_NUMBER : int = 10
|
||||
const MAP_RATIO = 4;
|
||||
const MAP_RATIO = 8;
|
||||
|
||||
@onready var image := Image.create_empty(
|
||||
TERRAIN_SIZE.x,
|
||||
|
||||
Reference in New Issue
Block a user