It's Cow Game! Version 2.04!

This commit is contained in:
PajamaBee 2024-09-19 23:06:51 -05:00
commit a9e1ed9ddd
3148 changed files with 95332 additions and 0 deletions

View file

@ -0,0 +1,11 @@
extends AnimatedSprite2D
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass

View file

@ -0,0 +1,100 @@
extends CharacterBody2D
# BASIC MOVEMENT VARAIABLES ---------------- #
var speed := 500
# GRAVITY ----- #
@export var gravity_acceleration : float = 3840
@export var gravity_max : float = 1020
# JUMP VARAIABLES ------------------- #
@export var jump_force : float = 1400
@export var jump_cut : float = 0.25
@export var jump_gravity_max : float = 500
# All iputs we want to keep track of
func get_input() -> Dictionary:
return {
"jump": Input.is_action_just_pressed("jump") == true,
}
func _physics_process(delta: float) -> void:
x_movement(delta)
jump_logic(delta)
apply_gravity(delta)
move_and_slide()
func is_die():
return false
func x_movement(delta: float) -> void:
velocity.x = 50*speed*delta
#velocity.x = Vector2(velocity.x, 0).move_toward(Vector2(speed,0),1000*delta).x
func jump_logic(_delta: float) -> void:
# Reset our jump requirements
# Jump if grounded, there is jump input, and we aren't jumping already
if get_input()["jump"]:
$Sprite/AnimatedSprite2D.stop()
$Sprite/AnimatedSprite2D.play("default")
velocity.y = -jump_force
func apply_gravity(delta: float) -> void:
var applied_gravity : float = 0
# Normal gravity limit
if velocity.y <= gravity_max:
applied_gravity = gravity_acceleration * delta
# If moving upwards while jumping, the limit is jump_gravity_max to achieve lower gravity
if velocity.y > jump_gravity_max:
applied_gravity = 0
velocity.y += applied_gravity
func _on_area_2d_area_shape_entered(_area_rid, area, _area_shape_index, _local_shape_index):
if area.is_in_group("Death") and speed > 0:
Suspend()
get_node("Explosion").emitting = true
get_node("CanvasLayer/SpilledLabel").visible = true
var timeSurvived = get_parent().timePlayed
var xpReward = int(timeSurvived * 10)
await get_tree().create_timer(1).timeout
get_node("/root/MainGame/CanvasLayer/MessageZone").visible = true
get_node("/root/MainGame/CanvasLayer/MenuBar").visible = true
get_node("/root/MainGame/CanvasLayer/MinimizeMessageZoneButton").visible = true
get_tree().paused = false
LevelManager.add_XP("gaming", xpReward)
get_parent().queue_free() #exit on death
func _on_animated_sprite_2d_animation_looped():
$Sprite/AnimatedSprite2D.stop()
func Suspend():
speed = 0
$Camera2D/sun.speed = 0
gravity_acceleration = 0
velocity = Vector2(0,0)
jump_force = 0

View file

