Code Monkey home page Code Monkey logo

nico's Introduction

NICO Game Framework

test

NICO is a simple game framework for the Nim programming language inspired by the PICO-8 API.

Supported platforms:

  • Windows
  • Linux, including RaspberryPi
  • Web/HTML5 via Emscripten
  • Android
  • MacOS

What it does:

  • Paletted Bitmap Graphics (you can load a custom palette up to 256 colors)
  • Fixed or flexible custom display resolution with pixel scaling
  • Sprite drawing, load png spritesheets, specify tile size per sheet (can load multiple and switch between them)
  • Tilemap drawing, import json from Tiled
  • Drawing primitives: pixels, lines, rectangles, circles, triangles
  • Input: Keyboard, Gamepad, Mouse, Touch
  • Sfx playback: load and play ogg vorbis files, configurable number of mixer channels.
  • Built in chip synth
  • Music playback: stream ogg vorbis files.
  • Custom audio callback for generating your own sounds via code.
  • Text drawing: load and draw fonts from png, supports variable width fonts.
  • Export animated gifs

Installation

  • You will need to have the Nim compiler installed
  • Run nimble install nico
  • Run nicoboot <yourname> <projectname> <directory> to create a new directory with an example base ready to start working with.
  • You can watch a quick tutorial here
  • Native build:
    • You'll need SDL2 for native builds, on Windows, ensure SDL2.dll is copied to your project directory.
    • From your project directory run nimble runr to build and run the example as a native build.
    • From your project directory run nimble rund to build and run the example as a debug native build.
  • Web build:
    • For web builds you'll need Emscripten.
    • From your project directory run nimble webr to build for web in release mode.
    • From your project directory run nimble webd to build for web in debug mode.

Learning

Why should you use NICO?

  • It's fun and easy to use
  • Learn Nim the fun way! It's a great new statically typed programming language that compiles to C.
  • You can build for Web, Windows, Linux, Mac, Android, and potentially other platforms.

Future work:

  • API Documentation
  • More examples
  • Tests
  • Utility modules for common higher level tasks
  • Browser to browser networking using WebRTC
  • Immediate mode GUI
  • 3D Utils and Rasterizer

Games made using NICO:

nico's People

Contributors

beef331 avatar cxong avatar fishcken avatar ftsf avatar hi02hi avatar jiro4989 avatar jorisbontje avatar markusgritsch avatar patitotective avatar planetis-m avatar srozb avatar szabolcs-cs avatar takwolf avatar theameliamay 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nico's Issues

SDL2 Versions

Is it possible to compile with an older version of SDL?

In GNU / Linux non-developer users usually do not have the latest versions of SDL installed (or they are missing from the repositories)

Cannot compile native backend on devel

Using devel branch of the Nim compiler results in scancodes in the sdl2 backend to be ambigious halting compilation.

Error: ambiguous identifier: 'SCANCODE_LEFT' -- use one of the following:
  Scancode.SCANCODE_LEFT: Scancode
  Scancode.SCANCODE_LEFT: Scancode

Colors are rendered incorrectly

Hi!

I've created a spritesheet in Gimp, using this palette: https://lospec.com/palette-list/pico-8

The spritesheet: https://imgur.com/36iND5H

The problem is the sprites from it are rendered in different colors: https://imgur.com/na9JSC1

Why is that? I've tried adding explicit setPalette(loadPalettePico8()), that didn't change anything. Tried setPalette(loadPaletteFromGPL("pico-8.gpl")), and the entire screen is just black.

P.S. Nico is fantastic! Thank you so much for the amazing work you do. I’ve just created my first game from scratch, without any prior experience, in just five hours total. And it’s been pure fun all the way.

Nico uses one core to the max?

Hi,

My specs:

  • Windows 10 x64
  • Nim 1.6.12 x64
  • SDL 2.26.5

Running any example uses one CPU core to the max. I tried setVSync both true/false, no difference.
The code I test with is:

import nico

proc gameInit() =
  nico.loadFont(0, "font.png")

proc gameUpdate(dt: Pfloat) =
  discard

proc gameDraw() =
  cls()
  setColor(7)
  line(64,64,128,64)
  setColor(8)
  line(64,0,64,64)
  
  circ(70,70,10)
  
  print("something", 20, 80)

# initialization
nico.init("nico", "test")

# we want a fixed sized screen with perfect square pixels
nico.fixedSize(true)
nico.integerScale(true)

