Merge branch 'stage/molecular' of ssh://git.djairo.dev:2222/djairoh/notSpore into stage/molecular

This commit is contained in:
Djairo Hougee 2026-01-17 13:01:57 +01:00
commit 5811658c64
15 changed files with 328 additions and 29 deletions

View File

@ -0,0 +1,23 @@
extends Node
var screen_size = Vector2(1920.0, 1080.0) # Default screen size (this is a float for some reason)
var viewport_size
func _ready() -> void:
viewport_size = get_viewport().get_visible_rect().size
# TODO: This needs to be called from a script inheriting a CharacterBody2D (e.g. the player)
# Alternative would be to pass the player reference to this script (which might be better?)
func init_screen_size(x:float, y:float) -> void:
screen_size.x = x
screen_size.y = y
# This can take a vector of any size (but should be 2d, other components are unused)
func get_boundaried_position(position):
## clamp
#return position.clamp(Vector2.ZERO, screen_size)
## periodic
position.x = wrapf(position.x, 0, screen_size.x)
position.y = wrapf(position.y, 0, screen_size.y)
return position

View File

@ -0,0 +1 @@
uid://vsbibc5fanou

View File

Before

Width:  |  Height:  |  Size: 72 KiB

After

Width:  |  Height:  |  Size: 72 KiB

View File

@ -3,15 +3,15 @@
importer="texture" importer="texture"
type="CompressedTexture2D" type="CompressedTexture2D"
uid="uid://dnlrq8gxiix6" uid="uid://dnlrq8gxiix6"
path="res://.godot/imported/bg-far-placeholder.jpg-f6a73992ff3dd38240865e4558592bbf.ctex" path="res://.godot/imported/bg-far-placeholder.jpg-01304d9c071eca65de57b4adc0479e81.ctex"
metadata={ metadata={
"vram_texture": false "vram_texture": false
} }
[deps] [deps]
source_file="res://molecular/assets/bg-far-placeholder.jpg" source_file="res://molecular/assets/background/bg-far-placeholder.jpg"
dest_files=["res://.godot/imported/bg-far-placeholder.jpg-f6a73992ff3dd38240865e4558592bbf.ctex"] dest_files=["res://.godot/imported/bg-far-placeholder.jpg-01304d9c071eca65de57b4adc0479e81.ctex"]
[params] [params]

Binary file not shown.

After

Width:  |  Height:  |  Size: 450 B

View File

