From 7474043ddcb94327b48ec66a2666777493465da7 Mon Sep 17 00:00:00 2001 From: Daniel Lyons <72824209+DandyLyons@users.noreply.github.com> Date: Sat, 7 Dec 2024 15:08:19 -0700 Subject: [PATCH] draft post-27 --- .gitignore | 4 +- .../Selective Equality Checking in Swift.md | 30 +++++++++++- ... 5 or 6?.md => Am I Using Swift 5 or 6.md} | 2 +- .../en/posts/post-27/Godot Tween Deep Dive.md | 46 +++++++++++++++++++ 4 files changed, 78 insertions(+), 4 deletions(-) rename content/en/posts/post-26/{Am I Using Swift 5 or 6?.md => Am I Using Swift 5 or 6.md} (98%) create mode 100644 content/en/posts/post-27/Godot Tween Deep Dive.md diff --git a/.gitignore b/.gitignore index c052762..e2875c5 100644 --- a/.gitignore +++ b/.gitignore @@ -25,4 +25,6 @@ # themes/ # Ignore files generated by Hugo -/resources/ \ No newline at end of file +/resources/ +# Local Netlify folder +.netlify diff --git a/content/en/posts/post-24/Selective Equality Checking in Swift.md b/content/en/posts/post-24/Selective Equality Checking in Swift.md index e9328f5..fac6e22 100644 --- a/content/en/posts/post-24/Selective Equality Checking in Swift.md +++ b/content/en/posts/post-24/Selective Equality Checking in Swift.md @@ -198,8 +198,10 @@ value(person1, isEqualTo: person2, by: \.firstName, \.lastName, \.age) ### How It Works This solution uses a new Swift 6.0 feature called [Parameter Pack Iteration](https://www.swift.org/blog/pack-iteration/). First we declare that the function receives many types `V`, all of which conform to `Equatable`. Then we accept a pack of `KeyPath` values (notice the `repeat`). Each of these key paths goes from type `T` to `each V`, and each V type will be `Equatable`. Then we iterate through each keypath, and compare the values to each other. -Let's evaluate our function: -1. Pro: Now we can check multiple properties at the same time **even when they are different types**! +>**Note**: For some reason, this feature appears to work for me even when I am using Swift 5 language mode. So even though the blog says that it is a Swift 6 feature, it appears to not require the Swift 6 language mode. Make sure you read my post? "[Am I Using Swift 5 or 6?]({{< ref "Am I Using Swift 5 or 6" >}})" to understand the difference between Swift 6, **the tools** and Swift 6, **the language mode**. + +Now, let's evaluate our function again: +1. Pro: Now we can check multiple properties at the same time **even when they are different types**! ### Room For Improvement Our final function doesn't quite match up to our original API design. Remember we wanted to build something that could be used like this: @@ -223,6 +225,30 @@ struct Person: Identifiable { value(person1, isEqualTo: person2, by: \.firstName, \.lastName, \.age) ``` +### Works Great With Reference Types +As we noted before, `Equatable` doesn't quite work for reference types. But our `value(isEqualTo:by:)` function works great with reference types! Look what happens if we change `Person` to a class: + +```swift +class Person: Identifiable { + let firstName: String + let lastName: String + let age: Int + let id: UUID + let profileImage: UIImage +} +value(person1, isEqualTo: person2, by: \.firstName, \.lastName, \.age) +``` + +Here the code works exactly the same. The call site makes it very clear that we are not checking if two `Person` instances are the same instance. Instead we are checking if they have the same values for the same properties. + +>**Note:** Don't forget that if we want to check if two class instances are the same instance, we can use the `===` operator like this: + +```swift +person1 === person2 +``` + + +## Conclusion Well there you have it, **Selective Equality Checking in Swift**. We can now easily and ergonomically check for equality on select properties and we don't need to conform our types to `Equatable`. Do you like this solution? Grab it for yourself from the [gist](https://gist.github.com/DandyLyons/d19c2b2444db743372fbe9f21d93c98a) here and don't forget to star it! --- diff --git a/content/en/posts/post-26/Am I Using Swift 5 or 6?.md b/content/en/posts/post-26/Am I Using Swift 5 or 6.md similarity index 98% rename from content/en/posts/post-26/Am I Using Swift 5 or 6?.md rename to content/en/posts/post-26/Am I Using Swift 5 or 6.md index a337f88..0e6ca47 100644 --- a/content/en/posts/post-26/Am I Using Swift 5 or 6?.md +++ b/content/en/posts/post-26/Am I Using Swift 5 or 6.md @@ -3,7 +3,7 @@ title: 'Am I Using Swift 5 or 6?' slug: am-i-using-swift-5-or-6 date: 2024-11-19 topics: ["Swift 6"] -description: +description: What's the difference between the Swift "language modes" and "compiler"? How do I determine which version of Swift I am using? How do I opt in or out of Swift 5 or Swift 6 language mode? --- Swift is in the middle of a transition from Swift 5 to Swift 6. This transition is not as simple as it may seem. In this post, we will discuss how to determine which version of Swift you are using. But first we need to clear up some misconceptions. diff --git a/content/en/posts/post-27/Godot Tween Deep Dive.md b/content/en/posts/post-27/Godot Tween Deep Dive.md new file mode 100644 index 0000000..00ee9bb --- /dev/null +++ b/content/en/posts/post-27/Godot Tween Deep Dive.md @@ -0,0 +1,46 @@ +--- +title: 'A Deep Dive Into Godot Engine's Tween System' +slug: godot-tween-deep-dive +date: 2024-11-26 +topics: ["Godot", "Game Development"] +description: +draft: true +--- + +Godot Engine's Tween system is a powerful tool for creating animations and interpolations in your games. In this article, we'll take a deep dive into how the Tween system works and how you can use it to create complex animations and effects in your games. + +## The Many "Animation" Systems in Godot +What is animation? In the early 1900s Walt Disney brought animation to a mainstream audience. By drawing a series of still images and playing them back in rapid succession, Disney was able to create the illusion of smooth change over time. This is the essence of animation: creating the illusion of smooth change. + +In game development, we are essentially doing the same process. The biggest difference however is that, typically, we are not drawing the frames ourselves. Instead, the game engine is responsible for rendering the frames for us. Instead, we are responsible for telling the game engine how to change the objects in our game. + +The Godot game engine has several systems that allow you to create animations in your games. These include: +- The AnimationPlayer system +- The Tween system +- The Physics system + +## Choosing The Right Animation System: When To Use The Tween System + + +## How The Tween System Works +Any time you learn a new API, it's important to understand the life cycle of the system. In particular you should seek to answer the following questions: +- What are the fundamental concepts that the API expects me to understand? +- How do you create a new instance of the system? + - Who is responsible for creating the instance? +- What are the various states that the system can be in? + - How do you transition between these states? +- How do you destroy an instance of the system? + - Who is responsible for destroying the instance? + +### Fundamental Concepts of the Tween System + + +### The Life Cycle And States of a Tween + +#### Pausing Tweens + +#### Stopping Tweens + +#### Killing Tweens + +## Putting It All Together: Creating Complex Animations With The Tween System \ No newline at end of file