among-eux

Game made in 1 day with flx
git clone git://git.vgx.fr/among-eux
Log | Files | Refs

commit 47f9b5d4a6e138a54f802b779d52d5b5f0eb07ac
parent 045f46e013b2207b1654de436e21693a825365a7
Author: Léo Villeveygoux <l@vgx.fr>
Date:   Sun, 28 Aug 2022 18:18:40 +0200

Evil people, random spawn

Diffstat:
MLevel.gd | 9+++++++++
MLevel.tscn | 33++++++---------------------------
MPublic.gd | 13++++++++++++-
MPublic.tscn | 131+++----------------------------------------------------------------------------
Martsrc/pnj1_sheet.aseprite | 0
5 files changed, 31 insertions(+), 155 deletions(-)

diff --git a/Level.gd b/Level.gd @@ -4,6 +4,9 @@ export var lvl = 1 var safe_radius = 40.0 +var public_scn = preload("res://Public.tscn") +var evil_scn = preload("res://Evil.tscn") + #func _ready(): # $President.position = Vector2(safe_radius, get_viewport_rect().size.y/2) # $Guard.position = Vector2(safe_radius, get_viewport_rect().size.y/2 - safe_radius*2) @@ -11,6 +14,12 @@ var safe_radius = 40.0 func _ready(): $LvlLabel.text = "lvl: " + String(lvl) + for i in range(int(10+lvl*2)): + $YSort.add_child(public_scn.instance()) + for i in range(int((lvl-1)*2)): + $YSort.add_child(evil_scn.instance()) + + func _physics_process(_delta): if $YSort/President.position.x + safe_radius > get_viewport_rect().size.x: diff --git a/Level.tscn b/Level.tscn @@ -1,8 +1,7 @@ -[gd_scene load_steps=55 format=2] +[gd_scene load_steps=54 format=2] [ext_resource path="res://Level.gd" type="Script" id=1] [ext_resource path="res://President.gd" type="Script" id=2] -[ext_resource path="res://Public.tscn" type="PackedScene" id=3] [ext_resource path="res://Guard.gd" type="Script" id=4] [ext_resource path="res://graphics/guard_sheet.png" type="Texture" id=5] [ext_resource path="res://graphics/president_sheet.png" type="Texture" id=6] @@ -313,7 +312,7 @@ shape = SubResource( 3 ) [node name="Sprite" type="AnimatedSprite" parent="YSort/President"] frames = SubResource( 24 ) animation = "up" -frame = 1 +frame = 2 playing = true __meta__ = { "_edit_lock_": true @@ -322,6 +321,9 @@ __meta__ = { [node name="Guard" type="KinematicBody2D" parent="YSort"] position = Vector2( 48, 90 ) script = ExtResource( 4 ) +__meta__ = { +"_edit_group_": true +} [node name="Sprite" type="AnimatedSprite" parent="YSort/Guard"] frames = SubResource( 45 ) @@ -334,34 +336,11 @@ rotation = 1.5708 shape = SubResource( 3 ) [node name="Dash" type="Sprite" parent="YSort/Guard"] +visible = false position = Vector2( 0, -33.0625 ) scale = Vector2( 0.01, 2 ) texture = SubResource( 49 ) -[node name="Public" parent="YSort" instance=ExtResource( 3 )] -position = Vector2( 152, 250 ) - -[node name="Public2" parent="YSort" instance=ExtResource( 3 )] -position = Vector2( 285, 78 ) - -[node name="Public3" parent="YSort" instance=ExtResource( 3 )] -position = Vector2( 277, 189 ) - -[node name="Public4" parent="YSort" instance=ExtResource( 3 )] -position = Vector2( 156, 66 ) - -[node name="Public5" parent="YSort" instance=ExtResource( 3 )] -position = Vector2( 255, 248 ) - -[node name="Public6" parent="YSort" instance=ExtResource( 3 )] -position = Vector2( 176, 139 ) - -[node name="Public7" parent="YSort" instance=ExtResource( 3 )] -position = Vector2( 395, 266 ) - -[node name="Public8" parent="YSort" instance=ExtResource( 3 )] -position = Vector2( 409, 123 ) - [node name="LvlLabel" type="Label" parent="."] margin_left = 438.0 margin_top = 7.0 diff --git a/Public.gd b/Public.gd @@ -3,8 +3,19 @@ extends RigidBody2D export var max_speed = 20.0 export var force = 20.0 -func _ready(): +var pnj_frames = [preload("res://PNJ1frames.tres"), preload("res://PNJ2frames.tres"), preload("res://PNJ3frames.tres")] + +func init(): max_speed = rand_range(0, max_speed) + + var vp_size = get_viewport_rect().size + position.x = rand_range(vp_size.x/10, vp_size.x-30.0) + position.y = rand_range(30.0, vp_size.y-30.0) + + $Sprite.frames = pnj_frames[randi()%3] + +func _ready(): + init() func _process(_delta): $Sprite.rotation = -rotation diff --git a/Public.tscn b/Public.tscn @@ -1,130 +1,7 @@ -[gd_scene load_steps=25 format=2] +[gd_scene load_steps=4 format=2] +[ext_resource path="res://PNJ2frames.tres" type="SpriteFrames" id=1] [ext_resource path="res://Public.gd" type="Script" id=2] -[ext_resource path="res://graphics/pnj1_sheet.png" type="Texture" id=3] - -[sub_resource type="AtlasTexture" id=2] -flags = 4 -atlas = ExtResource( 3 ) -region = Rect2( 0, 120, 60, 60 ) - -[sub_resource type="AtlasTexture" id=3] -flags = 4 -atlas = ExtResource( 3 ) -region = Rect2( 60, 120, 60, 60 ) - -[sub_resource type="AtlasTexture" id=4] -flags = 4 -atlas = ExtResource( 3 ) -region = Rect2( 120, 120, 60, 60 ) - -[sub_resource type="AtlasTexture" id=5] -flags = 4 -atlas = ExtResource( 3 ) -region = Rect2( 180, 120, 60, 60 ) - -[sub_resource type="AtlasTexture" id=6] -flags = 4 -atlas = ExtResource( 3 ) -region = Rect2( 0, 60, 60, 60 ) - -[sub_resource type="AtlasTexture" id=7] -flags = 4 -atlas = ExtResource( 3 ) -region = Rect2( 60, 60, 60, 60 ) - -[sub_resource type="AtlasTexture" id=8] -flags = 4 -atlas = ExtResource( 3 ) -region = Rect2( 120, 60, 60, 60 ) - -[sub_resource type="AtlasTexture" id=9] -flags = 4 -atlas = ExtResource( 3 ) -region = Rect2( 180, 60, 60, 60 ) - -[sub_resource type="AtlasTexture" id=10] -flags = 4 -atlas = ExtResource( 3 ) -region = Rect2( 240, 60, 60, 60 ) - -[sub_resource type="AtlasTexture" id=11] -flags = 4 -atlas = ExtResource( 3 ) -region = Rect2( 300, 60, 60, 60 ) - -[sub_resource type="AtlasTexture" id=12] -flags = 4 -atlas = ExtResource( 3 ) -region = Rect2( 0, 0, 60, 60 ) - -[sub_resource type="AtlasTexture" id=13] -flags = 4 -atlas = ExtResource( 3 ) -region = Rect2( 60, 0, 60, 60 ) - -[sub_resource type="AtlasTexture" id=14] -flags = 4 -atlas = ExtResource( 3 ) -region = Rect2( 120, 0, 60, 60 ) - -[sub_resource type="AtlasTexture" id=15] -flags = 4 -atlas = ExtResource( 3 ) -region = Rect2( 180, 0, 60, 60 ) - -[sub_resource type="AtlasTexture" id=16] -flags = 4 -atlas = ExtResource( 3 ) -region = Rect2( 240, 0, 60, 60 ) - -[sub_resource type="AtlasTexture" id=17] -flags = 4 -atlas = ExtResource( 3 ) -region = Rect2( 300, 0, 60, 60 ) - -[sub_resource type="AtlasTexture" id=18] -flags = 4 -atlas = ExtResource( 3 ) -region = Rect2( 0, 180, 60, 60 ) - -[sub_resource type="AtlasTexture" id=19] -flags = 4 -atlas = ExtResource( 3 ) -region = Rect2( 60, 180, 60, 60 ) - -[sub_resource type="AtlasTexture" id=20] -flags = 4 -atlas = ExtResource( 3 ) -region = Rect2( 120, 180, 60, 60 ) - -[sub_resource type="AtlasTexture" id=21] -flags = 4 -atlas = ExtResource( 3 ) -region = Rect2( 180, 180, 60, 60 ) - -[sub_resource type="SpriteFrames" id=22] -animations = [ { -"frames": [ SubResource( 2 ), SubResource( 3 ), SubResource( 4 ), SubResource( 5 ) ], -"loop": true, -"name": "down", -"speed": 5.0 -}, { -"frames": [ SubResource( 6 ), SubResource( 7 ), SubResource( 8 ), SubResource( 9 ), SubResource( 10 ), SubResource( 11 ) ], -"loop": true, -"name": "left", -"speed": 5.0 -}, { -"frames": [ SubResource( 12 ), SubResource( 13 ), SubResource( 14 ), SubResource( 15 ), SubResource( 16 ), SubResource( 17 ) ], -"loop": true, -"name": "right", -"speed": 5.0 -}, { -"frames": [ SubResource( 18 ), SubResource( 19 ), SubResource( 20 ), SubResource( 21 ) ], -"loop": true, -"name": "up", -"speed": 5.0 -} ] [sub_resource type="CircleShape2D" id=23] radius = 14.1421 @@ -138,9 +15,9 @@ __meta__ = { } [node name="Sprite" type="AnimatedSprite" parent="."] -frames = SubResource( 22 ) +frames = ExtResource( 1 ) animation = "down" -frame = 1 +frame = 2 playing = true [node name="CollisionShape2D" type="CollisionShape2D" parent="."] diff --git a/artsrc/pnj1_sheet.aseprite b/artsrc/pnj1_sheet.aseprite Binary files differ.