@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://c3cuhrmulyy1s"
path="res://.godot/imported/bg-near.png-00577ad303726b65cb5579d462bbdf09.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://molecular/assets/background/bg-near.png"
dest_files=["res://.godot/imported/bg-near.png-00577ad303726b65cb5579d462bbdf09.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

Binary file not shown.

After

Width:  |  Height:  |  Size: 960 B

View File

@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bto1pnycvianp"
path="res://.godot/imported/bg.png-84a173f3a1de937d0ba2884af46d549b.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://molecular/assets/background/bg.png"
dest_files=["res://.godot/imported/bg.png-84a173f3a1de937d0ba2884af46d549b.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

@ -3,15 +3,15 @@
importer="texture" importer="texture"
type="CompressedTexture2D" type="CompressedTexture2D"
uid="uid://bfjf6dxvbq5cj" uid="uid://bfjf6dxvbq5cj"
path="res://.godot/imported/dirt-specs.png-ba680203b0a1b1c73166838cd341279d.ctex" path="res://.godot/imported/dirt-specs.png-ef6f8fd578fedf9d185ca3625a87c7c3.ctex"
metadata={ metadata={
"vram_texture": false "vram_texture": false
} }
[deps] [deps]
source_file="res://dirt-specs.png" source_file="res://molecular/assets/background/dirt-specs.png"
dest_files=["res://.godot/imported/dirt-specs.png-ba680203b0a1b1c73166838cd341279d.ctex"] dest_files=["res://.godot/imported/dirt-specs.png-ef6f8fd578fedf9d185ca3625a87c7c3.ctex"]
[params] [params]

View File

@ -1,11 +1,11 @@
extends CharacterBody2D extends CharacterBody2D
@export var speed = 200 @export var speed = 200
var screen_size
var damage = 1 var damage = 1
func _ready(): func _ready() -> void:
screen_size = get_viewport_rect().size var screen_size = get_viewport_rect().size
GameManager.init_screen_size(screen_size.x, screen_size.y)
func _process(delta): func _process(delta):
velocity = Vector2.ZERO velocity = Vector2.ZERO
@ -20,4 +20,5 @@ func _process(delta):
move_and_collide(speed * velocity * delta) move_and_collide(speed * velocity * delta)
#position += speed * velocity * delta #position += speed * velocity * delta
position = position.clamp(Vector2.ZERO, screen_size) position = GameManager.get_boundaried_position(position)

File diff suppressed because one or more lines are too long

View File

@ -2,21 +2,39 @@ extends AbstractPrey2D
@onready var sprite = get_node("AnimatedSprite2D") @onready var sprite = get_node("AnimatedSprite2D")
# Mirroed sprites for periodic boundary
var mirrorSprite1: Node2D
var mirrorSprite2: Node2D
var mirrorSprite3: Node2D
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready() -> void: func _ready() -> void:
$AnimatedSprite2D.animation = "Healthy" $AnimatedSprite2D.animation = "Healthy"
$AnimatedSprite2D.play() $AnimatedSprite2D.play()
mirrorSprite1 = sprite.duplicate()
mirrorSprite2 = sprite.duplicate()
mirrorSprite3 = sprite.duplicate()
add_child(mirrorSprite1)
add_child(mirrorSprite2)
add_child(mirrorSprite3)
# Called every frame. 'delta' is the elapsed time since the previous frame. # Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void: func _process(delta: float) -> void:
return # Boundary mirroring
_handle_wrapping()
func _physics_process(delta: float) -> void: func _physics_process(delta: float) -> void:
self.move(Vector3(randfn(0, 1), randfn(0, 1), 0)) self.move(Vector3(randfn(0, 1), randfn(0, 1), 0))
func move(destination: Vector3) -> void: func move(motion: Vector3) -> void:
move_and_collide(Vector2(destination.x, destination.y)) move_and_collide(Vector2(motion.x, motion.y)) # Moves along the given vector
# Apply boundary to new position
position = GameManager.get_boundaried_position(position)
func die() -> void: func die() -> void:
sprite.play("Dying") sprite.play("Dying")
@ -38,3 +56,94 @@ func handle_collision_player(player):
self.die() self.die()
else: else:
sprite.play("Injured") sprite.play("Injured")
# FIXME: Doesn't work with injured sprite
# Mirroring table:
# |---|---|---|---|
# | 4 | 3 | 4 | 3 |
# |---|===|===|---|
# | 1 ǁ 2 | 1 ǁ 2 |
# |---ǁ---|---ǁ---|
# | 4 ǁ 3 | 4 ǁ 3 |
# |---|===|===|---|
# | 1 | 2 | 1 | 2 |
# |---|---|---|---|
# If less than viewport size away from an edge, mirror over that edge (for seamless boundary)
# NOTE: For this to look correctly the camera size should be smaller than half the screen port (in
# any one dimension. Ideally, the difference between camera size and half the screen port is
# at least the size of the prey sprite)
func _handle_wrapping():
mirrorSprite1.visible = false
mirrorSprite2.visible = false
mirrorSprite3.visible = false
# TODO: Assume viewport size << screen size and only draw according to GameManager.viewport_size
# Find corresponding section of the screen
if position.x < GameManager.screen_size.x/2 and position.y < GameManager.screen_size.y/2:
# 2
mirrorSprite1.visible = true
mirrorSprite2.visible = true
mirrorSprite3.visible = true
# Right
#mirrorSprite1.position = Vector2(sprite.position.x + GameManager.screen_size.x, sprite.position.y)
mirrorSprite1.position = Vector2(GameManager.screen_size.x, 0)
# Diag
#mirrorSprite2.position = Vector2(sprite.position.x + GameManager.screen_size.x, sprite.position.y + GameManager.screen_size.y)
mirrorSprite3.position = Vector2(GameManager.screen_size.x, GameManager.screen_size.y)
# Bottom
#mirrorSprite3.position = Vector2(sprite.position.x, sprite.position.y + GameManager.screen_size.y)
mirrorSprite2.position = Vector2(0, GameManager.screen_size.y)
elif position.x < GameManager.screen_size.x/2:
# 3
mirrorSprite1.visible = true
mirrorSprite2.visible = true
mirrorSprite3.visible = true
# Top
#mirrorSprite1.position = Vector2(sprite.position.x, sprite.position.y - GameManager.screen_size.y)
mirrorSprite1.position = Vector2(0, - GameManager.screen_size.y)
# Diag
#mirrorSprite2.position = Vector2(sprite.position.x + GameManager.screen_size.x, sprite.position.y - GameManager.screen_size.y)
mirrorSprite2.position = Vector2(GameManager.screen_size.x, - GameManager.screen_size.y)
# Right
#mirrorSprite3.position = Vector2(sprite.position.x + GameManager.screen_size.x, sprite.position.y)
mirrorSprite3.position = Vector2(GameManager.screen_size.x, 0)
elif position.y < GameManager.screen_size.y/2:
# 1
mirrorSprite1.visible = true
mirrorSprite2.visible = true
mirrorSprite3.visible = true
# Left
#mirrorSprite1.position = Vector2(sprite.position.x - GameManager.screen_size.x, sprite.position.y)
mirrorSprite1.position = Vector2(- GameManager.screen_size.x, 0)
# Bottom
#mirrorSprite2.position = Vector2(sprite.position.x, sprite.position.y + GameManager.screen_size.y)
mirrorSprite2.position = Vector2(0, GameManager.screen_size.y)
# Diag
#mirrorSprite3.position = Vector2(sprite.position.x - GameManager.screen_size.x, sprite.position.y + GameManager.screen_size.y)
mirrorSprite3.position = Vector2(- GameManager.screen_size.x, GameManager.screen_size.y)
else:
# 4
mirrorSprite1.visible = true
mirrorSprite2.visible = true
mirrorSprite3.visible = true
# Left
#mirrorSprite1.position = Vector2(sprite.position.x - GameManager.screen_size.x, sprite.position.y)
mirrorSprite1.position = Vector2(- GameManager.screen_size.x, 0)
# Diag
#mirrorSprite2.position = Vector2(sprite.position.x - GameManager.screen_size.x, sprite.position.y - GameManager.screen_size.y)
mirrorSprite2.position = Vector2(- GameManager.screen_size.x, - GameManager.screen_size.y)
# Top
#mirrorSprite3.position = Vector2(sprite.position.x, sprite.position.y - GameManager.screen_size.y)
mirrorSprite3.position = Vector2(0, - GameManager.screen_size.y)

View File

@ -0,0 +1,28 @@
extends Node
var preyScene = preload("res://molecular/nucleotide_prey.tscn")
#var predatorScene = preload("res://Predator.tscn")
var score
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
for i in range(0, 100, 10):
spawn_creature(preyScene, Vector2(i, i))
spawn_random()
spawn_random()
spawn_random()
spawn_random()
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
func spawn_random() -> void:
spawn_creature(preyScene, Vector2(randfn(100, 100), randfn(100, 100)))
func spawn_creature(scene, position: Vector2) -> void:
var instance = scene.instantiate()
instance.position = position
add_child(instance)

View File

@ -15,6 +15,10 @@ run/main_scene="uid://drgv154ei1vrl"
config/features=PackedStringArray("4.5", "Forward Plus") config/features=PackedStringArray("4.5", "Forward Plus")
config/icon="res://icon.svg" config/icon="res://icon.svg"
[autoload]
GameManager="*res://game_manager.gd"
[global_group] [global_group]
player="All scenes that constitute players should be added here." player="All scenes that constitute players should be added here."
@ -46,3 +50,7 @@ move_down={
2d_render/layer_1="Player" 2d_render/layer_1="Player"
2d_render/layer_2="Prey" 2d_render/layer_2="Prey"
[rendering]
textures/canvas_textures/default_texture_filter=0