Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/extranick/chatty_desktop_pet

Desktop desktop pet made after LucyPyre's demonite "Chatty", with Godot Engine 4.3, using GDScript
https://github.com/extranick/chatty_desktop_pet

desktop-pet gdscript godot godot-engine godot4

Last synced: about 1 month ago
JSON representation

Desktop desktop pet made after LucyPyre's demonite "Chatty", with Godot Engine 4.3, using GDScript

Awesome Lists containing this project

README

        

# Chatty desktop pet
A Chatty demonite desktop pet made with Godot Engine 4.3, written in GDScript.

## Functionalities
The desktop pet walks over the taskbar (measured in Windows 11) and can attach to the sides of the screen, or to the top, following them along.

The user can grab the pet with the mouse, and launch it around the screen.

Additionally, the pet can be right-clicked to be petted.

## How it works

### Window
Godot's Window class has many properties that are vital to this desktop pet, if you've seen [This tutorial by geegaz](https://github.com/geegaz/Multiple-Windows-tutorial), then you can probably guess how everything works.

First, a Window is created that matches the desktop pet's Height and Width.


Window_size


You can notice the window is actually larger than the pet's sprite, but that's because Windows 11 has minimum window size.

### Pet's play area
At this point when the window is created, the program reads the screen with current keyboard focus's First pixel (X: 0, Y: 0) at the top left of the screen, and the last pixel of the screen, at the bottom right corner. This becomes the maximum window size used later in determining actions.

The pet then reads the usable screen size (a godot 4 native function) and compares that with the maximum window size. The result is that in Windows 11 at least (and hopefully in other Linux desktop environments, but this is not tested), the program finds if a taskbar is present or not.

### Animations
All of the pet's animations are based off of speed:

- if the pet's speed is 0, it plays the idle animation
- if the pet's velocity is positive relative to its current axis, it plays a walk animation.
- if the pet's velocity is negative relative to it's current axis, it plays a flipped walk animation.


pet_idle

### Pet movement
The pet moves based off of a 5 seconds Timer, which procs an RNG function to decide the pet's next action. It will decide between staying still, moving to the right or to the left based on the current axis it's attached on.


pet_walk


For each pet movement, the Window performs the exact same movement, updateing it's positon based on the pet's position, effectively following it around the screen area.

### Side and top swapping
Once the Window meets either side of the screen, the pet decides between sticking to that window side's Y coordinates or not:

- If the pet decides against sticking, it will start a timer that prevents it against swapping window sides, and moves in the opposite direction.

- If the pet decides to sticking to that side of the screen, its X velocity is nullified, It's Y velocity starts receiving the movement choices and the sprite rotates 90 degrees if on the left side, or -90 degrees (270 degrees) if on the right side.


pet_walk_wall


This same decision making applies to the top side of the screen, with the rotation degree being 180 if swapping from the left side, or -180 if swapping from the right side.

### Petting animation
Throughout all of these movement choices, there is a hidden Window following the pet that contains a heart sprite.


heart_sprite


It receives all rotation degrees updates that the main sprite receives, and if the user right clicks the pet, this window becomes visible, its opacity gradually increases, and the sprites rotates 10 degrees back and forth relative to its starting degrees.


heart_sprite_animation

### Grabbing, flinging and gravity
The last Functionatility is the grabbing and flinging mechanic.

If the use left clicks (from now on i will refer to this as simply clicking) the pet, the pet enters a grabbed state:


pet_float


While grabbed, the pet cannot perform movement actions, but can stick to the sides or top of the screen.

Additionaly, moving the mouse while the pet is grabbed, will move the pet's position along the mouse's position in the screen (This is relative to a variable True_Position which is calculated from subtracting the maximum screen size from the starting screen size), effectively creating a Window dragging function since the window will follow the pet's position.

As the pet is being dragged by the mouse, an array variable stores the mouse's X positon, and another array variable stores the mouse's Y position. Both of these arrays have a maximum length of 10.

1 second after the pet is dragged, the pet receives the fligable state. This means that once the mouse is released, the "force" of the flinging is released, effectively launching the pet based off of the force's direction.

"Force" is defined comparing the X and Y Coordiantes arrays 10th value, subtracted by the 1st value.

Once the pet is flung with the mouse click release, it receives the flinging state, which slowly reduces the force at which the pet is being flung. Once the force is zeroed (Specifically the Y axis force), the flinging state receives the falling state, at which point it is subjective to a gradually increasing "gravity force" that eventually will drag the pet to the bottom of the screen (likely the taskbar).

### Play area limits
The pet cannot fall below a value defined as the pet play area.

This is important because its a fixed Y axis value and due to the high falling gravity speed, the pet *could* potentially fall through the floor entering a limbo state.

If the pet does fall through the pet play area, it's position and the Window's is reset to pet play area's equivalent Y axis value.

### Miscellaneous
The pet cannot swap screens. If you wish to change the pet's active screen, you have to close the application and re-open it in the desired screen.

The pet's active screen is based off of the keyboard's active screen at the time the application is started. Note: window's taskbar keyboard activity seems to default to the primary screen.

The Window's click through functionality was possible thanks to [This tutorial made by chewedgum](https://medium.com/@chewedgumah/godot-4-partially-clickthrough-window-with-transparent-background-3de637cdf95b)

## Additional information
To close the application, hover over the window in the taskbar and simply click the X. Or, just use task manager.

This applications use your GPU for the most part, so while you *can* have multiple pets at once, watch your VRAM, because if you run out, your PC *might* crash. My PC for example, doesn't like more than 8 Pets running at the same with, and i have 4GB of VRAM.

## Known Issues
if you have a top and a bottom screen set in Windows 11 settings, the pet will be unable to stick to the top of the bottom screen - This was untested in Linux, and in previous versions of Windows.