[WIP] Doggie. (I am learning to program)


#1

Hi. I am Fede, from Spain.
My English is very bad, so I use Google translator.

I present my project: Doggie.

It’s about a little dog that must save the world. How not? :slight_smile:
It digs in the earth to obtain things and be able to fight against evil.

Greetings to all

https://www.youtube.com/watch?v=RhaNAlhYAl8


(Miloslav Číž) #2

Hello, nice to meet you :slight_smile:

The graphics are very nice, is it your own work? Are you planning to share the source code?


#3

Thanks and nice to meet you too.

Yes, the graphics are mine and I will share them when I finish.


(Simon) #4

That looks great! Nice work.


(Nicole Birgel) #5

Interesting idea a bit like this sony dog simulator :+1:


(Jean Charles Lebeau) #6

Beautiful game :wink: Welcome


#7

Well, I’ve already returned.

It has cost me sweat and tears to put what I have gotten him. And he has known me little.
I’ve thrown about ten times more optimizing and ‘tricking’ than programming and drawing.

Every time I discovered a new ‘trap’, I would redo the whole code.

It only has two levels and a lot of honor.

He hardly whistles, first because no idea of ​​music and second because anyway it did not fit.

What bothered me the most was the compiler. As soon as I got anything new, I lost about half a kilobyte. I had to think a lot about putting things that I would not use several times.
The truth is that I could not guess what is influencing the program to change illogically when removing things. It suppressed a call to a function and instead of lowering the size, it went up.

Some tricks.

1-The map with metatiles.
2-The same graphic mirrored everywhere.
3-Cut out in library parts that I would not use.

Others were simply trial and error.
Having several methods to do the same task, he implemented them all and saw which ate less memory.

But do not make mistakes, I’ve had a good time.
It reminded me of my time when I was messing with the Spectrum.

Thank you all for the documentation that exists and especially for the magazines.

Here a gif, the hex and the sources.

A greeting.

https://github.com/PapaFede/Perrita

P.S. It’s a beta.

Doggie2X


(Boti Kis) #8

This is wonderful!

I Just saw it, great work!


(Pharap) #9

5 minutes into optimisation:

Before:

Sketch uses 28552 bytes (99%) of program storage space. Maximum is 28672 bytes.
Global variables use 1581 bytes (61%) of dynamic memory, leaving 979 bytes for local variables. Maximum is 2560 bytes.

After:

Sketch uses 27182 bytes (94%) of program storage space. Maximum is 28672 bytes.
Global variables use 1571 bytes (61%) of dynamic memory, leaving 989 bytes for local variables. Maximum is 2560 bytes.

I haven’t tested but I’m 90% sure it still works.

If anyone wants to check, the .hex is here:
https://gist.githubusercontent.com/Pharap/0fd34c05b4807922484e1e60720f16fb/raw/31971cbec54376a4b791de860b8fb13e4240beca/Perrita.ino.arduino_leonardo.hex

(And the actual gist: here.)


Edit
(By the way, you’re breaking the rules of the Font3x5 licence by removing the licence header. You’re not allowed to remove the licence header, even if you alter the code.)


(Pharap) #10

I could probably manage more if I could read spanish, but 12% will have to do.

Before:

Sketch uses 28552 bytes (99%) of program storage space. Maximum is 28672 bytes.
Global variables use 1581 bytes (61%) of dynamic memory, leaving 979 bytes for local variables. Maximum is 2560 bytes.

After:

Sketch uses 25086 bytes (87%) of program storage space. Maximum is 28672 bytes.
Global variables use 1545 bytes (60%) of dynamic memory, leaving 1015 bytes for local variables. Maximum is 2560 bytes.

I’ve forked the repo and committed my changes:

And here’s the .hex for those who just want the .hex, or want to test that everything still works (it might not, sometimes I break things by mistake).:
https://raw.githubusercontent.com/Pharap/Perrita/master/Perrita.ino.arduino_leonardo.hex


(Simon) #11

to

Awesome saving right there!


(Pharap) #12

It could potentially have been more if I understood Spanish.
(Not to forget the number of warnings I stamped out. :P)


(Simon) #13

I was curious about all of the methods without a return type … didn’t even know you could do that.

Did there contribute to the savings or were these more cosmetic / stylistic??


(Pharap) #14

You can’t.

sketch\Varios.h:24:15: warning: ISO C++ forbids declaration of ‘EsperarBotonA’ with no type [-fpermissive]

EsperarBotonA()

           ^

sketch\Varios.h: In function ‘int EsperarBotonA()’:

I’m fairly sure they did, because in the absense of a return type the compiler appears to default to int, and both bool and uint8_t are smaller than int.

This is actually a behaviour that was originally part of the C spec, but it’s never been part of the C++ spec and I think even C has obsoleted that behaviour (I checked, C99 dropped it),
so this is only permitted because of that awful -fpermissive flag.

The Arduino IDE writers really had no idea just what montrosities they were unleashing upon the world when they decided to include that flag into the build process.


(Simon) #15

Ah … that explains everything. Defaulting to an int would certainly have added a chunk of extra code.


#16

Sorry. I am a noob in the use of third-party libraries.

What is it: “the licence header”?

Is the file “LICENSE” in https://github.com/filmote/Font3x5?

Thanks you.


#17

Thank you very much for your changes. I will study them to learn what you have done.

Thank you very much really.


(Pharap) #18

I didn’t realise @filmote didn’t put the licence in the .h file as a header.

Sometimes people put the licence at the top of the .h/.cpp files, which is what I meant by “licence header”.

In which case, yes, just use the LICENSE file.

I have made 3 main changes:

  • Get rid of strcpy_P by using a version of my AsFlashString trick.
    • When the print function is given a const __FlashStringHelper *, it knows to read directly from progmem. AsFlashString is a helper function I wrote to make using this easy.
  • I added all the missing return values.
    • Functions need to have a return type (e.g. void, bool/boolean, uint8_t/byte),
      otherwise they default to int, which is 2 bytes wide (on Arduino only, in normal C++ you would get an error)
  • I replaced Arduboy2 with Arduboy2Base.
    • Arduboy2 is actually Arduboy2Base with added writing/printing logic, but you are already using Font3x5, so the printing part isn’t needed - you can just use Arduboy2Base.

#19

Thank you very much again.

In my land there is a saying of thanks: “I do not give you two kisses because I do not arrive”. :slight_smile:

(No te doy dos besos porque no llego).


(Matt) #20

This game is looking really nice. The graphics are top notch and I like the premise.

I wish the dog moved a bit faster.

I had to rename player.h to Player.h to get it to compile on a case sensitive file system.

How do you get bones? I can’t seem to find any. never mind, I got it now.