-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
c6a1206
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Подскажите пожалуйста откуда берется дополнительная строка?
assert(sizeof(map) == map_w*map_h+1); // +1 for the null terminated string
c6a1206
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Это не строка дополнительная, а символ. Чтобы промаркировать конец строки, там стоит ещё дополнительный символ с нулевым кодом.
c6a1206
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Спасибо! Прочитал как map_w * (map_h + 1)
Отктыл сгенерированный файл в GIMPe цвета почему-то отличаются.
c6a1206
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Сильно отличаются? Можно скриншот?
c6a1206
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
c6a1206
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Очень странно. Явно перепутан порядок каналов, вместо rgb он читает grb. Никогда такого формата не видел. Причём на этой стадии даже little endian / big endian не должен влиять... Можете мне .ppm файл скинуть напрямую? Я заинтригован. [email protected]
c6a1206
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Не получил письма, вы ответили в гитхаб-ветку.
c6a1206
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Переслал в лс
c6a1206
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Это прелестный файл! У меня тоже цвета неправильные. Рассказывайте, как вы его получили!!!
Я правильно понимаю, что этот файл получен при помощи кода из этого коммита как есть, без изменений? Если так, то у меня баг. Расскажите, пожалуйста, какая у вас операционная система, и какой компилятор. Хочу всё знать про машину, на которой этот файл сгенерирован.
c6a1206
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Код скопирован с вашего коммита без изменений. ОС Windows 10 64. Я использую Microsoft Visual Studio 2017 Community компилятор по умолчанию ничего не менял.
c6a1206
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
У меня на работе есть такой компьютер, завтра проверю. Это точно баг у меня, причём на данный момент я ума не приложу, где он может быть. Я специально старался избегать подобных ситуаций.
c6a1206
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Скомпилировал на Ubuntu 64 gcc на тойже машине. Получилось как задуманно.
c6a1206
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
По поводу grb. Удалось ли понять в чём проблема?
c6a1206
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
да, удалось
c6a1206
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Правильно ли я понимаю, что нам не важно, какая именно цифра используется в
map
? Что 1, что 2, что 3, это всё считается за "наличие". Верно?Если так, то зачем использовать 1, 2, 3? Есть ли какой-то смысл в этом?
c6a1206
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Да, подойдёт любой символ. Но есть тонкость: я использую символы '1', '2', '3'. Они в таблице кодировки идут по порядку. Поэтому разность между двумя символами '1' - '0' = 1 (обратите внимание, что результат - не символ, а число). Того же результата можно было бы добиться, например, 'b' - 'a' = 1. Таким способом я получаю индекс используемой текстуры (число) для данной клетки карты.
c6a1206
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Нюанс не ясен. Нигде в коде не вижу получение разницы между '1' и '0' или прочими символами. Выходит, этот нюанс совершенно не нужен?
c6a1206
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Это используется в дальнейших коммитах.
c6a1206
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Выходит, требоания из следующего этапа затесались в предыдущий. Печаль.
c6a1206
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А в чём печаль-то? В том, что я чуть-чуть представляю, что мне может понадобиться через полчаса? Это ведь совершенно очевидно, что нам нужно будет больше одного цвета. Как ещё хранить эту информацию?
c6a1206
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Проблема в том, что описание этапа даже не намекает про хранение цвета, поэтому это совершенно неочевидно для читателя. Неочевидное вызывает вопросы, замедляет понимание.
Я вижу следующие пути разрешения этого непонимания:
Оба способа приводят к потерям времени и к риску того, что материал будет понят не полностью. Для предотвращения подобных рисков, на мой взгляд, следует стараться избегать подобной рассинхронизации документации и кода.
Можно посчитать данное отношение излишеством. Уверен, большинство читателей выбрали первый вариант. Я тоже хотел пойти этим путём, но затем поймал себя на мысли, что ведь тогда не прочитаю самого главного - кода. А ведь я хочу не просто прочитать, как вы сделали игру, я хочу узнать каждую деталь, чтобы смочь сделать больше. В связи с этим я взялся прочитать ваши статьи так, чтобы понять буквально всё. Обязуюсь и впредь задавать вопросы, если вас не затрудняет на них отвечать.
c6a1206
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Очень крутой курс, спасибо огромное! (извините за оффтоп)
c6a1206
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assertion `sizeof (map) == map_w * map_h + 1' failed, this assertion is failing, and i haven't gotten the slightest clue on why that's happening.
c6a1206
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have you modified the source code or are you running exactly the the code from this repository?
c6a1206
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ssloy yes, i'm sure the code is correct because i checked it for typos 3 times now.
c6a1206
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Send me the cpp file by mail, i'll look into it. [email protected]
c6a1206
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ssloy Sure, but i'll see if i can't figure it out first.
c6a1206
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ssloy So it turns out the the map char array is 165 bytes in size, but map_w * map_h + 1 is evaluating to 257. I sent you the file btw.
c6a1206
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@halt27 Apparently, you have modified the map. It must be map_w tiles wide and map_h tiles long. Thus total length of the string map_w*map_h + 1, where +1 is for the null-termination of the string ('\0' character).
c6a1206
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ssloy I see what the problem was is very strange, since i'm setting chrome to immediately translate other languages to english, it somehow messed up the structure of the map and i ended up with the wrong structure, now it's working fine. Thanks for the help!
c6a1206
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Вот такое изображение вышло..
.
c6a1206
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Maxim-debug-msi
#9