Skip to content

Commit

Permalink
:3 added everything
Browse files Browse the repository at this point in the history
  • Loading branch information
JaegerwaldDev committed Mar 31, 2024
1 parent dd5c3fd commit ef891f4
Show file tree
Hide file tree
Showing 9 changed files with 371 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.godot/
.vscode/
Export/
62 changes: 62 additions & 0 deletions export_presets.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
[preset.0]

name="Binbows Ben"
platform="Windows Desktop"
runnable=true
dedicated_server=false
custom_features=""
export_filter="all_resources"
include_filter=""
exclude_filter=""
export_path="Export/oneko.exe"
encryption_include_filters=""
encryption_exclude_filters=""
encrypt_pck=false
encrypt_directory=false

[preset.0.options]

custom_template/debug=""
custom_template/release=""
debug/export_console_wrapper=2
binary_format/embed_pck=true
texture_format/bptc=true
texture_format/s3tc=true
texture_format/etc=false
texture_format/etc2=false
binary_format/architecture="x86_64"
codesign/enable=false
codesign/timestamp=true
codesign/timestamp_server_url=""
codesign/digest_algorithm=1
codesign/description=""
codesign/custom_options=PackedStringArray()
application/modify_resources=true
application/icon=""
application/console_wrapper_icon=""
application/icon_interpolation=4
application/file_version=""
application/product_version=""
application/company_name="JaegerwaldDev"
application/product_name="oneko.gd"
application/file_description="cat follow mouse (real)"
application/copyright="i fordor"
application/trademarks=""
application/export_angle=0
ssh_remote_deploy/enabled=false
ssh_remote_deploy/host="user@host_ip"
ssh_remote_deploy/port="22"
ssh_remote_deploy/extra_args_ssh=""
ssh_remote_deploy/extra_args_scp=""
ssh_remote_deploy/run_script="Expand-Archive -LiteralPath '{temp_dir}\\{archive_name}' -DestinationPath '{temp_dir}'
$action = New-ScheduledTaskAction -Execute '{temp_dir}\\{exe_name}' -Argument '{cmd_args}'
$trigger = New-ScheduledTaskTrigger -Once -At 00:00
$settings = New-ScheduledTaskSettingsSet
$task = New-ScheduledTask -Action $action -Trigger $trigger -Settings $settings
Register-ScheduledTask godot_remote_debug -InputObject $task -Force:$true
Start-ScheduledTask -TaskName godot_remote_debug
while (Get-ScheduledTask -TaskName godot_remote_debug | ? State -eq running) { Start-Sleep -Milliseconds 100 }
Unregister-ScheduledTask -TaskName godot_remote_debug -Confirm:$false -ErrorAction:SilentlyContinue"
ssh_remote_deploy/cleanup_script="Stop-ScheduledTask -TaskName godot_remote_debug -ErrorAction:SilentlyContinue
Unregister-ScheduledTask -TaskName godot_remote_debug -Confirm:$false -ErrorAction:SilentlyContinue
Remove-Item -Recurse -Force '{temp_dir}'"
Binary file added icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions icon.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://ctv34164u2jnc"
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/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
186 changes: 186 additions & 0 deletions neko.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
# This is literally just a port of oneko.js
# Like, 1:1 but just in another language.

# There might be some weird code because I ported the
# solutions to weird JS stuff to Godot. If you find
# anything like that, just make a PRQ with a fix.

extends Node2D

var nekoPosX = 32
var nekoPosY = 32

var mousePosX = 0
var mousePosY = 0

var frameCount = 0
var idleTime = 0
var idleAnimation = null
var idleAnimationFrame = 0

var nekoSpeed = 10
var spriteSets = {
"idle": [24],
"alert": [31],
"scratchSelf": [
28,
29,
30
],
"scratchWallN": [
16,
17
],
"scratchWallS": [
20,
21
],
"scratchWallE": [
18,
19
],
"scratchWallW": [
22,
23
],
"tired": [25],
"sleeping": [
26,
27
],
"N": [
0,
1
],
"NE": [
2,
3
],
"E": [
4,
5
],
"SE": [
6,
7
],
"S": [
8,
9
],
"SW": [
10,
11
],
"W": [
12,
13
],
"NW": [
14,
15
]
}

var lastFrameTimestamp

func onAnimationFrame(timestamp):
visible = true
$Neko.visible = true
if !lastFrameTimestamp:
lastFrameTimestamp = timestamp
if timestamp-lastFrameTimestamp > 100:
lastFrameTimestamp = timestamp
frame()

func setSprite(name, frame):
var sprite = spriteSets[name][frame % len(spriteSets[name])]
$Neko.frame = sprite

func resetIdleAnimation():
idleAnimation = null;
idleAnimationFrame = 0;

func idle():
idleTime += 1

