rudimentary world and player as of following tutorials 1&2

main
Adrian Pegler 2024-02-22 12:10:12 +01:00
parent b94071118e
commit 689e58f5fd
14 changed files with 321 additions and 0 deletions

2
.gitattributes vendored Normal file
View File

@ -0,0 +1,2 @@
# Normalize EOL for all files that Git considers text files.
* text=auto eol=lf

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
# Godot 4+ specific ignores
.godot/

1
icon.svg Normal file
View File

@ -0,0 +1 @@
<svg height="128" width="128" xmlns="http://www.w3.org/2000/svg"><rect x="2" y="2" width="124" height="124" rx="14" fill="#363d52" stroke="#212532" stroke-width="4"/><g transform="scale(.101) translate(122 122)"><g fill="#fff"><path d="M105 673v33q407 354 814 0v-33z"/><path fill="#478cbf" d="m105 673 152 14q12 1 15 14l4 67 132 10 8-61q2-11 15-15h162q13 4 15 15l8 61 132-10 4-67q3-13 15-14l152-14V427q30-39 56-81-35-59-83-108-43 20-82 47-40-37-88-64 7-51 8-102-59-28-123-42-26 43-46 89-49-7-98 0-20-46-46-89-64 14-123 42 1 51 8 102-48 27-88 64-39-27-82-47-48 49-83 108 26 42 56 81zm0 33v39c0 276 813 276 813 0v-39l-134 12-5 69q-2 10-14 13l-162 11q-12 0-16-11l-10-65H447l-10 65q-4 11-16 11l-162-11q-12-3-14-13l-5-69z"/><path d="M483 600c3 34 55 34 58 0v-86c-3-34-55-34-58 0z"/><circle cx="725" cy="526" r="90"/><circle cx="299" cy="526" r="90"/></g><g fill="#414042"><circle cx="307" cy="532" r="60"/><circle cx="717" cy="532" r="60"/></g></g></svg>

After

Width:  |  Height:  |  Size: 950 B

37
icon.svg.import Normal file
View File

@ -0,0 +1,37 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cvb07jl0jedyr"
path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://icon.svg"
dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
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/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
svg/scale=1.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false

44
player.gd Normal file
View File

@ -0,0 +1,44 @@
extends CharacterBody2D
const SPEED = 300.0
const JUMP_VELOCITY = -300.0
# Get the gravity from the project settings to be synced with RigidBody nodes.
var gravity = ProjectSettings.get_setting("physics/2d/default_gravity")
#own variables see tutorial 2
var is_jumping = false
@onready var animated_sprite_2d = $AnimatedSprite2D
func _physics_process(delta):
# Add the gravity.
if not is_on_floor():
velocity.y += gravity * delta
else:
is_jumping = false
# Handle jump.
if Input.is_action_just_pressed("ui_accept") and is_on_floor():
velocity.y = JUMP_VELOCITY
is_jumping = true
# Get the input direction and handle the movement/deceleration.
# As good practice, you should replace UI actions with custom gameplay actions.
var direction = Input.get_axis("ui_left", "ui_right")
if direction:
velocity.x = direction * SPEED
else:
velocity.x = move_toward(velocity.x, 0, SPEED)
update_animation(direction)
move_and_slide()
func update_animation(direction):
if is_jumping:
animated_sprite_2d.play("jump")
elif direction != 0:
animated_sprite_2d.flip_h = (direction < 0)
animated_sprite_2d.play("run")
else:
animated_sprite_2d.play("idle")

70
player.tscn Normal file
View File

@ -0,0 +1,70 @@
[gd_scene load_steps=10 format=3 uid="uid://c5njgaps6d3vn"]
[ext_resource type="Texture2D" uid="uid://bbaks8lekbw53" path="res://sprites/bazzabogan.png" id="1_6kthl"]
[ext_resource type="Script" path="res://player.gd" id="1_y8jpy"]
[sub_resource type="AtlasTexture" id="AtlasTexture_l3wuf"]
atlas = ExtResource("1_6kthl")
region = Rect2(0, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_nm0eg"]
atlas = ExtResource("1_6kthl")
region = Rect2(128, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_uadt3"]
atlas = ExtResource("1_6kthl")
region = Rect2(32, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_ewher"]
atlas = ExtResource("1_6kthl")
region = Rect2(64, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_gctgy"]
atlas = ExtResource("1_6kthl")
region = Rect2(96, 0, 32, 32)
[sub_resource type="SpriteFrames" id="SpriteFrames_bl6kg"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_l3wuf")
}],
"loop": true,
"name": &"idle",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_nm0eg")
}],
"loop": true,
"name": &"jump",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_uadt3")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ewher")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_gctgy")
}],
"loop": true,
"name": &"run",
"speed": 12.0
}]
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_vmep3"]
height = 32.0
[node name="player" type="CharacterBody2D"]
script = ExtResource("1_y8jpy")
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
sprite_frames = SubResource("SpriteFrames_bl6kg")
animation = &"run"
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource("CapsuleShape2D_vmep3")

22
project.godot Normal file
View File

