Rogue-like ascii based on Arduboy


(Simon) #61

I think you need to use …

arduboy.exitToBootLoader();


#62

Thank you! @filmote.
I’m very embarrassed because I have made a very rudimentary question.
I will post it after checking firmly. really sorry…:disappointed_relieved:


#63

“Au” is the chemical name for gold. (it’s all Latin and stuff)
I think it meant the amount of $ you got.

Uh … … … Mmm.



If he used my version (in which he didn’t, not his fault) , we will see this instead:

if (st == stm)
    stm++;
st++;

K&R indenting.

Saved 4 bytes. (or 2 byte? I forgot.)

I feel like my work often goes unnoticed…just saying.

Use ‘drawFastVLine’ instead. It’s simpler, and therefore faster.

drawFastVLine(starting_x, starting_y, length/*only goes DOWN*/, color);

drawFastHline(starting_x, starting_y, length/*only goes RIGHT*/, color);

STUPID IOS KEYBOARD!

That’s actually mine…

You’re fine.

Although it might be done better in Private Messages.


#64

Thank you for your reply, @CDR_Xavier.

Yes, I use ‘drawFastVLine’.

I am sorry that I made you feel bad.

I will be careful. I’m sorry.


(Stephane C) #65

If you had a GitHub repo for this game we could help you even more and faster :slight_smile:

Will this be in open source? There’s some things I would try implement if it ever gets open source.


(Pharap) #66

問題ない。

Short for “aurum”.

I thought @BlueMax meant “your post in the big asteroids thread” rather than “your big asteroids game”.

If it was supposed to be the latter then yes, I didn’t write Big Asteroids.
(I did provide some advice/suggestions though.)

はい!I mean, yes! :P

I’ve been putting off explaining the licences because it’s hard enough to understand if you speak fluent English, never mind if you don’t.

(Though @BlueMax’s English is clearly better than my Japanese.)


(Scott R) #67

The good thing about Cathy3k and No_USB is you can still upload with USB as normal.

I was planning to use No_USB on every game to save some spi flash space if there’s ever enough games to fill my Arduboy.


(Scott) #68

I suggest you use the DOWN button to invoke exitToBootloader(). The bootloader only remains in upload mode for about 8 seconds if an upload isn’t started. It then restarts the sketch. By using DOWN to start the bootloader, the user can press and hold the DOWN button. The sketch will then call exitToBootloader() as a result but if the bootloader times out and restarts the sketch, the DOWN button will be detected by ARDUBOY_NO_USB code and re-enter the bootloader.

If you use the RIGHT button, the user would only get one shot, unless they switch to holding the DOWN button before the bootloader times out.


(Scott) #69

I think Evade 2 does it’s own thing to remove USB. Arduventure uses the Arduboy2 library features.


(Pharap) #70

@BlueMax
大メモリせヴィング!

Before:

Sketch uses 28204 bytes (98%) of program storage space. Maximum is 28672 bytes.
Global variables use 2354 bytes (91%) of dynamic memory, leaving 206 bytes for local variables. Maximum is 2560 bytes.

After:

Sketch uses 27614 bytes (96%) of program storage space. Maximum is 28672 bytes.
Global variables use 2353 bytes (91%) of dynamic memory, leaving 207 bytes for local variables. Maximum is 2560 bytes.

コード:

void specialAttack(byte mon) {  //mon=0 to 25 mon vari

  bool hit = false;
  switch (mon) {
    case 5:     //IceMon
      if (random(5) == 0) {
        hit = true;
        mess(13);
        hslep = random(5) + 4;
        if (random(20) == 0) {
          hp = 0;
        }
      }
      break;
    case 6:     //R.snake
      if (st > 3 || hasRing(5) == 0) {
        if (random(5) == 0) {
          hit = true;
          mess(14);
          st--;
        }
      }
      break;
    case 9:     //Leprchaun
      if (random(10) != 0) {
        hit = true;
        mess(15);
        au = au - random(50);
      }
      break;
    case 12:    //Aquator
      uint8_t eq = equip(4, 1);
      if ( equip(4, 1) != 0 && bitRead(i4[eq - 1], 3) == 0) {
        if (hasRing(9) == 0) {
          hit = true;
          mess(16);
          i2[eq - 1]--;
        }
      }
      break;
    case 13:    //Nymph
      if (random(2) == 0) {
        byte t = random(20);
        if (bitRead(i4[t], 4) == 0) {
          hit = true;
          mess(15);
          deleteItem(t);
        }
      }
      break;
    case 15:    //Flytrap
      if (hlevi == 0) {
        hit = true;
        mess(17);
        hheld = 1;
      }
      break;
    case 17:    //Wraith
      if (lv > 5 && random(5) == 0) {
        hit = true;
        mess(20);
        nl = nl / 2;
        ex = nl - 1;
        lv--;
        hpm = hpm - 3 - random(7);
        if (hp > hpm) hp = hpm;
      }
      break;
    case 22:    //Vampire
      if (random(10) < 4) {
        hit = true;
        mess(21);
        byte r = random(3);
        if (r % 2 == 0) {
          if (hasRing(5) == 0 || st > 5) {
            st--;
          }
        }
        if (r > 0) {
          if (hp > 9) {
            hp--;
            hpm--;
          }
        }
      }
      break;
  }
  
  if(hit)
	flashHero();
}

