mirror of
				https://github.com/godotrecipes/2d_platform_basic.git
				synced 2025-11-01 03:01:05 +08:00 
			
		
		
		
	updates
This commit is contained in:
		
							
								
								
									
										2
									
								
								.gitattributes
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								.gitattributes
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,2 @@ | ||||
| # Normalize EOL for all files that Git considers text files. | ||||
| * text=auto eol=lf | ||||
							
								
								
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,2 @@ | ||||
| # Godot 4+ specific ignores | ||||
| .godot/ | ||||
							
								
								
									
										
											BIN
										
									
								
								assets/tileBlack_01.png
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								assets/tileBlack_01.png
									
									
									
									
									
										Executable file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 859 B | 
							
								
								
									
										34
									
								
								assets/tileBlack_01.png.import
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								assets/tileBlack_01.png.import
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,34 @@ | ||||
| [remap] | ||||
|  | ||||
| importer="texture" | ||||
| type="CompressedTexture2D" | ||||
| uid="uid://puaqodjkjijx" | ||||
| path="res://.godot/imported/tileBlack_01.png-fbd6bf9f5439ded044597cfd73a5e107.ctex" | ||||
| metadata={ | ||||
| "vram_texture": false | ||||
| } | ||||
|  | ||||
| [deps] | ||||
|  | ||||
| source_file="res://assets/tileBlack_01.png" | ||||
| dest_files=["res://.godot/imported/tileBlack_01.png-fbd6bf9f5439ded044597cfd73a5e107.ctex"] | ||||
|  | ||||
| [params] | ||||
|  | ||||
| compress/mode=0 | ||||
| compress/lossy_quality=0.7 | ||||
| compress/hdr_compression=1 | ||||
| compress/bptc_ldr=0 | ||||
| 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
										
									
								
								assets/tileYellow_02.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								assets/tileYellow_02.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 1.0 KiB | 
							
								
								
									
										34
									
								
								assets/tileYellow_02.png.import
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								assets/tileYellow_02.png.import
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,34 @@ | ||||
| [remap] | ||||
|  | ||||
| importer="texture" | ||||
| type="CompressedTexture2D" | ||||
| uid="uid://cws3unmxr0p5d" | ||||
| path="res://.godot/imported/tileYellow_02.png-8aeb47b60fb599d000fe8503457daccf.ctex" | ||||
| metadata={ | ||||
| "vram_texture": false | ||||
| } | ||||
|  | ||||
| [deps] | ||||
|  | ||||
| source_file="res://assets/tileYellow_02.png" | ||||
| dest_files=["res://.godot/imported/tileYellow_02.png-8aeb47b60fb599d000fe8503457daccf.ctex"] | ||||
|  | ||||
| [params] | ||||
|  | ||||
| compress/mode=0 | ||||
| compress/lossy_quality=0.7 | ||||
| compress/hdr_compression=1 | ||||
| compress/bptc_ldr=0 | ||||
| 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 | ||||
							
								
								
									
										34
									
								
								icon.png.import
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								icon.png.import
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,34 @@ | ||||
| [remap] | ||||
|  | ||||
| importer="texture" | ||||
| type="CompressedTexture2D" | ||||
| uid="uid://bfi2hxm80pbrv" | ||||
| path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex" | ||||
| metadata={ | ||||
| "vram_texture": false | ||||
| } | ||||
|  | ||||
| [deps] | ||||
|  | ||||
| source_file="res://icon.png" | ||||
| dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"] | ||||
|  | ||||
| [params] | ||||
|  | ||||
| compress/mode=0 | ||||
| compress/lossy_quality=0.7 | ||||
| compress/hdr_compression=1 | ||||
| compress/bptc_ldr=0 | ||||
| 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 | ||||
							
								
								
									
										27
									
								
								main.tscn
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								main.tscn
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,27 @@ | ||||
| [gd_scene load_steps=5 format=3 uid="uid://b60evyj30472m"] | ||||
|  | ||||
| [ext_resource type="Texture2D" uid="uid://puaqodjkjijx" path="res://assets/tileBlack_01.png" id="1_hogng"] | ||||
| [ext_resource type="PackedScene" uid="uid://cx2vva4fapb6v" path="res://platform_character.tscn" id="2_swg1k"] | ||||
|  | ||||
| [sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_qmrml"] | ||||
| texture = ExtResource( "1_hogng" ) | ||||
| texture_region_size = Vector2i(32, 32) | ||||
| 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(-16, -16, 16, -16, 16, 16, -16, 16) | ||||
|  | ||||
| [sub_resource type="TileSet" id="TileSet_0yp3r"] | ||||
| tile_size = Vector2i(32, 32) | ||||
| physics_layer_0/collision_layer = 1 | ||||
| sources/0 = SubResource( "TileSetAtlasSource_qmrml" ) | ||||
|  | ||||
| [node name="Main" type="Node2D"] | ||||
|  | ||||
| [node name="TileMap" type="TileMap" parent="."] | ||||
| tile_set = SubResource( "TileSet_0yp3r" ) | ||||
| format = 2 | ||||
| layer_0/tile_data = PackedInt32Array(655360, 0, 0, 655361, 0, 0, 655362, 0, 0, 655363, 0, 0, 655364, 0, 0, 655365, 0, 0, 655366, 0, 0, 655367, 0, 0, 655368, 0, 0, 655369, 0, 0, 655370, 0, 0, 655371, 0, 0, 655372, 0, 0, 655373, 0, 0, 65536, 0, 0, 131072, 0, 0, 196608, 0, 0, 262144, 0, 0, 327680, 0, 0, 393216, 0, 0, 458752, 0, 0, 524288, 0, 0, 589824, 0, 0, 655374, 0, 0, 655375, 0, 0, 655376, 0, 0, 655377, 0, 0, 655378, 0, 0, 655379, 0, 0, 655380, 0, 0, 655381, 0, 0, 655382, 0, 0, 655383, 0, 0, 655384, 0, 0, 655385, 0, 0, 655386, 0, 0, 655387, 0, 0, 655388, 0, 0, 655389, 0, 0, 65565, 0, 0, 131101, 0, 0, 196637, 0, 0, 262173, 0, 0, 327709, 0, 0, 393245, 0, 0, 458781, 0, 0, 524317, 0, 0, 393234, 0, 0, 393235, 0, 0, 393236, 0, 0, 393237, 0, 0, 589853, 0, 0, 131088, 0, 0, 131087, 0, 0, 131086, 0, 0, 131085, 0, 0, 393238, 0, 0, 131084, 0, 0, 131071, 0, 0, 196607, 0, 0, 262143, 0, 0, 327679, 0, 0, 393215, 0, 0, 458751, 0, 0, 524287, 0, 0, 589823, 0, 0, 655359, 0, 0, 720895, 0, 0, 786431, 0, 0, 720896, 0, 0, 720897, 0, 0, 720898, 0, 0, 720899, 0, 0, 720900, 0, 0, 720901, 0, 0, 720902, 0, 0, 720903, 0, 0, 720904, 0, 0, 720905, 0, 0, 720906, 0, 0, 720907, 0, 0, 720908, 0, 0, 720909, 0, 0, 720910, 0, 0, 720911, 0, 0, 720912, 0, 0, 720913, 0, 0, 720914, 0, 0, 720915, 0, 0, 720916, 0, 0, 720917, 0, 0, 720918, 0, 0, 720919, 0, 0, 720920, 0, 0, 720921, 0, 0, 720922, 0, 0, 720923, 0, 0, 720924, 0, 0, 720925, 0, 0, 720926, 0, 0, 655390, 0, 0, 589854, 0, 0, 524318, 0, 0, 458782, 0, 0, 393246, 0, 0, 327710, 0, 0, 262174, 0, 0, 196638, 0, 0, 131102, 0, 0, 65566, 0, 0, 65535, 0, 0, 0, 0, 0, 29, 0, 0, 30, 0, 0, -196609, 0, 0, -262144, 0, 0, -131073, 0, 0, -65537, 0, 0, -131072, 0, 0, -65536, 0, 0, -196608, 0, 0, -1, 0, 0, -262115, 0, 0, -196579, 0, 0, -131043, 0, 0, -65507, 0, 0, -262114, 0, 0, -196578, 0, 0, -131042, 0, 0, -65506, 0, 0, -262145, 0, 0, -327680, 0, 0, -327679, 0, 0, -327678, 0, 0, -327677, 0, 0, -327676, 0, 0, -327675, 0, 0, -327674, 0, 0, -327673, 0, 0, -327672, 0, 0, -327671, 0, 0, -327670, 0, 0, -327669, 0, 0, -327668, 0, 0, -327667, 0, 0, -327666, 0, 0, -327665, 0, 0, -327664, 0, 0, -327663, 0, 0, -327662, 0, 0, -327661, 0, 0, -327660, 0, 0, -327659, 0, 0, -327658, 0, 0, -327657, 0, 0, -327656, 0, 0, -327655, 0, 0, -327654, 0, 0, -327653, 0, 0, -327652, 0, 0, -327651, 0, 0, -327650, 0, 0, -393186, 0, 0, -393187, 0, 0, -393188, 0, 0, -393189, 0, 0, -393190, 0, 0, -393191, 0, 0, -393192, 0, 0, -393193, 0, 0, -393194, 0, 0, -393195, 0, 0, -393196, 0, 0, -393197, 0, 0, -393198, 0, 0, -393199, 0, 0, -393200, 0, 0, -393201, 0, 0, -393202, 0, 0, -393203, 0, 0, -393204, 0, 0, -393205, 0, 0, -393206, 0, 0, -393207, 0, 0, -393208, 0, 0, -393209, 0, 0, -393210, 0, 0, -393211, 0, 0, -393212, 0, 0, -393213, 0, 0, -393214, 0, 0, -393215, 0, 0, -393216, 0, 0, -327681, 0, 0) | ||||
|  | ||||
| [node name="PlatformCharacter" parent="." instance=ExtResource( "2_swg1k" )] | ||||
| position = Vector2(181, 228) | ||||
							
								
								
									
										23
									
								
								platform_character.gd
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								platform_character.gd
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,23 @@ | ||||
| extends CharacterBody2D | ||||
|  | ||||
|  | ||||
| @export var speed = 500 | ||||
| @export var jump_speed = -800 | ||||
| @export var acceleration = 15 | ||||
| @export var friction = 6 | ||||
|  | ||||
| var gravity = ProjectSettings.get_setting("physics/2d/default_gravity") | ||||
|  | ||||
| func get_input(delta): | ||||
| 	var direction = Input.get_axis("move_left", "move_right") | ||||
| 	if direction: | ||||
| 		velocity.x = lerp(velocity.x, direction * speed, acceleration * delta) | ||||
| 	else: | ||||
| 		velocity.x = lerp(velocity.x, 0, friction * delta) | ||||
| 	if Input.is_action_just_pressed("jump") and is_on_floor(): | ||||
| 		velocity.y = jump_speed | ||||
| 	 | ||||
| func _physics_process(delta): | ||||
| 	velocity.y += gravity * delta | ||||
| 	get_input(delta) | ||||
| 	move_and_slide() | ||||
							
								
								
									
										20
									
								
								platform_character.tscn
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								platform_character.tscn
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,20 @@ | ||||
| [gd_scene load_steps=4 format=3 uid="uid://cx2vva4fapb6v"] | ||||
|  | ||||
| [ext_resource type="Script" path="res://platform_character.gd" id="1_7ux0n"] | ||||
| [ext_resource type="Texture2D" uid="uid://cws3unmxr0p5d" path="res://assets/tileYellow_02.png" id="1_85evu"] | ||||
|  | ||||
| [sub_resource type="RectangleShape2D" id="RectangleShape2D_a5rer"] | ||||
| size = Vector2(32, 68) | ||||
|  | ||||
| [node name="PlatformCharacter" type="CharacterBody2D"] | ||||
| script = ExtResource( "1_7ux0n" ) | ||||
|  | ||||
| [node name="Sprite2D" type="Sprite2D" parent="."] | ||||
| rotation = 1.5708 | ||||
| texture = ExtResource( "1_85evu" ) | ||||
|  | ||||
| [node name="CollisionShape2D" type="CollisionShape2D" parent="."] | ||||
| shape = SubResource( "RectangleShape2D_a5rer" ) | ||||
|  | ||||
| [node name="Camera2D" type="Camera2D" parent="."] | ||||
| current = true | ||||
							
								
								
									
										42
									
								
								project.godot
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								project.godot
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,42 @@ | ||||
| ; 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="2d_platform_basic" | ||||
| run/main_scene="res://main.tscn" | ||||
| config/features=PackedStringArray("4.0", "Vulkan Clustered") | ||||
| config/icon="res://icon.png" | ||||
|  | ||||
| [input] | ||||
|  | ||||
| move_right={ | ||||
| "deadzone": 0.5, | ||||
| "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"command_pressed":false,"pressed":false,"keycode":0,"physical_keycode":16777233,"unicode":0,"echo":false,"script":null) | ||||
| , Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"command_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"unicode":0,"echo":false,"script":null) | ||||
| ] | ||||
| } | ||||
| move_left={ | ||||
| "deadzone": 0.5, | ||||
| "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"command_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"unicode":0,"echo":false,"script":null) | ||||
| , Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"command_pressed":false,"pressed":false,"keycode":0,"physical_keycode":16777231,"unicode":0,"echo":false,"script":null) | ||||
| ] | ||||
| } | ||||
| jump={ | ||||
| "deadzone": 0.5, | ||||
| "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"command_pressed":false,"pressed":false,"keycode":0,"physical_keycode":16777232,"unicode":0,"echo":false,"script":null) | ||||
| , Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"command_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"unicode":0,"echo":false,"script":null) | ||||
| , Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"store_command":true,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"command_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"unicode":0,"echo":false,"script":null) | ||||
| ] | ||||
| } | ||||
|  | ||||
| [physics] | ||||
|  | ||||
| 2d/default_gravity=2000.0 | ||||
		Reference in New Issue
	
	Block a user
	 Chris Bradfield
					Chris Bradfield