@ -0,0 +1,22 @@
; Engine configuration file.
; It's best edited using the editor UI and not directly,
; since the parameters that go here are not all obvious.
;
; Format:
; [section] ; section goes between []
; param=value ; assign values to parameters
config_version=5
[application]
config/name="SuperMathio"
run/main_scene="res://world.tscn"
config/features=PackedStringArray("4.2", "GL Compatibility")
config/icon="res://icon.svg"
[rendering]
renderer/rendering_method="gl_compatibility"
renderer/rendering_method.mobile="gl_compatibility"
environment/defaults/default_clear_color=Color(0.560784, 0.835294, 1, 1)

BIN
sprites/bazzabogan.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bbaks8lekbw53"
path="res://.godot/imported/bazzabogan.png-1ff0b99cc899b197e52731c5bea0564c.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://sprites/bazzabogan.png"
dest_files=["res://.godot/imported/bazzabogan.png-1ff0b99cc899b197e52731c5bea0564c.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
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/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

BIN
sprites/block.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 179 B

34
sprites/block.png.import Normal file
View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://07it5xehcx0"
path="res://.godot/imported/block.png-5bbcdacea06057fdfa5559fd03e54f2c.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://sprites/block.png"
dest_files=["res://.godot/imported/block.png-5bbcdacea06057fdfa5559fd03e54f2c.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
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/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

BIN
sprites/brick.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 211 B

34
sprites/brick.png.import Normal file
View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://wifmfna0xx26"
path="res://.godot/imported/brick.png-77d98f5d32d031ca09e379b39ddb4c05.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://sprites/brick.png"
dest_files=["res://.godot/imported/brick.png-77d98f5d32d031ca09e379b39ddb4c05.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
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/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

41
world.tscn Normal file
View File

@ -0,0 +1,41 @@
[gd_scene load_steps=7 format=3 uid="uid://d25dmlkpt468c"]
[ext_resource type="Texture2D" uid="uid://07it5xehcx0" path="res://sprites/block.png" id="1_x4yy8"]
[ext_resource type="Texture2D" uid="uid://wifmfna0xx26" path="res://sprites/brick.png" id="2_h3orb"]
[ext_resource type="PackedScene" uid="uid://c5njgaps6d3vn" path="res://player.tscn" id="3_b84gf"]
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_brspi"]
resource_name = "block"
texture = ExtResource("1_x4yy8")
0:0/0 = 0
0:0/0/physics_layer_0/linear_velocity = Vector2(0, 0)
0:0/0/physics_layer_0/angular_velocity = 0.0
0:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8)
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_5rxdw"]
resource_name = "brick"
texture = ExtResource("2_h3orb")
0:0/0 = 0
0:0/0/physics_layer_0/linear_velocity = Vector2(0, 0)
0:0/0/physics_layer_0/angular_velocity = 0.0
0:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8)
[sub_resource type="TileSet" id="TileSet_pv314"]
physics_layer_0/collision_layer = 1
sources/0 = SubResource("TileSetAtlasSource_brspi")
sources/1 = SubResource("TileSetAtlasSource_5rxdw")
[node name="world" type="Node2D"]
[node name="TileMap" type="TileMap" parent="."]
tile_set = SubResource("TileSet_pv314")
format = 2
layer_0/tile_data = PackedInt32Array(2490368, 1, 0, 2555904, 1, 0, 2621440, 1, 0, 2490369, 1, 0, 2555905, 1, 0, 2621441, 1, 0, 2490370, 1, 0, 2555906, 1, 0, 2621442, 1, 0, 2490371, 1, 0, 2555907, 1, 0, 2621443, 1, 0, 2490372, 1, 0, 2555908, 1, 0, 2621444, 1, 0, 2490373, 1, 0, 2555909, 1, 0, 2621445, 1, 0, 2490374, 1, 0, 2555910, 1, 0, 2621446, 1, 0, 2490375, 1, 0, 2555911, 1, 0, 2621447, 1, 0, 2490376, 1, 0, 2555912, 1, 0, 2621448, 1, 0, 2490377, 1, 0, 2555913, 1, 0, 2621449, 1, 0, 2490378, 1, 0, 2555914, 1, 0, 2621450, 1, 0, 2490379, 1, 0, 2555915, 1, 0, 2621451, 1, 0, 2490380, 1, 0, 2555916, 1, 0, 2621452, 1, 0, 2490381, 1, 0, 2555917, 1, 0, 2621453, 1, 0, 2490382, 1, 0, 2555918, 1, 0, 2621454, 1, 0, 2490383, 1, 0, 2555919, 1, 0, 2621455, 1, 0, 2490384, 1, 0, 2555920, 1, 0, 2621456, 1, 0, 2490385, 1, 0, 2555921, 1, 0, 2621457, 1, 0, 2490386, 1, 0, 2555922, 1, 0, 2621458, 1, 0, 2490387, 1, 0, 2555923, 1, 0, 2621459, 1, 0, 2490388, 1, 0, 2555924, 1, 0, 2621460, 1, 0, 2490389, 1, 0, 2555925, 1, 0, 2621461, 1, 0, 2490390, 1, 0, 2555926, 1, 0, 2621462, 1, 0, 2490391, 1, 0, 2555927, 1, 0, 2621463, 1, 0, 2490392, 1, 0, 2555928, 1, 0, 2621464, 1, 0, 2490393, 1, 0, 2555929, 1, 0, 2621465, 1, 0, 2490394, 1, 0, 2555930, 1, 0, 2621466, 1, 0, 2490395, 1, 0, 2555931, 1, 0, 2621467, 1, 0, 2490396, 1, 0, 2555932, 1, 0, 2621468, 1, 0, 2490397, 1, 0, 2555933, 1, 0, 2621469, 1, 0, 2490398, 1, 0, 2555934, 1, 0, 2621470, 1, 0, 2490399, 1, 0, 2555935, 1, 0, 2621471, 1, 0, 2490400, 1, 0, 2555936, 1, 0, 2621472, 1, 0, 2490401, 1, 0, 2555937, 1, 0, 2621473, 1, 0, 2490402, 1, 0, 2555938, 1, 0, 2621474, 1, 0, 2490403, 1, 0, 2555939, 1, 0, 2621475, 1, 0, 2490404, 1, 0, 2555940, 1, 0, 2621476, 1, 0, 2490405, 1, 0, 2555941, 1, 0, 2621477, 1, 0, 2490406, 1, 0, 2555942, 1, 0, 2621478, 1, 0, 2490407, 1, 0, 2555943, 1, 0, 2621479, 1, 0, 2490408, 1, 0, 2555944, 1, 0, 2621480, 1, 0, 2490409, 1, 0, 2555945, 1, 0, 2621481, 1, 0, 2490410, 1, 0, 2555946, 1, 0, 2621482, 1, 0, 2490411, 1, 0, 2555947, 1, 0, 2621483, 1, 0, 2490412, 1, 0, 2555948, 1, 0, 2621484, 1, 0, 2490413, 1, 0, 2555949, 1, 0, 2621485, 1, 0, 2490414, 1, 0, 2555950, 1, 0, 2621486, 1, 0, 2490415, 1, 0, 2555951, 1, 0, 2621487, 1, 0, 2490416, 1, 0, 2555952, 1, 0, 2621488, 1, 0, 2490417, 1, 0, 2555953, 1, 0, 2621489, 1, 0, 2490418, 1, 0, 2555954, 1, 0, 2621490, 1, 0, 2490419, 1, 0, 2555955, 1, 0, 2621491, 1, 0, 2490420, 1, 0, 2555956, 1, 0, 2621492, 1, 0, 2490421, 1, 0, 2555957, 1, 0, 2621493, 1, 0, 2490422, 1, 0, 2555958, 1, 0, 2621494, 1, 0, 2490423, 1, 0, 2555959, 1, 0, 2621495, 1, 0, 2490424, 1, 0, 2555960, 1, 0, 2621496, 1, 0, 2490425, 1, 0, 2555961, 1, 0, 2621497, 1, 0, 2490426, 1, 0, 2555962, 1, 0, 2621498, 1, 0, 2490427, 1, 0, 2555963, 1, 0, 2621499, 1, 0, 2490428, 1, 0, 2555964, 1, 0, 2621500, 1, 0, 2490429, 1, 0, 2555965, 1, 0, 2621501, 1, 0, 2490430, 1, 0, 2555966, 1, 0, 2621502, 1, 0, 2490431, 1, 0, 2555967, 1, 0, 2621503, 1, 0, 2490432, 1, 0, 2555968, 1, 0, 2621504, 1, 0, 2490433, 1, 0, 2555969, 1, 0, 2621505, 1, 0, 2490434, 1, 0, 2555970, 1, 0, 2621506, 1, 0, 2490435, 1, 0, 2555971, 1, 0, 2621507, 1, 0, 2490436, 1, 0, 2555972, 1, 0, 2621508, 1, 0, 2490437, 1, 0, 2555973, 1, 0, 2621509, 1, 0, 2490438, 1, 0, 2555974, 1, 0, 2621510, 1, 0, 2490439, 1, 0, 2555975, 1, 0, 2621511, 1, 0, 2424863, 0, 0, 2424864, 0, 0, 1966119, 1, 0, 2031655, 1, 0, 2097191, 1, 0, 2162727, 1, 0, 2228263, 1, 0, 2293799, 1, 0, 2359335, 1, 0, 2424871, 1, 0, 1966120, 1, 0, 2031656, 1, 0, 2097192, 1, 0, 2162728, 1, 0, 2228264, 1, 0, 2293800, 1, 0, 2359336, 1, 0, 2424872, 1, 0, 1966121, 1, 0, 2031657, 1, 0, 2097193, 1, 0, 2162729, 1, 0, 2228265, 1, 0, 2293801, 1, 0, 2359337, 1, 0, 2424873, 1, 0)
[node name="player" parent="TileMap" instance=ExtResource("3_b84gf")]
position = Vector2(67, 521)
[node name="Camera2D" type="Camera2D" parent="TileMap/player"]
limit_left = 0
limit_top = 0
limit_bottom = 650