由:

関数呼び出しが高価。
(Function calls are expensive.)
代入が安価。(でも、いつもじゃないです。)
(Assignment is cheap. (But not always.))


I’m slowly making sense of the variables…

hpmがHPマックスとmessがメッセージでしょうか?

hlevi, hheld, hslep… わかりません。


(Pharap) #71

@BlueMax

Before:

Sketch uses 27612 bytes (96%) of program storage space. Maximum is 28672 bytes.
Global variables use 2353 bytes (91%) of dynamic memory, leaving 207 bytes for local variables. Maximum is 2560 bytes.

After:

Sketch uses 27534 bytes (96%) of program storage space. Maximum is 28672 bytes.
Global variables use 2353 bytes (91%) of dynamic memory, leaving 207 bytes for local variables. Maximum is 2560 bytes.

コード:

void drawMap() {
  for (int i = 0; i < 21; i++) {
    for (int j = 0; j < 8; j++) {
      locate(i, j);
      //      if (known[i][j] == 1) {
	  
	  char c = ' ';
      if (getKnown(i, j) == 1) {
        if (dungeon[i][j] == 0) {
          c = ' ';
        } else if (dungeon[i][j] >= 1 && dungeon[i][j] <= 6 && isDark[dungeon[hx][hy] % 10 - 1] == 0) {
          //        } else if (dungeon[i][j] >= 1 && dungeon[i][j] <= 6 ) {
          //          if ((dungeon[i][j] == dungeon[hx][hy]) || (dungeon[i][j] == dungeon[hx][hy] - 10)) {
          if ( dungeon[i][j] < 40 && dungeon[i][j] % 10 == dungeon[hx][hy] % 10 ) {
            c = '.';
          } else {
            c = ' ';
          }
        } else if (dungeon[i][j] == 8) {
          c = '#';
        } else if (dungeon[i][j] >= 11 && dungeon[i][j] <= 16) {
          c = '%';
        } else if (dungeon[i][j] >= 21 && dungeon[i][j] <= 26) {
          c = '+';
        } else if (dungeon[i][j] >= 31 && dungeon[i][j] <= 38) {
          c = '?';
        } else if (dungeon[i][j] >= 41 && dungeon[i][j] <= 46) {
          c = '-';
        } else if (dungeon[i][j] >= 51 && dungeon[i][j] <= 56) {
          c = '|';
        } else if (dungeon[i][j] >= 61 && dungeon[i][j] <= 66) {
          c = '-';
        } else if (dungeon[i][j] == 68) {
          c = ' ';
        } else if (dungeon[i][j] >= 71 && dungeon[i][j] <= 76) {
          c = '|';
        }
      }
      arduboy.print(c);
    }
  }
}

由:

Same as the last time.


Before:

Sketch uses 27534 bytes (96%) of program storage space. Maximum is 28672 bytes.
Global variables use 2353 bytes (91%) of dynamic memory, leaving 207 bytes for local variables. Maximum is 2560 bytes.

After:

Sketch uses 27500 bytes (95%) of program storage space. Maximum is 28672 bytes.
Global variables use 2353 bytes (91%) of dynamic memory, leaving 207 bytes for local variables. Maximum is 2560 bytes

コード:

void drawHero() {
  if (hblnd == 0) {
    for (uint8_t i = 0; i <= 2; i++) {
      for (uint8_t j = 0; j <= 2; j++) {
        uint8_t tx = hx + i - 1;
        uint8_t ty = hy + j - 1;
        if (dungeon[tx][ty] >= 1 && dungeon[tx][ty] <= 6) { // (tx >= 0 && tx <= 20 && ty >= 0 && ty <= 7)
          locate(tx, ty);
          arduboy.print('.');
        }
      }
    }
  }
  locate(hx, hy);
  arduboy.print('@');
}

由:

(I’m not sure how to say “on the Arduboy/with the Arduboy”, so I guessed “アルジュボイは”.)

intが少なくとも16ビット算術型。
(アルジュボイはintがちょうど16ビット算術型。)
uint8_tがちょうど8ビット算術型。
アルジュボイのCPUが8ビット、8ビット算術型がいいですから。

も、アルジュボイはcharが8ビット文字型。
F("@")の型がconst __FlashStringHelper *
const __FlashStringHelper *がポインタ型。
アルジュボイはがポインタが16ビット型。

arduboy.print('@') -> Print::print(char)
arduboy.print(F("@")) -> Print::print(const __FlashStringHelper *)