# Framerate
nico.fps(30)
nico.setVSync(true)

# create the window
nico.createWindow("nico", 128, 128, 4)

# start, say which functions to use for init, update and draw
nico.run(gameInit, gameUpdate, gameDraw)

Any ideas?
Thanks

24x24 sprite sheet only draws some sprites

the section at the bottom is two different palettized gradients covering a wide range of colors to test if it had anything to do with the palettization of the spritesheet
image

Deployment

I have downloaded the smalltrek, however I have been able to see a finalized and compiled game for distribution and something has caught my attention ...
All assets are exposed and I am wondering if this is the only way of distribution or nico or nim can compile resources within the executable ?

gui label with richPrint color codes has incorrect width

When using a label with richPrint color control codes such as G.label("one <8>two<-> three") instead of G.label("one two three"), the label gets differently word wrapped within the parent area even through the width should be the same.

Sound effects are delayed.

Using my repository as an example, a sound should be played every time the ball hits a wall, but there is a noticeable delay in sound. I've noticed this in my other project as well.

LCT_RGB .png files never loaded.

On macOS 11.1 with latest master build, .png files with LCT_RGB type never get displayed (or used, seemingly) when loading them as spritesheets. Only LCT_RGBA is accepted. Maybe this is an issue caused with how I'm exporting the .png?

LCT_RGB ignored:
image

LCT_RGBA accepted:
image

Console key listener (~) overriden in SDL2 backend

With examples/vertex.nim in nico v0.3.2 on OSX:

The console key listener doesn't get triggered when pressing the ~ key.
This seems happen because the SDL2 backend overrides keyListeners (sdl2.nim:141) from the common backend. After commenting that line out, the console is launched as expected when pressing ~.

Illegal storage access (Mac osx Version 12.3.1)

nimble runr --verbose [11:05:44]
Warning: Package 'conway' has an incorrect structure. The top level of the package source directory should contain at most one module, named 'conway.nim', but a file named 'main.nim' was found. This will be an error in the future.
Hint: If this is the primary source file in the package, rename it to 'conway.nim'. If it's a source file required by the main module, or if it is one of several modules exposed by 'conway', then move it into a 'conway/' subdirectory. If it's a test file or otherwise not required to build the the package 'conway.nim', prevent its installation by adding skipFiles = @["main.nim"] to the .nimble file. See https://github.com/nim-lang/nimble#libraries for more info.
Executing task runr in /Users/.env/nim/practice/ud_nim_programming/nico/conway/conway.nimble
Hint: used config file '/Users/.choosenim/toolchains/nim-1.6.4/config/nim.cfg' [Conf]
Hint: used config file '/Users/.choosenim/toolchains/nim-1.6.4/config/config.nims' [Conf]
Hint: used config file '/Users/.env/nim/practice/ud_nim_programming/nico/conway/config.nims' [Conf]
Hint: gc: refc; opt: speed; options: -d:danger
19456 lines; 0.069s; 16.531MiB peakmem; proj: /Users/.env/nim/practice/ud_nim_programming/nico/conway/src/main.nim; out: /Users/nim/practice/ud_nim_programming/nico/conway/conway [SuccessX]
Hint: /Users/.env/nim/practice/ud_nim_programming/nico/conway/conway [Exec]

SIGSEGV: Illegal storage access. (Attempt to read from nil?)
Error: execution of an external program failed: '/Users/.env/nim/practice/ud_nim_programming/nico/conway/conway '
stack trace: (most recent call last)
/private/var/folders/81/zn5n71012mb48jwlptm46_m80000gq/T/nimblecache-1664209541/nimscriptapi_969186685.nim(187, 16)
/Users/.env/nim/practice/ud_nim_programming/nico/conway/conway.nimble(20, 7) runrTask
/Users/.choosenim/toolchains/nim-1.6.4/lib/system/nimscript.nim(273, 7) exec
/Users/.choosenim/toolchains/nim-1.6.4/lib/system/nimscript.nim(273, 7) Error: unhandled exception: FAILED: nim c -r -d:danger -o:conway src/main.nim [OSError]
Tip: 1 messages have been suppressed, use --verbose to show them.
Error: Exception raised during nimble script execution

I have run the code using nimble runr and also nim c -r ./src/main.nim
The file compiles just fine but I cannot execute the file.


Code:

`import nico
import std/sequtils

let title = "Jonathan's game of life"
let wx = 600
let wy = 400
let resolution = 10
let dx = resolution
let dy = resolution
let nx = wx div dx
let ny = wy div dy

var board = newSeqWith(nx, newseqbool)
board[0][0] = true
board[10][0] = true
board[0][5] = true

var buttonDown = false

proc gameInit() =
loadFont(0, "font.png")

proc gameUpdate(dt: float32) =
buttonDown = btn(pcA)

proc gameDraw() =
cls()
#setColor(if buttonDown: 7 else: 3)
#printc("welcome to " & appName, screenWidth div 2, screenHeight div 2)
setColor(3)
boxfill(10,20,100,50)

nico.init("myOrg", title)
nico.createWindow("myApp", wx, wy, 1, false)
nico.run(gameInit, gameUpdate, gameDraw)`

Problems with fresh install on Nim 1.5.1?

Hey! Just playing around with Nim & Nico, but when I tried to make a sample app using nicoboot, I get an error:

C:\Users\Foo\.nimble\pkgs\nico-0.3.2\nico\backends\sdl2.nim(21, 19) Error: type mismatch:
 got 'Keycode' for 'x' [enum declared in C:\Users\Foo\.nimble\pkgs\sdl2-2.0.12.0\sdl2\private\keycode.nim(34, 3)]
 but expected 'Keycode = enum' [enum declared in C:\Users\Foo\.nimble\pkgs\nico-0.3.2\nico\keycodes.nim(207, 3)]
maybe use `-d:nimLegacyConvEnumEnum` for a transition period

When I add the -d:nimLegacyConvEnumEnum flag, I then get

Error: ambiguous identifier: 'SCANCODE_LEFT' -- use one of the following:
  Scancode.SCANCODE_LEFT: Scancode
  Scancode.SCANCODE_LEFT: Scancode

I am using the last Nim from GitHub, as the installers are triggering a virus alert. It looks like I had built Nim 1.5.1.