@ -0,0 +1,131 @@
[gd_scene load_steps=10 format=3 uid="uid://bfijgdkhe4s1p"]
[ext_resource type="Script" path="res://MiniGames/FlappyCow/Player/FlappyCow.gd" id="1_pmws3"]
[ext_resource type="Script" path="res://MiniGames/FlappyCow/Player/Sprite.gd" id="2_i7lbn"]
[ext_resource type="Texture2D" uid="uid://ombwk8f3srit" path="res://MiniGames/FlappyCow/Art/cowwing1.png" id="3_jtwbd"]
[ext_resource type="Texture2D" uid="uid://dqjxanyewvtkd" path="res://MiniGames/FlappyCow/Art/cowwing2.png" id="4_8f7l2"]
[sub_resource type="Animation" id="3"]
resource_name = "Jump"
length = 0.3
step = 0.05
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath(".:scale")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.1, 0.3),
"transitions": PackedFloat32Array(1.68179, 1, 1),
"update": 0,
"values": [Vector2(1, 1), Vector2(0.8, 1.2), Vector2(1, 1)]
}
[sub_resource type="Animation" id="4"]
resource_name = "Land"
length = 0.2
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath(".:scale")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.1, 0.2),
"transitions": PackedFloat32Array(0.241484, 1, 1),
"update": 0,
"values": [Vector2(1, 1), Vector2(1.4, 1), Vector2(1, 1)]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_1lb64"]
_data = {
"Jump": SubResource("3"),
"Land": SubResource("4")
}
[sub_resource type="SpriteFrames" id="SpriteFrames_vllpg"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": ExtResource("3_jtwbd")
}, {
"duration": 5.0,
"texture": ExtResource("4_8f7l2")
}],
"loop": true,
"name": &"default",
"speed": 30.0
}]
[sub_resource type="Gradient" id="Gradient_10mlp"]
[node name="Player" type="CharacterBody2D" groups=["Player"]]
z_index = 10
collision_mask = 14
floor_snap_length = 16.0
script = ExtResource("1_pmws3")
[node name="Sprite" type="Node2D" parent="."]
position = Vector2(0, 8)
script = ExtResource("2_i7lbn")
player_path = NodePath("..")
[node name="AnimationPlayer" type="AnimationPlayer" parent="Sprite"]
libraries = {
"": SubResource("AnimationLibrary_1lb64")
}
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="Sprite"]
z_index = 101
z_as_relative = false
sprite_frames = SubResource("SpriteFrames_vllpg")
flip_h = true
[node name="Area2D" type="Area2D" parent="."]
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Area2D"]
polygon = PackedVector2Array(33, 59, 82, -23, 70, -42, 23, -41, 14, -11, -72, -4, -79, 58)
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="."]
polygon = PackedVector2Array(33, 59, 82, -23, 70, -42, 23, -41, 14, -11, -72, -4, -79, 58)
[node name="Explosion" type="CPUParticles2D" parent="."]
emitting = false
amount = 100
one_shot = true
explosiveness = 0.86
randomness = 0.41
spread = 180.0
gravity = Vector2(0, 0)
initial_velocity_min = 25.0
initial_velocity_max = 142.0
angular_velocity_max = 360.0
linear_accel_max = 53.33
radial_accel_max = 13.33
scale_amount_min = 7.85
scale_amount_max = 9.65
color = Color(0.909804, 0.054902, 0, 1)
color_ramp = SubResource("Gradient_10mlp")
[node name="CanvasLayer" type="CanvasLayer" parent="."]
[node name="SpilledLabel" type="Label" parent="CanvasLayer"]
visible = false
offset_left = -29.0
offset_top = 195.0
offset_right = 941.0
offset_bottom = 373.0
theme_override_colors/font_color = Color(1, 0, 0, 1)
theme_override_colors/font_outline_color = Color(0, 0, 0, 1)
theme_override_constants/outline_size = 9
theme_override_constants/line_spacing = 0
theme_override_font_sizes/font_size = 62
text = "I SPIL MY JICE MODS
HELP HELP HELP HEP HELP HELP"
horizontal_alignment = 1
[connection signal="animation_finished" from="Sprite/AnimatedSprite2D" to="." method="_on_animated_sprite_2d_animation_finished"]
[connection signal="animation_looped" from="Sprite/AnimatedSprite2D" to="." method="_on_animated_sprite_2d_animation_looped"]
[connection signal="area_shape_entered" from="Area2D" to="." method="_on_area_2d_area_shape_entered"]
[connection signal="body_entered" from="Area2D" to="." method="_on_area_2d_body_entered"]

View file

@ -0,0 +1,24 @@
extends Node2D
@export var player_path : NodePath
@onready var Player := get_node(player_path)
@onready var Animator := $AnimationPlayer
var previous_frame_velocity := Vector2(0,0)
# Avoid errors
func _ready() -> void:
if Player == null:
print("Sprite.gd is missing player_path")
set_process(false)
func _process(_delta: float) -> void:
if previous_frame_velocity.y >= 0 and Player.velocity.y < 0:
Animator.play("Jump")
elif previous_frame_velocity.y > 0 and Player.is_on_floor():
Animator.play("Land")
# It's important that this is the last thing done
previous_frame_velocity = Player.velocity