言ってること分かるか?


#72

Good morning, my teacher @Pharap.

I’m really sorry for the wasteful program. Very embarrassed.:sweat_smile:
I will rewrite the program to the code taught by the teacher.

Yes. “hp” is hero’s hit point, and “hpm” is hero’s maximum hit point.
“hlevi” is variable that store time of hero levitation.
“hheld” is bool that hero held by Flytrap or not.
A hero can not hold on to Flytrap when he is levitating.
“hslep” is variable that store time of hero sleeping.
The “mess(byte)” is function that feedback to the player.(message for player)

Previous versions displayed a message like ”you hit emu. emu miss you…" when a hero attacked. However, the message was too long to display everything on the screen.(Only 21 characters!) . mess(0) and mess(1) is a remnant of that time.So, I changed to a method to flash the hero.This is quite different from the original “Rogue”. I also removed the monster’s name from the source code at that time.

Thank you very much. Please do not spend precious time for me.

By the way,

What does this say in English? “large memory se ving!”?


(Stephane C) #73

We don’t waste time, I am pretty sure Pharap enjoy helping you out. And I sure don’t mind helping you out too. I like what you did and it’s worth the effort to make it the best it can be :slight_smile:
And with the memory saving. It’s even better now.


(Simon) #74

I am not sure I understand this. Are you saying that if you use the ARDUBOY_NO_USB code, it will automatically detect the down button while the sketch is running?

This would be true if it is in setup() but not if it was in a menu or other passive part of the game.
If this is a menu


(Scott) #75

No, only once when the sketch first starts. The DOWN button detection code is in Arduboy2Core::mainNoUSB(), which is called in the replacement main() function generated by the ARDUBOY_NO_USB macro.

True, you could have your sketch look for a button during power up (but that’s already handled by ARDUBOY_NO_USB), or continually somewhere elsewhere in the sketch. Regardless, the DOWN button is still recommended over any other button as a defacto standard, as a way to keep things consistent between all sketches that have the USB code removed. Plus, this matches what’s used in the Cathy bootloader.


(Pharap) #76

こんばんわ

いいえ、問題ない。

あー、なるほど。

heroLevitationTime, isHeroHeld, heroSleepTime would be better.
これは詳しいですから。
(Because they are more descriptive.)

“A hero can not hold on to Flytrap when he is levitating.” should be “A Flytrap cannot hold on to the hero when he is levitating.”
(“X is held by Y”, “Y holds onto X”)

Also, about ‘a’ vs ‘the’…
‘A’ refers to ‘one of many’ (e.g. one Flytrap of many)
‘The’ refers to ‘that specific one’ or ‘the only one’ (e.g. there is only one hero, so he is ‘the hero’)
Think of it like this:
“The hero is an idiot” is like「あのヒーローは阿呆」

でも問題ない、わかりましたですから。
(But it isn’t a problem, because I understand.)

いいえ、問題ない。
私の目は鋭いです。
30分。多分45分。

すみません、わたしは間違えました。

  • I typed “savingu”, the software wrote 「サヴィング」
  • I noticed 「サ」, I changed to 「セ」… でも、ひらがなモードで ; n ;
  • 「ー」は忘れた。(I forgot the “ー”.)

大メモリセーヴィング = Large memory saving
“memory saving” here implies ‘memory saved from being wasted’.
(This is probably confusing for you. ‘saving’ has many meanings.)


A mini Japanese lesson for you:
“I like your game”
あなたの ゲームがすきです。
“anata no gehmu ga suki desu”
(Or to sound a bit more natural, “anata no gehm’ ga s’ki des’”. Make sure it sounds like “anata” and not “an’ta”, because “an’ta” is considered very rude for some reason.)


#77

Everyone in this community, @Pharap and @Vampirics.

Because of your kindness, I will cry.:disappointed_relieved: Thank you very much.

To @Pharap.

I truly think so too. I want to rewrite this program from the beginning all over again…

Indeed I understand!
僕の目は鋭くなかった…(I had no sharp eyes… )


#78

To @Vampirics.

Rogue4Vampirics.hex.pdf (75.7 KB)

I was also concerned about the key combination.

I wrote

if (arduboy.justPressed( A_BUTTON +DWN_BUTTON)){…

rewrite

if (arduboy.justPressed(DOWN_BUTTON)) {
if(arduboy.buttonsState()==24){…

How about this?
This time .hex is compiled with caterina bootloader, but I am using ARDUBOY_NO_USB. Since the implementation is not sufficient, please check it on the emulator.


(Stephane C) #79

What do you mean the implementation is not sufficient? We can still get to bootloader by holding down?

Anyway I tried it on the real hardware and it work well now. And I can get back to bootloader easily by holding down when I turn on.


#80

To @Vampirics.

I am glad I did not break your Arduboy.
It was good that the program also went well!