(I guess Nim doesn't have semantic versioning, as that seems to have broken Nico...)

Okay, just re-compiled from source with version 1.4.8, works great!

(ps just for others, you have to delete *.exe from Nim/bin otherwise build_all.bat doesn't recompile Nim itself!)

gifenc - Package not found

Was curious if you had any insight about this.

Installing gifenc@>= 0.1.0
    Prompt: gifenc not found in any local packages.json, check internet for updated packages? [y/N]
    Answer: y
Downloading Official package list
    Success Package list downloaded.
       Tip: 7 messages have been suppressed, use --verbose to show them.
     Error: Traceback (most recent call last)
        ... nimble.nim(1087)         nimble
        ... nimble.nim(1012)         doAction
        ... nimble.nim(607)          install
        ... nimble.nim(414)          installFromDir
        ... nimble.nim(254)          processDeps
        ... nimble.nim(611)          install
        ... nimble.nim(599)          getDownloadInfo
        ... nimble.nim(601)          getDownloadInfo
        ... Package not found.

Taking screenshot crashes

With nico 0.3.2 on OSX, when taking a screenshot with F10 the nico apps crashes.
This happens for nico examples (paintout, gui, vertex, etc) as well for my own games.

Traceback (most recent call last)
/Users/username/Projects/nico/nico/examples/paintout.nim(161) paintout
/Users/username/Projects/nico/nico/nico.nim(2942) run
/Users/username/Projects/nico/nico/nico/backends/sdl2.nim(1662) run
/Users/username/Projects/nico/nico/nico/backends/sdl2.nim(1209) step
/Users/username/Projects/nico/nico/nico/backends/sdl2.nim(1197) checkInput
/Users/username/Projects/nico/nico/nico/backends/sdl2.nim(1104) appHandleEvent
/Users/username/Projects/nico/nico/nico/backends/sdl2.nim(742) saveScreenshot
/Users/username/Projects/nico/nico/nico/ringbuffer.nim(42) []
/Users/username/Projects/nico/nico/nico/ringbuffer.nim(37) idx
SIGFPE: Arithmetic error.

undeclared identifier: 'queueMixerAudio'

First of all, thanks for your awesome project :)

I tried to build the examples (on Windows and Ubuntu) using nimble examples.

In both cases, I only got:
sdl2.nim(728, 9) Error: undeclared identifier: 'queueMixerAudio'

Any ideas what I can do make it work?

Uncaught (in promise) TypeError: eventHandler.target is null

I'm compiling with Nim 1.6.6 and Emscripten 3.1.19 with nimble webr and when I load it in Firefox I get this error in the console (and no game shows up):

Uncaught (in promise) TypeError: eventHandler.target is null
    registerOrRemoveHandler http://127.0.0.1:8090/carrider.js:1
    registerMouseEventCallback http://127.0.0.1:8090/carrider.js:1
    _emscripten_set_mousemove_callback_on_thread http://127.0.0.1:8090/carrider.js:1
    createExportWrapper http://127.0.0.1:8090/carrider.js:1
    callMain http://127.0.0.1:8090/carrider.js:1
    doRun http://127.0.0.1:8090/carrider.js:1
    run http://127.0.0.1:8090/carrider.js:1
    runCaller http://127.0.0.1:8090/carrider.js:1
    removeRunDependency http://127.0.0.1:8090/carrider.js:1
    receiveInstance http://127.0.0.1:8090/carrider.js:1
    receiveInstantiationResult http://127.0.0.1:8090/carrider.js:1
    promise callback*createWasm/instantiateAsync/< http://127.0.0.1:8090/carrider.js:1
    promise callback*instantiateAsync http://127.0.0.1:8090/carrider.js:1
    createWasm http://127.0.0.1:8090/carrider.js:1
    <anonymous> http://127.0.0.1:8090/carrider.js:1

Screen Shot 2022-08-18 at 10 15 20 PM

I'm about to try with earlier Emscripten versions to see if that's the reason. Do you happen to have a recommended Emscripten version?

Nico JS backend broken on Nim 1.4

When compiling for JS backend we get the following error:

C:\Users\user\.nimble\pkgs\ajax-0.1.0\ajax.nim(16, 3) Error: attempt to redefine: 'onloadstart'

These are now defined in dom module as part of EventTargetObj

Hello world project uses 100% CPU

Using Nico 0.2.6, Nim 1.2.2, a default hello world example project created using nicoboot uses 100% of one CPU core. Is this because the framerate is uncapped? I don't see any way of setting a target framerate in the API doc

Volume Control Still doesnt work.

Issue #18 still is a problem and just bumping it since you closed it and have not responded since. On my system 1-255 is at 100% volume and 0 is at 0% volume. This was an issue across two Ubuntu derived OS systems.

Ambiguous call in sdl2.nim

Hello!
I'm trying to compile the following code for Windows.
(Nim Compiler Version 0.18.1 [Windows: amd64])

nim cpp --nilseqs:on -r main.nim

import nico

proc game_init() =
    echo "init"

proc game_update(dt: Pfloat) = 
    # echo "update: ", dt
    discard

proc game_draw() =
    cls()
    setColor(7)
    print("hello world", 42, 60)

nico.init("test", "test_game")

nico.createWindow("test_game", 128, 128, 4)

nico.run(game_init, game_update, game_draw)

I get an error:

C:\Users\Erik.nimble\pkgs\nico-0.1.0\nico\backends\sdl2.nim(1134, 16) Error: ambiguous call; both system.$(x: int)[declared in lib\system.nim(1864, 5)] and system.$(x: uint64)[declared in lib\system\strmantle.nim(282, 5)] match for: (uint8)

Audio example: Channel adjust in song view can get out of valid range

With examples/audio.nim in nico v0.3.2 on OSX:
Using pcA+pcUp / pcA+pcDown to adjust the channel in the song view can cause the channel to get out of the valid range [0..64]. This seems to be due to incorrect boundary checks in audio.nim gameUpdate(126-130).

Resulting stack trace:

~/nico/examples/audio.nim(345) audio
~/.nimble/pkgs/nico-0.3.2/nico.nim(2935) run
~/.nimble/pkgs/nico-0.3.2/nico/backends/sdl2.nim(1662) run
~/.nimble/pkgs/nico-0.3.2/nico/backends/sdl2.nim(1272) step
~/.nimble/pkgs/nico-0.3.2/nico/backends/sdl2.nim(1519) queueMixerAudio
~/nico/examples/audio.nim(40) musicUpdate
~/.choosenim/toolchains/nim-1.4.2/lib/system/fatal.nim(49) sysFatal
Error: unhandled exception: index 240 not in 0 .. 63 [IndexDefect]
Error: execution of an external program failed: '~/nico/examples/audio '

new error when trying to build platformer.nim on Nim 1.2.0 with latest source

nim --version
Nim Compiler Version 1.2.0 [Windows: amd64]
Compiled at 2020-04-03
Copyright (c) 2006-2020 by Andreas Rumpf

git hash: 7e83adff84be5d0c401a213eccb61e321a3fb1ff
active boot switches: -d:release
git clone https://github.com/ftsf/nico.git
Cloning into 'nico'...
remote: Enumerating objects: 133, done.
remote: Counting objects: 100% (133/133), done.
remote: Compressing objects: 100% (69/69), done.
remote: Total 703 (delta 83), reused 109 (delta 64), pack-reused 570
Receiving objects: 100% (703/703), 386.35 KiB | 1.54 MiB/s, done.
Resolving deltas: 100% (418/418), done.
# cd nico/examples
# nim c -r -d:release platformer.nim
Hint: used config file 'C:\Users\unicodex\.choosenim\toolchains\nim-1.2.0\config\nim.cfg' [Conf]
Hint: system [Processing]
Hint: widestrs [Processing]
Hint: io [Processing]
Hint: platformer [Processing]
Hint: nico [Processing]
Hint: common [Processing]
Hint: math [Processing]
Hint: bitops [Processing]
Hint: macros [Processing]
Hint: tables [Processing]
Hint: hashes [Processing]
Hint: algorithm [Processing]
Hint: unicode [Processing]
Hint: times [Processing]
Hint: strutils [Processing]
Hint: parseutils [Processing]
Hint: options [Processing]
Hint: typetraits [Processing]
Hint: winlean [Processing]
Hint: dynlib [Processing]
Hint: time_t [Processing]
Hint: keycodes [Processing]
Hint: controller [Processing]
Hint: sdl [Processing]
Hint: ringbuffer [Processing]
Hint: unittest [Processing]
Hint: streams [Processing]
Hint: sets [Processing]
Hint: sequtils [Processing]
Hint: os [Processing]
Hint: pathnorm [Processing]
Hint: osseps [Processing]
Hint: terminal [Processing]
Hint: strformat [Processing]
Hint: colors [Processing]
C:\Users\unicodex\.nimble\pkgs\nico-0.2.0\nico\backends\common.nim(140, 3) Hint: 'LineIterator' is declared but not used [XDeclaredButNotUsed]
C:\Users\unicodex\.nimble\pkgs\nico-0.2.0\nico\backends\common.nim(141, 3) Hint: 'Edge' is declared but not used [XDeclaredButNotUsed]
C:\Users\unicodex\.nimble\pkgs\nico-0.2.0\nico\backends\common.nim(7, 8) Warning: imported and not used: 'strutils' [UnusedImport]
Hint: sdl2 [Processing]
Hint: json [Processing]
Hint: lexbase [Processing]
Hint: parsejson [Processing]
Hint: nimPNG [Processing]
Hint: endians [Processing]
Hint: buffer [Processing]
Hint: nimz [Processing]
Hint: filters [Processing]
Hint: osproc [Processing]
Hint: strtabs [Processing]
Hint: cpuinfo [Processing]
Hint: ospaths [Processing]
C:\Users\unicodex\.nimble\pkgs\nico-0.2.0\nico\backends\sdl2.nim(34, 8) Warning: import os.nim instead; ospaths is deprecated [Deprecated]
Hint: parsecfg [Processing]
Hint: sndfile [Processing]
Hint: random [Processing]
C:\Users\unicodex\.nimble\pkgs\nico-0.2.0\nico\backends\sdl2.nim(333, 50) Warning: use `csize_t` instead; csize is deprecated [Deprecated]
C:\Users\unicodex\.nimble\pkgs\nico-0.2.0\nico\backends\sdl2.nim(333, 19) Error: type mismatch: got <ptr RWops, ptr uint8, int literal(1), csize>
but expected one of:
proc rwRead(context: ptr RWops; p: pointer; size: csize_t; maxnum: csize_t): csize_t
  first type mismatch at position: 4
  required type for maxnum: csize_t
  but expression 'csize(1)' is of type: csize

expression: rwRead(fp, addr(buffer[offset]), 1, csize(1))

Error: unhandled exception: index out of bounds [IndexError]

If binaries are compiled in debug mode, then at runtime -

main.nim(175)            main
nico.nim(1539)           init
nico.nim(1141)           loadFont
sdl2.nim(349)            loadSurface
nico.nim(1143)           :anonymous
nico.nim(1128)           createFontFromSurface
system.nim(2811)         sysFatal
Error: unhandled exception: index out of bounds [IndexError]

Load full screen image?

Sorry--this is more of a question, not an issue!

Is there a way to load a large (e.g. full screen or 128 x 128) indexed PNG image as a background? I tried creating a single sprite, but it didn't seem to work.

Thanks!

Compiling error

/nico/backends/common.nim(323, 30) Error: type mismatch: got but expected 'uint8'

Add warning about different sdl2 packages

I was following the beginners tutorial but I was having trouble compiling the initial nicoboot example app that was created for me but I couldn't figure out why. It said it couldn't load sdl2/sdl even though I'd installed nico, its dependencies and added SDL2.dll to the root folder.

I later figured out I had other nimble sdl2 packages installed (I think it was just called sdl2), while nico needs sdl2_nim specifically it appears. After uninstalling the old sdl2 packages using nimble it worked fine again.

Is there a warning somewhere about this or did I just miss it? Maybe it should be added to the README if not already there.

nico package not found

I've just installed nim on my Win10 x64 system and successfully made a helloworld.nim program.
I now tried installing nico with nimble install nico and got the following output:

$ nimble install nico --verbose
    Reading official package list
    Prompt: nico not found in any local packages.json, check internet for updated packages? [y/N]
    Answer: y
Downloading Official package list
     Trying https://github.com/nim-lang/packages/raw/master/packages.json
    Success Package list downloaded.
    Reading official package list
     Error: Package not found.

SDL Calls

Sorry I couldn't find another way to communicate with you.

Hi, I am absolutely new to this. (in fact I haven't installed nim yet)

Using nico, could I make direct calls to SDL2?
Could for example (SDL_SetWindowOpacity) from nico, or how would this be done?
Thanks for all your work.

Need more useful error messages when loading invalid fonts.

In the example project generated by nicoboot, I can't change the default font even though I replaced the .png and .png.dat files.

If I change the index in loadFont and setFont, it compiles and then shows an error:

Error: unhandled exception: No font selected [Exception] Error: execution of an external program failed: '/Users/******/Code/nicotest/nicotest ' stack trace: (most recent call last) /private/var/folders/3d/70xtvzmj457d129np6fy7jjm0000gn/T/nimblecache-903273217/nimscriptapi_463822526.nim(187, 16) /Users/******/Code/nicotest/nicotest.nimble(20, 7) runrTask /opt/homebrew/Cellar/nim/1.6.2/nim/lib/system/nimscript.nim(273, 7) exec /opt/homebrew/Cellar/nim/1.6.2/nim/lib/system/nimscript.nim(273, 7) Error: unhandled exception: FAILED: nim c -r -d:danger -o:nicotest src/main.nim [OSError] Error: Exception raised during nimble script execution

I also tried renaming the file (to fonty.png) with no luck.

My code:

import nico

const orgName = "flkdsa"
const appName = "Working Title"

var buttonDown = false

proc gameInit() =
  loadFont(0, "fonty.png")
  loadSpriteSheet(0, "icon.png", 32, 32)

proc gameUpdate(dt: float32) =
  buttonDown = btn(pcLeft)

proc gameDraw() =
  cls()
  setColor(if buttonDown: 7 else: 3)
  setFont(0)
  printc("welcome to " & appName, screenWidth div 2, screenHeight div 2)

nico.init(orgName, appName)
nico.createWindow(appName, 320, 240, 4, false)
nico.run(gameInit, gameUpdate, gameDraw)

My 'fonty.png.dat':
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890

The png is attached.
fonty

Linux has outdated SDL

Hello!

My linux distro (ubuntu 18, which isn't too old, i suspect many people are still on this version) has SDL 2.0.0, which causes nico to crash. This is because it calls into SDL_RWsize, which is not in SDL 2.0.0 (apparently it was a macro in that version)

I had to build from the source on their website, then manually set LD_LIBRARY_PATH to point to this. This made it all work!

I had to build from the source on the website: https://www.libsdl.org/release/SDL2-2.0.12.tar.gz
A github mirror I tried seemed to only build SDL 2.0.0

Not a problem with nico, just adding this issue so that other linux users know what the issue is!

Audio bug w/js - Music not playing, infinite sfx

When compiling this project for the web, the music is not played, and the ending sound effect (when you die) is played infinitely and the game doesn't progress. This could be some other compilation related bug, that doesn't have to do with audio.

Try the game locally first to see how it should behave, because it works natively.

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.