var rng = RandomNumberGenerator.new()

# every ~ 20 seconds
if idleTime > 10 and floor(rng.randi_range(0, 200)) == 0 and idleAnimation == null:
var avalibleIdleAnimations = ["sleeping", "scratchSelf"];
if nekoPosX < 32:
avalibleIdleAnimations.append("scratchWallW")
if nekoPosY < 32:
avalibleIdleAnimations.append("scratchWallN")
if nekoPosX > DisplayServer.screen_get_size()[0] - 32:
avalibleIdleAnimations.append("scratchWallE")
if nekoPosY > DisplayServer.screen_get_size()[1] - 96:
avalibleIdleAnimations.append("scratchWallS")

idleAnimation = avalibleIdleAnimations[
floor(rng.randi_range(0, len(avalibleIdleAnimations)-1))
]

match idleAnimation:
"sleeping":
if idleAnimationFrame < 8:
setSprite("tired", 0)
pass
setSprite("sleeping", floor(idleAnimationFrame / 4))
if idleAnimationFrame > 192:
resetIdleAnimation()
pass
"scratchWallN", "scratchWallS", "scratchWallE", "scratchWallW", "scratchSelf":
setSprite(idleAnimation, idleAnimationFrame)
if idleAnimationFrame > 9:
resetIdleAnimation()
pass
_:
setSprite("idle", 0)
pass
idleAnimationFrame += 1;

func frame():
frameCount += 1
var diffX = nekoPosX - mousePosX
var diffY = nekoPosY - mousePosY

var distance = sqrt(diffX ** 2 + diffY ** 2)

if distance < nekoSpeed or distance < 96:
idle()
else:
idleAnimation = null;
idleAnimationFrame = 0

if idleTime > 1:
setSprite("alert", 0)
# count down after being alerted before moving
idleTime = min(idleTime, 7)
idleTime -= 1
else:
var direction
direction = "N" if diffY / distance > 0.5 else ""
direction += "S" if diffY / distance < -0.5 else ""
direction += "W" if diffX / distance > 0.5 else ""
direction += "E" if diffX / distance < -0.5 else ""
setSprite(direction, frameCount);

nekoPosX -= (diffX / distance) * nekoSpeed;
nekoPosY -= (diffY / distance) * nekoSpeed;

nekoPosX = min(max(16, nekoPosX), DisplayServer.screen_get_size()[0] - 16)
nekoPosY = min(max(16, nekoPosY), DisplayServer.screen_get_size()[1] - 64)

get_window().position = Vector2(nekoPosX, nekoPosY)

# Called when the node enters the scene tree for the first time.
func _ready():
get_window().size = Vector2(32, 32)

# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
mousePosX = get_window().position[0] + get_global_mouse_position()[0]
mousePosY = min(max(0, get_window().position[1] + get_global_mouse_position()[1]), DisplayServer.screen_get_size()[1] - 64)
onAnimationFrame(Time.get_ticks_msec())
Binary file added neko.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions neko.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://cd77b0fxjwjbl"
path="res://.godot/imported/neko.png-3bd0c8134f0454a081e40cbcfff2dcb9.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://neko.png"
dest_files=["res://.godot/imported/neko.png-3bd0c8134f0454a081e40cbcfff2dcb9.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
15 changes: 15 additions & 0 deletions neko.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[gd_scene load_steps=3 format=3 uid="uid://csc53xij60iq0"]

[ext_resource type="Script" path="res://neko.gd" id="1_i4h0e"]
[ext_resource type="Texture2D" uid="uid://cd77b0fxjwjbl" path="res://neko.png" id="1_whxow"]

[node name="Node2D" type="Node2D"]
visible = false
script = ExtResource("1_i4h0e")

[node name="Neko" type="Sprite2D" parent="."]
visible = false
position = Vector2(32, 32)
texture = ExtResource("1_whxow")
hframes = 8
vframes = 4
37 changes: 37 additions & 0 deletions project.godot
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
; 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="oneko.gd"
run/main_scene="res://neko.tscn"
config/features=PackedStringArray("4.2", "GL Compatibility")
boot_splash/bg_color=Color(0, 0, 0, 1)
boot_splash/show_image=false
boot_splash/fullsize=false
boot_splash/use_filter=false
config/icon="res://icon.png"

[display]

window/size/viewport_width=32
window/size/viewport_height=32
window/size/initial_position_type=3
window/size/borderless=true
window/size/always_on_top=true
window/size/transparent=true
window/per_pixel_transparency/allowed=true

[rendering]

textures/canvas_textures/default_texture_filter=0
renderer/rendering_method="gl_compatibility"
renderer/rendering_method.mobile="gl_compatibility"
viewport/transparent_background=true

0 comments on commit ef891f4

Please sign in to comment.