Permalink
Browse files

Painting test for color monster.

  • Loading branch information...
dulsi committed Jun 4, 2018
0 parents commit 53c0cadbbd4822209bd0816be50d57947a73562c
Showing with 1,335 additions and 0 deletions.
  1. +674 −0 LICENSE
  2. +26 −0 README.md
  3. +99 −0 TinyArcade.h
  4. +28 −0 TinyConfig.h
  5. +109 −0 TinyGameKit.h
  6. +67 −0 cateye.h
  7. +253 −0 colormonster.ino
  8. BIN images/cateye.png
  9. +79 −0 ui.h
  10. BIN ui/paint.png
  11. BIN ui/pointer.png
674 LICENSE

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -0,0 +1,26 @@
# Color Monster
You are a color monster trainer. In a black and white world, color monsters
are the greatest fighters. Explore the world. Collect more monsters to train.
Battle other trainers.
# Building
Color Monster is montser training game designed for the TinyArcade platform.
Load the viobyte.ino in the Arduino IDE. Install the TinyScreen library and you
should be able to build it for your device.
If you want to play it on a Linux computer, you can use the tinyscreensim
program (https://github.com/dulsi/tinyscreensim). Install glfw3 library.
Download the tinyscreensim. Run it with the command like:
../tinyscreensim/tinyscreensim colormonster colormonster.ino
Now you should be able to run colormonster.
# Thanks
Color Monster uses a modified tinyscreen-spritetile-lib by jonwingrove
https://github.com/jonwingrove/tinyscreen-spritetile-lib
The Cateye image is based on the Cateye from Tuxemon by Cavalcadeur is
licensed under CC-BY-SA 4.0
@@ -0,0 +1,99 @@
/*
TinyArcade.h - Last modified 6 September 2016
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Written by Ben Rose for TinyCircuits.
The latest version of this library can be found at https://tinycircuits.com/
*/
#ifndef TINYARCADE_H
#define TINYARCADE_H
#define TinyArcadePin1 45 //Left Button
#define TinyArcadePin2 44 //Right Button
#define TinyArcadePinX 42 //Analog Joystick x-axis
#define TinyArcadePinY 1 //Analog Joystick y-axis
#define TinyArcadePinUp 42 //Joystick UP
#define TinyArcadePinDown 19 //Joystick DOWN
#define TinyArcadePinLeft 25 //Joystick LEFT
#define TinyArcadePinRight 15 //Joystick RIGHT
const uint8_t TAJoystickUp = 1 << 0; //Mask
const uint8_t TAJoystickDown = 1 << 1; //Mask
const uint8_t TAJoystickLeft = 1 << 2; //Mask
const uint8_t TAJoystickRight = 1 << 3; //Mask
const uint8_t TAButton1 = 1 << 0; //Mask
const uint8_t TAButton2 = 1 << 1; //Mask
uint8_t arcadeVersion = 1;
void arcadeInit() {
pinMode(4, INPUT_PULLUP);
if (!digitalRead(4)) {
arcadeVersion = 2;
}
analogWrite(A0, analogRead(A0));//Set audio output to avoid picking up noise, even though audio isn't used
pinMode(TinyArcadePin2, INPUT_PULLUP);
pinMode(TinyArcadePin1, INPUT_PULLUP);
if (arcadeVersion == 2) {
pinMode(TinyArcadePinUp, INPUT_PULLUP);
pinMode(TinyArcadePinDown, INPUT_PULLUP);
pinMode(TinyArcadePinLeft, INPUT_PULLUP);
pinMode(TinyArcadePinRight, INPUT_PULLUP);
}
}
uint8_t checkButton(uint8_t btn) {
uint8_t rVal = 0;
if ((btn & TAButton1) && !digitalRead(TinyArcadePin1))
rVal |= TAButton1;
if ((btn & TAButton2) && !digitalRead(TinyArcadePin2))
rVal |= TAButton2;
return rVal;
}
uint8_t checkJoystick(uint8_t joystickDir) {
if (arcadeVersion == 1) {
int analogVal = analogRead(TinyArcadePinY);
uint8_t rVal = 0;
if ((joystickDir & TAJoystickUp) && analogVal < 512 - 250)
rVal |= TAJoystickUp;
else if ((joystickDir & TAJoystickDown) && analogVal > 512 + 250)
rVal |= TAJoystickDown;
analogVal = analogRead(TinyArcadePinX);
if ((joystickDir & TAJoystickLeft) && analogVal > 512 + 250)
rVal |= TAJoystickLeft;
else if ((joystickDir & TAJoystickRight) && analogVal < 512 - 250)
rVal |= TAJoystickRight;
return rVal;
} else if (arcadeVersion == 2) {
uint8_t rVal = 0;
if ((joystickDir & TAJoystickUp) && !digitalRead(TinyArcadePinUp))
rVal |= TAJoystickUp;
if ((joystickDir & TAJoystickDown) && !digitalRead(TinyArcadePinDown))
rVal |= TAJoystickDown;
if ((joystickDir & TAJoystickLeft) && !digitalRead(TinyArcadePinLeft))
rVal |= TAJoystickLeft;
if ((joystickDir & TAJoystickRight) && !digitalRead(TinyArcadePinRight))
rVal |= TAJoystickRight;
return rVal;
}
}
#endif
@@ -0,0 +1,28 @@
#ifndef TINYCONFIG_H
#define TINYCONFIG_H
#ifndef TINYSCREENSIM
#define TINYARCADE_CONFIG
//#define TINYSCREEN_GAMEKIT_CONFIG
#else
#define TINYSCREEN_GAMEKIT_CONFIG
#endif
#ifdef TINYARCADE_CONFIG
#define pgm_read_ptr(x) (*(x))
const uint8_t PROGMEM TAJoystick2Up = 1 << 4; //Mask
const uint8_t PROGMEM TAJoystick2Down = 1 << 5; //Mask
const uint8_t PROGMEM TAJoystick2Left = 1 << 6; //Mask
const uint8_t PROGMEM TAJoystick2Right = 1 << 7; //Mask
#define TINYSCREEN_TYPE TinyScreenPlus
#endif
#ifdef TINYSCREEN_GAMEKIT_CONFIG
#include <avr/pgmspace.h>
#define TINYSCREEN_TYPE 0
#define SerialUSB Serial
#endif
#endif
@@ -0,0 +1,109 @@
#ifndef TINYGAMEKIT_H
#define TINYGAMEKIT_H
const uint8_t PROGMEM TAJoystickUp = 1 << 0; //Mask
const uint8_t PROGMEM TAJoystickDown = 1 << 1; //Mask
const uint8_t PROGMEM TAJoystickLeft = 1 << 2; //Mask
const uint8_t PROGMEM TAJoystickRight = 1 << 3; //Mask
const uint8_t PROGMEM TAJoystick2Up = 1 << 4; //Mask
const uint8_t PROGMEM TAJoystick2Down = 1 << 5; //Mask
const uint8_t PROGMEM TAJoystick2Left = 1 << 6; //Mask
const uint8_t PROGMEM TAJoystick2Right = 1 << 7; //Mask
const uint8_t TAButton1 = 1 << 0; //Mask
const uint8_t TAButton2 = 1 << 1; //Mask
#define GAMEKIT_HASJOYSTICK 1
#define GAMEKIT_HASBUTTONS 2
byte gamekit_read = 0;
int gamekit_data[4];
byte gamekit_buttons;
void arcadeInit()
{
Wire.begin();
}
void readJoystickButtons()
{
Wire.requestFrom(0x22,6);
for(int i=0;i<4;i++)
{
gamekit_data[i]=Wire.read();
}
byte lsb=Wire.read();
for(int i=0;i<4;i++)
{
gamekit_data[i]<<=2;
gamekit_data[i]|= ((lsb>>(i*2))&3);
gamekit_data[i]-=511;
}
gamekit_buttons=~Wire.read();
gamekit_read = GAMEKIT_HASJOYSTICK | GAMEKIT_HASBUTTONS;
}
uint8_t checkButton(uint8_t btn)
{
if (0 == (gamekit_read & GAMEKIT_HASBUTTONS))
{
readJoystickButtons();
gamekit_read = gamekit_read & (~GAMEKIT_HASBUTTONS);
}
uint8_t answer = 0;
if ((btn & TAButton1) && (gamekit_buttons & 4))
answer |= TAButton1;
if ((btn & TAButton2) && (gamekit_buttons & 8))
answer |= TAButton2;
return answer;
}
uint8_t checkJoystick(uint8_t joystickDir)
{
if (0 == (gamekit_read & GAMEKIT_HASJOYSTICK))
{
readJoystickButtons();
gamekit_read = gamekit_read & (~GAMEKIT_HASJOYSTICK);
}
uint8_t answer = 0;
int RX=gamekit_data[0];
int RY=gamekit_data[1];
int LX=gamekit_data[2];
int LY=gamekit_data[3];
if ((joystickDir & TAJoystickLeft) && (LX > 100))
{
answer |= TAJoystickLeft;
}
else if ((joystickDir & TAJoystickRight) && (LX < -100))
{
answer |= TAJoystickRight;
}
if ((joystickDir & TAJoystickUp) && (LY > 100))
{
answer |= TAJoystickUp;
}
else if ((joystickDir & TAJoystickDown) && (LY < -100))
{
answer |= TAJoystickDown;
}
if ((joystickDir & TAJoystick2Left) && (RX > 100))
{
answer |= TAJoystick2Left;
}
else if ((joystickDir & TAJoystick2Right) && (RX < -100))
{
answer |= TAJoystick2Right;
}
if ((joystickDir & TAJoystick2Up) && (RY > 100))
{
answer |= TAJoystick2Up;
}
else if ((joystickDir & TAJoystick2Down) && (RY < -100))
{
answer |= TAJoystick2Down;
}
return answer;
}
#endif
Oops, something went wrong.

0 comments on commit 53c0cad

Please sign in to comment.