روز اول مدسه نیکی کلافه
#include iostream
#include vector
#include cstdlib
#include ctime
#include conio.h // برای getch()
#include windows.h // برای Sleep()
using namespace std
const int width = 40
const int height = 20
const int numObstacles = 50 // موانع بیشتر!
int carPos = width / 2
bool gameOver = false
int score = 0
struct Obstacle {
int x
int y
}
vectorObstacle obstacles
void initializeObstacles() {
obstacles.clear()
for (int i = 0 i numObstacles ++i) {
Obstacle obs
obs.x = rand() width
obs.y = rand() height
obstacles.push_back(obs)
}
}
void draw() {
system(cls) // برای ویندوز
for (int y = 0 y height y++) {
for (int x = 0 x width x++) {
bool obstaclePrinted = false
for (auto &obs : obstacles) {
if (obs.x == x && obs.y == y) {
cout #
obstaclePrinted = true
break
}
}
if (!obstaclePrinted) {
if (y == height - 1 && x == carPos)
cout A // ماشین بازیکن
else
cout
}
}
cout endl
}
cout امتیاز: score
cout برای خروج: q endl
}
void update() {
for (auto &obs : obstacles) {
obs.y++
if (obs.y = height) {
obs.y = 0
obs.x = rand() width
score++
}
if (obs.y == height - 1 && obs.x == carPos) {
gameOver = true
}
}
}
void input() {
if (_kbhit()) { // اگر کلیدی زده شد
char move = _getch()
if (move == a && carPos 0)
carPos--
else if (move == d && carPos width - 1)
carPos++
else if (move == q)
gameOver = true
}
}
int main() {
srand(time(0))
initializeObstacles()
while (!gameOver) {
draw()
input()
update()
Sleep(50) // سرعت بازی (میتوانی کمتر کنی تا سریعتر شود)
}
cout بازی تمام شد! امتیاز نهایی: score endl
return 0
}
#include vector
#include cstdlib
#include ctime
#include conio.h // برای getch()
#include windows.h // برای Sleep()
using namespace std
const int width = 40
const int height = 20
const int numObstacles = 50 // موانع بیشتر!
int carPos = width / 2
bool gameOver = false
int score = 0
struct Obstacle {
int x
int y
}
vectorObstacle obstacles
void initializeObstacles() {
obstacles.clear()
for (int i = 0 i numObstacles ++i) {
Obstacle obs
obs.x = rand() width
obs.y = rand() height
obstacles.push_back(obs)
}
}
void draw() {
system(cls) // برای ویندوز
for (int y = 0 y height y++) {
for (int x = 0 x width x++) {
bool obstaclePrinted = false
for (auto &obs : obstacles) {
if (obs.x == x && obs.y == y) {
cout #
obstaclePrinted = true
break
}
}
if (!obstaclePrinted) {
if (y == height - 1 && x == carPos)
cout A // ماشین بازیکن
else
cout
}
}
cout endl
}
cout امتیاز: score
cout برای خروج: q endl
}
void update() {
for (auto &obs : obstacles) {
obs.y++
if (obs.y = height) {
obs.y = 0
obs.x = rand() width
score++
}
if (obs.y == height - 1 && obs.x == carPos) {
gameOver = true
}
}
}
void input() {
if (_kbhit()) { // اگر کلیدی زده شد
char move = _getch()
if (move == a && carPos 0)
carPos--
else if (move == d && carPos width - 1)
carPos++
else if (move == q)
gameOver = true
}
}
int main() {
srand(time(0))
initializeObstacles()
while (!gameOver) {
draw()
input()
update()
Sleep(50) // سرعت بازی (میتوانی کمتر کنی تا سریعتر شود)
}
cout بازی تمام شد! امتیاز نهایی: score endl
return 0
}
- 🙈
- 🙉
- 🙊
- 💛
- ❤
- 💔
- 💯
- 💢
- ✋
- ✌
- 👍
- 👎
- ✊
- 👏
- 👈
- 👉
- 🙏
- 💪
- 🎬
- 🐥
- 🌹
- 🍁
- 🍉
- 🍕
- 🍳
- 🎂
- 🎈
- ☕
- 🌍
- 💩
- 🚗
- ⏰
- ☔
- 📙
- ⭐
- 😀
- 😂
- 😉
- 😊
- 😍
- 😘
- 💋
- 😋
- 😜
- 👀
- 😐
- 😕
- 😎
- 😌
- 😒
- 😬
- 😔
- 😢
- 😭
- 😷
- 😎
- 😨
- 😱
- 😡
- 😠
😊
مشاهده نظرات
X
این ویدیو
×
گزارش تخلف
×در صورتیکه توضیحی در مورد گزارش تخلف دارید در کادر زیر بنویسید
افزودن به لیست پخش
×دانلود اپلیکیشن فیلو
×برای دانلود این ویدیو، اپلیکیشن فیلو را از مارکت ها یا بصورت مستقیم نصب کنید.
در صورتی که اپلیکیشن فیلو را نصب کرده اید؛ برای تماشا یا دانلود این ویدیو وارد اپلیکیشن شده، از منو گزینه اسکن را انتخاب کرده و کد زیر را اسکن کنید.
