From 689e58f5fda97a07d816d489f4be6aaea237346a Mon Sep 17 00:00:00 2001 From: Adrian Pegler Date: Thu, 22 Feb 2024 12:10:12 +0100 Subject: [PATCH] rudimentary world and player as of following tutorials 1&2 --- .gitattributes | 2 + .gitignore | 2 + icon.svg | 1 + icon.svg.import | 37 ++++++++++++++++++ player.gd | 44 +++++++++++++++++++++ player.tscn | 70 ++++++++++++++++++++++++++++++++++ project.godot | 22 +++++++++++ sprites/bazzabogan.png | Bin 0 -> 1768 bytes sprites/bazzabogan.png.import | 34 +++++++++++++++++ sprites/block.png | Bin 0 -> 179 bytes sprites/block.png.import | 34 +++++++++++++++++ sprites/brick.png | Bin 0 -> 211 bytes sprites/brick.png.import | 34 +++++++++++++++++ world.tscn | 41 ++++++++++++++++++++ 14 files changed, 321 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 icon.svg create mode 100644 icon.svg.import create mode 100644 player.gd create mode 100644 player.tscn create mode 100644 project.godot create mode 100644 sprites/bazzabogan.png create mode 100644 sprites/bazzabogan.png.import create mode 100644 sprites/block.png create mode 100644 sprites/block.png.import create mode 100644 sprites/brick.png create mode 100644 sprites/brick.png.import create mode 100644 world.tscn diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..8ad74f7 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Normalize EOL for all files that Git considers text files. +* text=auto eol=lf diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4709183 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# Godot 4+ specific ignores +.godot/ diff --git a/icon.svg b/icon.svg new file mode 100644 index 0000000..b370ceb --- /dev/null +++ b/icon.svg @@ -0,0 +1 @@ + diff --git a/icon.svg.import b/icon.svg.import new file mode 100644 index 0000000..380de2f --- /dev/null +++ b/icon.svg.import @@ -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 diff --git a/player.gd b/player.gd new file mode 100644 index 0000000..433e465 --- /dev/null +++ b/player.gd @@ -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") + diff --git a/player.tscn b/player.tscn new file mode 100644 index 0000000..3840e9d --- /dev/null +++ b/player.tscn @@ -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") diff --git a/project.godot b/project.godot new file mode 100644 index 0000000..9e333de --- /dev/null +++ b/project.godot @@ -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) diff --git a/sprites/bazzabogan.png b/sprites/bazzabogan.png new file mode 100644 index 0000000000000000000000000000000000000000..c11fd2ccbd8734ebbf0f5144f0387a8b0bb56a5c GIT binary patch literal 1768 zcmVP)Px*qDe$SRCt{2oNa6rMHt6_t0IWK0F}^E!%J-g0)nVj6Wd0x9|}|vj79?b#XzVe zpcpaKM8A+gqKPPo!JyR;ZAg46mYj`}s!5AMgajdiRR|Uoib8?31`y2oVRw2r)7ib< zd+AnheqZixcV?bv<}S~Fo|)ORaG`2+@7tJL8J}1HEvHhe9F`xs-v4a-;fCUs(YFEjvzU+th&cBiH-y=Et{td;O4qsH>tz z0S$%_$=XSn^%JK7@JqpEAo!}A=EOw5_)#{;e%3;Ew_^{5<&g; zI8ig8FbZfegovvGKK;~@HdWq20=gU;t?^m_=) zk0ZZcumDQO4+ErCN`Y4K)YVT-y;RGm^?YQeFbZfeghn=iwe#MZofbez#QxlK z@gD#xr{!zQM?bOsTij;fPv{5GS5e)@L#-!Jl~1tt!y|xnW>agY<5J2`F-Xc2`(TEB z(NR7PT0a6Pu9o`d69AM>v2*P&cb~QZR?Qp>KzUiAXRcX)%zn*pkvID4t84}ALZ6#1 zSvV;MFnNNlw6AXdA+3I73ZsAqLx^}Opyz*Xq{`6WMoFJVBo_3H7z{w`0ekf=zFOx` z@dU3d?XUnIz0=M;5?1{@Pee4fbvp0z9s9DvsmdlktL0W~9Bct>Sbo`;zds%CA<@se zg(Viix`w09_}lIKRsPR5@3H_M7&Az^F4|YeJsI)-`I`a7StETCtLu?B4~a__#P@ww z_Pk$a0X$YaTlyV#T$0;W$K|8V%@)9{G4k(M*qL?8D4@ZR^CZmyTMu+u0CVcTcOr?u z9H73r$^v+5w%&x>>gU$gw*xT0(#{3Ms$8UIjkdgs+y0?{{&ZgT_98WI_2h9m-!s!G zU*Xwad{tCFX(DpLbqz;7>&NL;01M#Z+H#-uY{Zl5V&;)|!?hMbL(5Q6B;a`Zv#Y@Z zc)iIUk2iMw;rtHlnMU!Fg8eD@%}zW7WFEeH2!gg zJBXj_qWv=`PXg}yuwh{o&|nA=S2Ykhf!n@RV{4~WSLAFeYd^IA`=hqr&SlidAER;Pb%-$#N1O8(tD;YJJKrii?@aJKs@ z0N?%mm-fVsP{4tPQ9y$sM3O3Cd>^XMeW`A;aw5{H5#M7@F14q&lWmgqKY@OE(z+k~ zkrYtm@LQtC0cdP<`)7h=`;sZIh5}k81o|qP-*N*DqkslOi2MuK*wN8FV6=Gv0000< KMNUMnLSTYrMQT+5 literal 0 HcmV?d00001 diff --git a/sprites/bazzabogan.png.import b/sprites/bazzabogan.png.import new file mode 100644 index 0000000..c6622f4 --- /dev/null +++ b/sprites/bazzabogan.png.import @@ -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 diff --git a/sprites/block.png b/sprites/block.png new file mode 100644 index 0000000000000000000000000000000000000000..1e99a7183141193449300ceca1b667b3a02c92e6 GIT binary patch literal 179 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|ay?xfLo9mV zPCCfjV8FxN-&JZA681tNZlQDPf=`T5S}GawHXEk6ulcdWBThxMJl)MQy=k{_@*FN^ zmWIF+f_99`6U=xvY&(6%`r*$f>^1TQFCF72S$iri4dFG`P77h9#*w>LJ@Eyyr1* zTP8VcMH^$^GY`SwYFptAE!;C4PlPmz*dF9gUDx>J&$Ocb%vB*4lS<;O?*kpi;OXk; Jvd$@?2>=Z9P;vkO literal 0 HcmV?d00001 diff --git a/sprites/brick.png.import b/sprites/brick.png.import new file mode 100644 index 0000000..0fef717 --- /dev/null +++ b/sprites/brick.png.import @@ -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 diff --git a/world.tscn b/world.tscn new file mode 100644 index 0000000..49f06bf --- /dev/null +++ b/world.tscn @@ -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