Code Monkey home page Code Monkey logo

chirp8's People

Contributors

mratsim avatar vindaar avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

chirp8's Issues

Implement key presses

Currently there is no keypress support.

The following loop must be modified:

chirp8/src/chirp8.nim

Lines 34 to 44 in ba98bdb

while gameState.running:
while sdl2.pollEvent(gameState.event):
case gameState.event.kind:
of QuitEvent:
gameState.running = false
break
of KeyDown:
gameState.running = false
break
else:
break

KeyDOWN matches pressing
KeyUp matches release

So something like that can be done

 while gameState.running: 
   while sdl2.pollEvent(gameState.event): 
     case gameState.event.kind: 
     of QuitEvent: 
       gameState.running = false 
       break 
     of KeyDown: 
       case event.key.keysym.sym:
       of K_KP0: foo(key0)
       of K_KP1: foo(key1)
       ...
     else: 
       break 

Keycodes are available here: https://github.com/nim-lang/sdl2/blob/master/src/sdl2/private/keycodes.nim

A new "key" array should be added to store the key states (up or down)

Layout

The original key layout is this:

2018-03-31_11-28-02

with 2-4-6-8 corresponding to up left right down.

Ideally Chirp-8 should read mapping from a .cfg to so that people can customize their keyboard mapping:

  • laptops without a keypad
  • non-QWERTY keyboard
  • ...

cc @Vindaar

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.