C语言easyx飞机大战源码+素材(大屏版)

在上一期的博客中给大家分享了小屏版的飞机大战的源码和素材

往期回顾:

C语言easyx飞机大战源码+素材

(点击这里进入)

今天给大家带来一个更高级的飞机大战版本

废话不多说,直接看效果

看着不错吧

接下来给大家看看部分源码

#include "stdafx.h"
#include "Game.h"
#include "DealObject.h"
#include "Tools.h"

IMAGE temp_img, img_bk;
IMAGE img_plane, img_ufoa, img_ufob, img_ufoc;
IMAGE img_plane_bullet, img_ufoa_bullet, img_ufob_bullet;

int Input = NOTINPUT;
int Score = 0;


void PlayMusic(int type){

	//根据需要的类型播放或关闭音乐
	switch (type)
	{
	case BGM:
		mciSendString(TEXT("
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
C语言结合EasyX图形库可以实现飞机大战的双人模式。下面是一个简单的示例代码: ```c #include <graphics.h> #include <conio.h> #define WIDTH 480 #define HEIGHT 600 // 玩家1飞机的结构体 struct Player1Plane { int x; // x坐标 int y; // y坐标 }; // 玩家2飞机的结构体 struct Player2Plane { int x; // x坐标 int y; // y坐标 }; // 初始化玩家1飞机 void initPlayer1Plane(Player1Plane* plane) { plane->x = WIDTH / 2 - 30; plane->y = HEIGHT - 100; } // 初始化玩家2飞机 void initPlayer2Plane(Player2Plane* plane) { plane->x = WIDTH / 2 + 30; plane->y = HEIGHT - 100; } // 绘制飞机 void drawPlane(int x, int y) { setfillcolor(YELLOW); fillrectangle(x - 20, y, x + 20, y + 40); } int main() { initgraph(WIDTH, HEIGHT); // 初始化图形窗口 Player1Plane player1; Player2Plane player2; initPlayer1Plane(&player1); initPlayer2Plane(&player2); while (true) { cleardevice(); // 清空屏幕 if (_kbhit()) { char ch = _getch(); if (ch == 'a') { player1.x -= 10; // 玩家1向左移动 } else if (ch == 'd') { player1.x += 10; // 玩家1向右移动 } else if (ch == 'j') { player2.x -= 10; // 玩家2向左移动 } else if (ch == 'l') { player2.x += 10; // 玩家2向右移动 } } drawPlane(player1.x, player1.y); // 绘制玩家1飞机 drawPlane(player2.x, player2.y); // 绘制玩家2飞机 Sleep(30); // 控制刷新速度 } closegraph(); // 关闭图形窗口 return 0; } ``` 在此示例中,我们使用EasyX图形库来创建一个窗口,然后通过键盘输入控制玩家1和玩家2的飞机移动。玩家1使用键盘的 'a' 和 'd' 键来左右移动飞机,玩家2使用键盘的 'j' 和 'l' 键来左右移动飞机。飞机的绘制使用了`drawPlane`函数,你可以根据自己的需求进行自定义。 希望这个示例对你有所帮助!如果还有其他问题,请随时提问。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

天若有情673

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值