עקבו אחר הסרטון הבא כדי לצפות כיצד להתקין את האפליקציה של האתר על מסך הבית של המכשיר שברשותכם.
תזכורת: This feature may not be available in some browsers.
זה פשוט לא רץ כמו שזה צריך לרוץ. זה עושה איזה מן מעוין כזה קטן עם הכוכביותמה הבעיה?
כוכבית אמורה לנוע על מסך שהמידות שלו הם 20*80 , בכל פעם שפוגעת ב"קיר" היא פשוט משנה כיוון, אם זזה בכיוון ימין ומעלה ופגעה בקיר העליון, תנוע בכיוון ימין ומטה, אם אחר כך פגעה בקיר הימני, תנוע בכיוון שמאל ומטה וכן הלאה...מה אמור לקרות?
אכן זאת הייתה הבעיה, אני כל הזמן נופל על הקטנות האלה של סימנים. מעצבן.קודם כל,שים לב שכל ה IF שלך הם עם שווה אחד במקום שתיים,אני חושב שמשם אתה יכול להמשיך לבד.
קיבלתיאגב אני ממליץ שתפתח הרגל,שכל מספר שאתה מכניס כמה פעמים בתור משתנה,תתן לו שם ו DEFINE בתחילת התוכנית,ככה שהיא תהיה מובנת למישהו שלא יודע מה זה 20 ,80,30 וכו..
DEFINE SCREEN_HEIGHT 20
DEFINE SCREEN_WIDTH 80
DEFINE FPS 30
וכו
רק תיקון קטן קומפיילר לא מריץ תוכנית הוא מקמפל/בונה אותה. מערכת הפעלה מריצה תוכניותקוד:#include <stdio.h> #include <conio.h> #include <dos.h> #include <windows.h> #include <time.h> #define SCREEN_HEIGHT 25 void sleep_seconds(long seconds) { clock_t limit, now = clock(); limit = now + seconds * CLOCKS_PER_SEC; while (limit > now) now = clock(); } void sleep_ticks(long ticks) { clock_t limit, now = clock(); limit = now + ticks; while (limit > now) now = clock(); } void wait(long milliseconds) { long timeout = clock() + milliseconds; while (clock() < timeout) continue; } void gotoxy(int x, int y) { COORD coord; coord.X = x; coord.Y = y; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord); } void main() { int xpos, ypos,x,y; x = 0; y = 12; xpos = 1; ypos = 13; while (ypos >= 0 && xpos >= 0) { if ((xpos = x + 1) && (ypos = y + 1)) // כוכבית נעה ימינה ולמטה { gotoxy(xpos, ypos); putchar('*'); gotoxy(xpos - 1, ypos - 1); putchar(' '); x = xpos; y = ypos; ypos++; xpos++; Sleep(30); if (xpos = 80) xpos = xpos - 2; if (xpos = 0) xpos = xpos + 2; if (ypos = 20) ypos = ypos - 2; if (ypos = 0) ypos = ypos + 2; } if ((xpos = x - 1) && (ypos = y + 1)) // כוכבית נעה שמאלה ולמטה { gotoxy(xpos, ypos); putchar('*'); gotoxy(xpos + 1, ypos - 1); putchar(' '); x = xpos; y = ypos; ypos++; xpos--; Sleep(30); if (xpos = 80) xpos = xpos - 2; if (xpos = 0) xpos = xpos + 2; if (ypos = 20) ypos = ypos - 2; if (ypos = 0) ypos = ypos + 2; } if ((xpos = x - 1) && (ypos = y - 1)) // כוכבית נעה שמאלה ולמעלה { gotoxy(xpos, ypos); putchar('*'); gotoxy(xpos + 1, ypos + 1); putchar(' '); x = xpos; y = ypos; ypos--; xpos--; Sleep(30); if (xpos = 80) xpos = xpos - 2; if (xpos = 0) xpos = xpos + 2; if (ypos = 20) ypos = ypos - 2; if (ypos = 0) ypos = ypos + 2; } if ((xpos = x + 1) && (ypos = y - 1)) // כוכבית נעה ימינה ולמעלה { gotoxy(xpos, ypos); putchar('*'); gotoxy(xpos - 1, ypos + 1); putchar(' '); x = xpos; y = ypos; ypos--; xpos++; Sleep(30); if (xpos = 80) xpos = xpos - 2; if (xpos = 0) xpos = xpos + 2; if (ypos = 20) ypos = ypos - 2; if (ypos = 0) ypos = ypos + 2; } } system("pause"); }
אני יודע שיש דרכים אחרות לעשות את ה"כדור המקפץ", אבל מנסה להבין מה לא בסדר בקוד הזה... הקומפיילר מריץ את התוכנית אבל היא לא רצה כמו שצריך...
@vithano
@coldfire