Coder Social home page Coder Social logo

Comments (5)

x2nie avatar x2nie commented on July 4, 2024 1

Thanks You !

from md_parola.

MajicDesigns avatar MajicDesigns commented on July 4, 2024

At the moment there is no way to do this. The sprite will be turned around by the library when the direction changes.

from md_parola.

x2nie avatar x2nie commented on July 4, 2024

I need a one more clarification, perhaps my question is not clear enough.
For the pacman1, when it is running in real hardware it first running from left to right, and the pacman heading to right side.
I can accept it.
(my parola sprite editor always drawn the pacman as heading to left (it also "flipped") , that looks like it make my thinking as complicated. I am sorry for that.)

But after pacman reached the screen width, the pacman heading to left side; which is what I want to avoid.
So, do you think that the only solution is I should writing a brand new function ?
Would you like to give me some clues for doing that?

from md_parola.

x2nie avatar x2nie commented on July 4, 2024

Hi, finally I found a solution without need of additional function (can work with current MD_Parola).
Well, inspired by Parola_Animation_Catalog.ino that show 2 different sprites for one animation, I created a flipped sprite to be shown as "not flipped" (because the second sprite will always flipped horizontally by library).

The idea is to provide 2 sprites, with the second one as flipped from first sprites

// Sprite Definition
const uint8_t F_ROCKET = 2;
const uint8_t W_ROCKET = 11;
const uint8_t PROGMEM rocket_launch[F_ROCKET * W_ROCKET] =  // rocket
{
  0x18, 0x24, 0x42, 0x81, 0x99, 0x18, 0x99, 0x18, 0xa5, 0x5a, 0x81,
  0x18, 0x24, 0x42, 0x81, 0x18, 0x99, 0x18, 0x99, 0x24, 0x42, 0x99,
};

const uint8_t PROGMEM rocket_depart[F_ROCKET * W_ROCKET] =  // rocket flipped no-flip
{
  0x81, 0x5a, 0xa5, 0x18, 0x99, 0x18, 0x99, 0x81, 0x42, 0x24, 0x18,
  0x99, 0x42, 0x24, 0x99, 0x18, 0x99, 0x18, 0x81, 0x42, 0x24, 0x18,
};

The full source-code below can be shown (as live / online simulation) here : https://wokwi.com/projects/346387200800195154
image

full code:

// Program to exercise the MD_Parola library
//
// Demonstrates an un-flpped sprite.
// a demo solution of question : https://github.com/MajicDesigns/MD_Parola/issues/102
//
// MD_MAX72XX library can be found at https://github.com/MajicDesigns/MD_MAX72XX
//

#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>

// Define the number of devices we have in the chain and the hardware interface
// NOTE: These pin numbers will probably not work with your hardware and may
// need to be adapted
#define HARDWARE_TYPE MD_MAX72XX::PAROLA_HW
#define MAX_DEVICES 11

#define CLK_PIN   13
#define DATA_PIN  11
#define CS_PIN    10

// HARDWARE SPI
MD_Parola P = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
// SOFTWARE SPI
//MD_Parola P = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);

// Global variables
const char msg[] = "Parola Sprites";

// Sprite Definition
const uint8_t F_ROCKET = 2;
const uint8_t W_ROCKET = 11;
const uint8_t PROGMEM rocket_launch[F_ROCKET * W_ROCKET] =  // rocket
{
  0x18, 0x24, 0x42, 0x81, 0x99, 0x18, 0x99, 0x18, 0xa5, 0x5a, 0x81,
  0x18, 0x24, 0x42, 0x81, 0x18, 0x99, 0x18, 0x99, 0x24, 0x42, 0x99,
};

const uint8_t PROGMEM rocket_depart[F_ROCKET * W_ROCKET] =  // rocket flipped no-flip
{
  0x81, 0x5a, 0xa5, 0x18, 0x99, 0x18, 0x99, 0x81, 0x42, 0x24, 0x18,
  0x99, 0x42, 0x24, 0x99, 0x18, 0x99, 0x18, 0x81, 0x42, 0x24, 0x18,
};

void setup(void)
{
  P.begin();
  P.displayText(msg, PA_CENTER, P.getSpeed(), 1000, PA_SPRITE, PA_SPRITE);
  P.setSpriteData(rocket_launch, W_ROCKET, F_ROCKET, rocket_depart, W_ROCKET, F_ROCKET);
}

void loop(void)
{
  if (P.displayAnimate())
    P.displayReset();
}

from md_parola.

x2nie avatar x2nie commented on July 4, 2024

or in easier to see:
image

from md_parola.

Related Issues (20)

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.