Giter Site home page Giter Site logo

crgimenes / neko Goto Github PK

View Code? Open in Web Editor NEW
308.0 10.0 26.0 3.4 MB

Neko is a cross-platform open-source animated cursor-chasing cat. This is the reimplementation write in Go.

License: BSD 2-Clause "Simplified" License

Go 94.33% Makefile 5.67%
neko golang go retro cat ebitengine

neko's Introduction

Neko

noko

Neko is a cat that chases the mouse cursor across the screen, an app written in the late 1980s and ported for many platforms.

Neco

This code is a re-implementation using Golang and has no relationship to the original software. Furthermore, this version does not use any part of the original source code except sprites and sounds.

The goal is to demonstrate the Go language with a fun and very nostalgic example, without necessarily being tied to the behavior of the original version.

In this example, we used the Ebitengine, an incredibly easy-to-use gaming library with a vibrant community.

How to run

Note that some operating systems may restrict the execution of binaries downloaded from the internet for security reasons. Please consult your operating system documentation to learn how to enable Neko to run.

Parameters

  • -speed The speed of the cat (default 2).
  • -scale The scale of the cat on the screen (default 2.0).
  • -quiet Disable sound.
  • -h Show help.

How to Contribute

Please follow our contribution guide.

neko's People

Contributors

bytecurdler avatar crgimenes avatar dependabot[bot] avatar hajimehoshi avatar hitalos avatar raff avatar xcdkz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

neko's Issues

Use spritesheets instead of individual image files

adryd's port of neko to javascript is one of the best implementation of the silly cat
https://github.com/adryd325/oneko.js

I am currently working on some conversion tools to get more animals from these repos!
https://github.com/tie/oneko/tree/master/bitmaps
https://github.com/eliot-akira/neko/tree/main/2023-icon-library

But the tools I am making generate spritesheets with placements in exact same positions
as in adryd's oneko.gif so they don't have to change the mapping in the code

Thus if the values were copied to this version, it will be able to load the spritesheets I am working on
getting closer to the idea of having multiple fur colors that you pitched in #23
And not only fur colors but different animals all together
plus it will make the assets folder less chaotic

Also when at it, I think some of the move
ment/animation logic could be borrowed too, for example this version makes the cat
fall asleep very fast and also if close to the mouse, the cat twitches like crazy, also diagonal movement is faster which is not
an issue in the javascript version

Overall I think checking out that javascript version could be beneficial and fix the issues with movement and animations

Here is an example spritesheet for testing if you need
kina

Change the mouse cursor to a mouse

The ebitengine does not support changing the mouse cursor, but there are some possibilities, the code below still needs to be tested.

unsigned char pixels[16 * 16 * 4];
memset(pixels, 0xff, sizeof(pixels));
 
GLFWimage image;
image.width = 16;
image.height = 16;
image.pixels = pixels;
 
GLFWcursor* cursor = glfwCreateCursor(&image, 0, 0);

Add comments to the code.

This code started as a joke, and there are almost no comments in the code, but now I am using it as a tool to explain the state machine, and it is necessary to clarify the code and add comments so that people can study it on their own. It is necessary to follow the "godoc" standard.

Scale can't be less than 1.0

Even tho it's a float, setting it to less than 1.0 like 0.5 results in an error
image

Also scale 1 is now bigger than before, here's a comparassion
image

Use a large window and move the sprite.

In the current version, Neko uses a transparent, floating window of the size of the sprite, and the entire window is moved around the screen, creating the illusion of the cat's movement.

Instead of creating a small window, the idea is to create a large, full-screen one and move the cat sprite instead of the entire window. This would make implementing other features like #23 and #9 more straightforward and more compatible with other graphical environments.

Icons, manifest files, etc.

Prepare the executables to be distributed appropriately, not just the compiled code but icons, manifest files, etc. To become more friendly to the non-programmer user.

Windowed mode

A windowed version like the first Apple Macintosh version.

Add multiple cats

An option for multiple cats would be nice, ideally it should have some random offset so they don't just merge together. Maybe make other cats wonder around randomly and after some random duration, pick new cat to follow the mouse so there is one cat that follows a mouse and other cats wonder around and they should switch places after some duration.

Add more animations

  • Animation of the cat running at more angles
  • More "games" like playing with a ball of yarn, etc.

Configure GitHub actions to generate executables.

Configure the GitHub actions to generate the executables as a release whenever a PR is accepted or the version number changes. (the tricky part is dealing with external dependencies for macOS and Linux).

write readme file

Write the readme file, include references, mention authors and licenses.

Guide to run neko on i3wm

neko-go doesn't work well with workspaces and also i3wm border/picom can be annoying but I found solutions to all problems.

First in i3wm config add these lines

for_window [class="GLFW-Application"] border none
exec --no-startup-id $HOME/.local/bin/neko.sh

the latter will be explained later

Then in picom.conf add this if you use shadows

shadow-exclude = [
    "class_g = 'GLFW-Application'"
];

Now create a new file in .local/bin called neko.sh and in it add this

#!/bin/bash

# Kill existing neko-go processes and start a new one
restart_neko() {
    killall neko-go 2>/dev/null
    nohup neko-go -speed 1 -scale 1 >/dev/null 2>&1 &
}

# Initial start
restart_neko

# Listen for workspace change events from i3
i3-msg -t subscribe -m '[ "workspace" ]' | jq --unbuffered -c 'select(.change == "focus")' |
while read -r event; do
    restart_neko
done

this script restarts neko-go on workspace changes to always put neko on the current workspace
I tried moving the neko window to the new workspace but it often just vanishes into thin air so this
solution is less prune to errors, keep in mind that -speed 1 -scale 1 has been used for preference
change these accordingly

bug when it's exactly between two directions

When the mouse angle of the mouse to the cat is precisely between two directions, like, for example, left vs. left down, the sprites are repeatedly alternating between the two directions.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.