广告位联系
返回顶部
分享到

基于Matlab实现俄罗斯方块游戏

C语言 来源:互联网 作者:秩名 发布时间:2022-03-03 21:42:11 人浏览
摘要

我最早写的一个matlab小游戏 写的可能不够简洁,但还有可玩性, 先发上来,以后可能改进或出教程。 大家自己探索吧(外挂是哪个按键,更改颜色是哪个按键) 游戏效果 完整代码

我最早写的一个matlab小游戏

写的可能不够简洁,但还有可玩性,

先发上来,以后可能改进或出教程。

大家自己探索吧(外挂是哪个按键,更改颜色是哪个按键)

游戏效果

完整代码

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216

217

218

219

220

221

222

223

224

225

226

227

228

229

230

231

232

233

234

235

236

237

238

239

240

241

242

243

244

245

246

247

248

249

250

251

252

253

254

255

256

257

258

259

260

261

262

263

264

265

266

267

268

269

270

271

272

273

274

275

276

277

278

279

280

281

282

283

284

285

286

287

288

289

290

291

292

293

294

295

296

297

298

299

300

301

302

303

304

305

306

307

308

309

310

311

312

313

314

315

316

317

318

319

320

321

322

323

324

325

326

327

328

329

330

331

332

333

334

335

336

337

338

339

340

341

342

343

344

345

346

347

348

349

350

351

352

353

354

355

356

357

358

359

360

361

362

363

364

365

366

367

368

369

370

371

372

373

374

375

376

377

378

379

380

381

382

383

384

385

386

387

388

389

390

391

392

393

394

395

396

397

398

399

400

401

402

403

404

405

406

407

408

409

410

411

412

413

414

415

416

417

418

419

420

421

422

423

424

425

426

427

428

429

430

431

432

433

434

435

436

437

438

439

440

441

442

443

444

445

446

447

448

449

450

451

452

453

454

455

456

457

458

459

460

461

462

463

464

465

466

467

468

469

470

471

472

473

474

475

476

477

478

479

480

481

482

483

484

485

486

487

488

489

490

491

492

493

494

495

496

497

498

499

500

501

502

503

504

505

506

507

508

509

510

511

512

513

514

515

516

517

518

519

520

521

522

523

524

525

526

527

528

529

530

531

532

533

534

535

536

537

538

539

540

541

542

543

544

545

546

547

548

549

550

551

552

553

554

555

556

557

558

559

560

561

562

563

function elos

hold on

axis equal

axis(0.5+[0,10,0,20])

set(gca,'xtick',[],'ytick',[],'xcolor','w','ycolor','w')

set(gca,'color','k')

%%%%%%%%%%% %%%%%%%%%% %%%%%%%%%% %%%%%%%%%% %%%%%%%%%% %%%%%%%%% %%%%%%%%%

A1=[5,23;5,24;6,23;6,24];%1

B1=[5,23;5,24;5,22;5,21];%21

B2=[5,23;4,23;6,23;7,23];%23

C1=[5,23;5,24;5,22;4,24];%31

C2=[5,23;6,23;4,23;6,24];%33

C3=[5,23;5,24;5,22;6,22];%35

C4=[5,23;4,23;6,23;4,22];%37

D1=[5,23;5,24;5,22;6,24];%41

D2=[5,23;4,23;6,23;6,22];%43

D3=[5,23;5,24;5,22;4,22];%45

D4=[5,23;4,23;6,23;4,24];%47

E1=[5,23;5,24;4,24;6,23];%51

E2=[5,23;6,24;6,23;5,22];%53

E3=[5,23;4,23;5,22;6,22];%55

E4=[5,23;5,24;4,23;4,22];%57

F1=[5,23;5,24;6,24;4,23];%61

F2=[5,23;6,23;6,22;5,24];%63

F3=[5,23;6,23;5,22;4,22];%65

F4=[5,23;4,24;4,23;5,22];%67

G1=[5,23;5,24;4,23;6,23];%71

G2=[5,23;6,23;5,24;5,22];%73

G3=[5,23;4,23;6,23;5,22];%75

G4=[5,23;4,23;5,24;5,22];%77

%%%%%%%%%%% %%%%%%%%%% %%%%%%%%%% %%%%%%%%%% %%%%%%%%%% %%%%%%%%% %%%%%%%%%

r=[1 0 0;1 0 0;1 0 0;1 0 0];

b=[0 0 1;0 0 1;0 0 1;0 0 1];

g=[0 1 0;0 1 0;0 1 0;0 1 0];

c=[0 1 1;0 1 1;0 1 1;0 1 1];

w=[1 1 1;1 1 1;1 1 1;1 1 1];

h=[-50,-50,0,0,1;-49,-49,0,0,1;-48,-48,0,0,1;-47,-47,0,0,1];

wall1=[1 0;2 0;3 0;4 0;5 0;6 0;7 0;8 0;9 0;10 0];

wall2=[0,0;0,1;0,2;0,3;0,4;0,5;0,6;0,7;0,8;0,9;0,10;0,11;0,12;0,13;0,14;0,15;

    0,16;0,17;0,18;0,19;0,20];

wall3=[11,0;11,1;11,2;11,3;11,4;11,5;11,6;11,7;11,8;11,9;11,10;11,11;11,12;

    11,13;11,14;11,15;11,16;11,17;11,18;11,19;11,20];

direct=[0,-1,0,0,0;0,-1,0,0,0;0,-1,0,0,0;0,-1,0,0,0];

dir=[0,-1;0,-1;0,-1;0,-1];

left=[-1,0,0,0,0;-1,0,0,0,0;-1,0,0,0,0;-1,0,0,0,0];

right=[1,0,0,0,0;1,0,0,0,0;1,0,0,0,0;1,0,0,0,0];

lefty=[-1,0;-1,0;-1,0;-1,0];

leftyy=[-1,-1;-1,-1;-1,-1;-1,-1];

righty=[1,0;1,0;1,0;1,0];

rightyy=[1,-1;1 ,-1;1,-1;1,-1];

s=[A1,c];

s1=A1;

change=1;

waigua=1;

color=1;

score=0;

%%%%%%%%%%% %%%%%%%%%% %%%%%%%%%% %%%%%%%%%% %%%%%%%%%% %%%%%%%%% %%%%%%%%%

kill1=[1,17;2,17;3,17;4,17;5,17;6,17;7,17;8,17;9,17;10,17];

kill2=[1,16;2,16;3,16;4,16;5,16;6,16;7,16;8,16;9,16;10,16];

kill3=[1,15;2,15;3,15;4,15;5,15;6,15;7,15;8,15;9,15;10,15];

kill4=[1,14;2,14;3,14;4,14;5,14;6,14;7,14;8,14;9,14;10,14];

kill5=[1,13;2,13;3,13;4,13;5,13;6,13;7,13;8,13;9,13;10,13];

kill6=[1,12;2,12;3,12;4,12;5,12;6,12;7,12;8,12;9,12;10,12];

kill7=[1,11;2,11;3,11;4,11;5,11;6,11;7,11;8,11;9,11;10,11];

kill8=[1,10;2,10;3,10;4,10;5,10;6,10;7,10;8,10;9,10;10,10];

kill9=[1,9;2,9;3,9;4,9;5,9;6,9;7,9;8,9;9,9;10,9];

kill10=[1,8;2,8;3,8;4,8;5,8;6,8;7,8;8,8;9,8;10,8];

kill11=[1,7;2,7;3,7;4,7;5,7;6,7;7,7;8,7;9,7;10,7];

kill12=[1,6;2,6;3,6;4,6;5,6;6,6;7,6;8,6;9,6;10,6];

kill13=[1,5;2,5;3,5;4,5;5,5;6,5;7,5;8,5;9,5;10,5];

kill14=[1,4;2,4;3,4;4,4;5,4;6,4;7,4;8,4;9,4;10,4];

kill15=[1,3;2,3;3,3;4,3;5,3;6,3;7,3;8,3;9,3;10,3];

kill16=[1,2;2,2;3,2;4,2;5,2;6,2;7,2;8,2;9,2;10,2];

kill17=[1,1;2,1;3,1;4,1;5,1;6,1;7,1;8,1;9,1;10,1];

%%%%%%%%%%% %%%%%%%%%% %%%%%%%%%% %%%%%%%%%% %%%%%%%%%% %%%%%%%%% %%%%%%%%%

plotelos=scatter(gca,s(:,1),s(:,2),220,s(:,3:5),'s','filled');

plott=scatter(gca,h(:,1),h(:,2),220,h(:,3:5),'s','filled');

set(gcf, 'KeyPressFcn', @key)

fps = 5;                                   

game = timer('ExecutionMode', 'FixedRate', 'Period',1/fps, 'TimerFcn', @elosgame);

start(game)

%%%%%%%%%%% %%%%%%%%%% %%%%%%%%%% %%%%%%%%%% %%%%%%%%%% %%%%%%%%% %%%%%%%%%

    function elosgame(~,~)

        talant=find(h>18);

        if length(talant)==0

        else

            stop(game);

            ButtonName1 = questdlg('Game over','what do you mean to do?','restart','end', 'end');

            if ButtonName1 == 'restart';

                clf;

                elos();

            else

                close;

            end

        end

        if length(wall1)==length(unique([wall1;kill1],'rows'));

            wall1(find(wall1(:,2)==17),:)=[];

            h(find(h(:,2)==17),:)=[];

            wall1(wall1(:,2)>17)=wall1(wall1(:,2)>17)-1;

            h(h(:,2)>17)=h(h(:,2)>17)-1;

            score=score+10;

        end

        if length(wall1)==length(unique([wall1;kill2],'rows'));

            wall1(find(wall1(:,2)==16),:)=[];

            h(find(h(:,2)==16),:)=[];

            wall1(wall1(:,2)>16)=wall1(wall1(:,2)>16)-1;

            h(h(:,2)>16)=h(h(:,2)>16)-1;

            score=score+10;

        end

        if length(wall1)==length(unique([wall1;kill3],'rows'));

            wall1(find(wall1(:,2)==15),:)=[];

            h(find(h(:,2)==15),:)=[];

            wall1(wall1(:,2)>15)=wall1(wall1(:,2)>15)-1;

            h(h(:,2)>15)=h(h(:,2)>15)-1;

            score=score+10;

        end

        if length(wall1)==length(unique([wall1;kill4],'rows'));

            wall1(find(wall1(:,2)==14),:)=[];

            h(find(h(:,2)==14),:)=[];

            wall1(wall1(:,2)>14)=wall1(wall1(:,2)>14)-1;

            h(h(:,2)>14)=h(h(:,2)>14)-1;

            score=score+10;

        end

        if length(wall1)==length(unique([wall1;kill5],'rows'));

            wall1(find(wall1(:,2)==13),:)=[];

            h(find(h(:,2)==13),:)=[];

            wall1(wall1(:,2)>13)=wall1(wall1(:,2)>13)-1;

            h(h(:,2)>13)=h(h(:,2)>13)-1;

            score=score+10;

        end

        if length(wall1)==length(unique([wall1;kill6],'rows'));

            wall1(find(wall1(:,2)==12),:)=[];

            h(find(h(:,2)==12),:)=[];

            wall1(wall1(:,2)>12)=wall1(wall1(:,2)>12)-1;

            h(h(:,2)>12)=h(h(:,2)>12)-1;

            score=score+10;

        end

        if length(wall1)==length(unique([wall1;kill7],'rows'));

            wall1(find(wall1(:,2)==11),:)=[];

            h(find(h(:,2)==11),:)=[];

            wall1(wall1(:,2)>11)=wall1(wall1(:,2)>11)-1;

            h(h(:,2)>11)=h(h(:,2)>11)-1;

            score=score+10;

        end

        if length(wall1)==length(unique([wall1;kill8],'rows'));

            wall1(find(wall1(:,2)==10),:)=[];

            h(find(h(:,2)==0),:)=[];

            wall1(wall1(:,2)>10)=wall1(wall1(:,2)>10)-1;

            h(h(:,2)>10)=h(h(:,2)>10)-1;

            score=score+10;

        end

        if length(wall1)==length(unique([wall1;kill9],'rows'));

            wall1(find(wall1(:,2)==9),:)=[];

            h(find(h(:,2)==9),:)=[];

            wall1(wall1(:,2)>9,2)=wall1(wall1(:,2)>9,2)-1;

            h(h(:,2)>9,2)=h(h(:,2)>9,2)-1;

            score=score+10;

        end

        if length(wall1)==length(unique([wall1;kill10],'rows'));

            wall1(find(wall1(:,2)==8),:)=[];

            h(find(h(:,2)==8),:)=[];           

            wall1(wall1(:,2)>8,2)=wall1(wall1(:,2)>8,2)-1;

            h(h(:,2)>8,2)=h(h(:,2)>8,2)-1;

            score=score+10;

        end

        if length(wall1)==length(unique([wall1;kill11],'rows'));

            wall1(find(wall1(:,2)==7),:)=[];

            h(find(h(:,2)==7),:)=[];

            wall1(wall1(:,2)>7,2)=wall1(wall1(:,2)>7,2)-1;

            h(h(:,2)>7,2)=h(h(:,2)>7,2)-1;

            score=score+10;

        end

        if length(wall1)==length(unique([wall1;kill12],'rows'));

            wall1(find(wall1(:,2)==6),:)=[];

            h(find(h(:,2)==6),:)=[];

            wall1(wall1(:,2)>6,2)=wall1(wall1(:,2)>6,2)-1;

            h(h(:,2)>6,2)=h(h(:,2)>6,2)-1;

            score=score+10;

        end

        if length(wall1)==length(unique([wall1;kill13],'rows'));

            wall1(find(wall1(:,2)==5),:)=[];

            h(find(h(:,2)==5),:)==[];

            wall1(wall1(:,2)>5,2)=wall1(wall1(:,2)>59,2)-1;

            h(h(:,2)>5,2)=h(h(:,2)>5,2)-1;

            score=score+10;

        end

        if length(wall1)==length(unique([wall1;kill14],'rows'));

            wall1(find(wall1(:,2)==4),:)=[];

            h(find(h(:,2)==4),:)=[];

            wall1(wall1(:,2)>4,2)=wall1(wall1(:,2)>4,2)-1;

            h(h(:,2)>4,2)=h(h(:,2)>4,2)-1;

            score=score+10;

        end

        if length(wall1)==length(unique([wall1;kill15],'rows'));

            wall1(find(wall1(:,2)==3),:)=[];

            h(find(h(:,2)==3),:)=[];

            wall1(wall1(:,2)>3,2)=wall1(wall1(:,2)>3,2)-1;

            h(h(:,2)>3,2)=h(h(:,2)>3,2)-1;

            score=score+10;

        end

        if length(wall1)==length(unique([wall1;kill16],'rows'));

            wall1(find(wall1(:,2)==2),:)=[];

            h(find(h(:,2)==2),:)=[];

            wall1(wall1(:,2)>2,2)=wall1(wall1(:,2)>2,2)-1;

            h(h(:,2)>2,2)=h(h(:,2)>2,2)-1;

            score=score+10;

        end

        if length(wall1)==length(unique([wall1;kill17],'rows'));

            wall1(find(wall1(:,2)==1),:)=[];

            h(find(h(:,2)==1),:)=[];

            wall1(wall1(:,2)>1,2)=wall1(wall1(:,2)>1,2)-1;

            h(h(:,2)>1,2)=h(h(:,2)>1,2)-1;

            score=score+10;

        end

        s1=s1+dir;

        s=s+direct;

        control=length(intersect(dir+s1,wall1,'rows'));

        if control==0;

        else

            h=[h;s];

            wall1=[wall1;s1];

            power=randi(7);

            power2=randi(4);

            if power==1;

                sn=A1;

                change=1;

            end

            if power==2;

                sn=B1;

                change=21;

            end

            if power==3;

                sn=C1;

                change=31;

            end

            if power==4;

                sn=D1;

                change=41;

            end

            if power==5;

                sn=E1;

                change=51;

            end

            if power==6;

                sn=F1;

                change=61;

            end

            if power==7;

                sn=G1;

                change=71;

            end

            if power2==1;

                co=r;

            end

            if power2==2;

                co=b;

            end

            if power2==3;

                co=g;

            end

            if power2==4;

                co=c;

            end

            if waigua==1;

                s=[sn,co];

                s1=sn;

                tip=1;

            end

            if waigua==2;

                s=[B1,co];

                s1=B1;

                tip=1;

                change=21;

            end

        end

        if color==1;

            set(plott,'XData',h(:,1),'YData',h(:,2),'CData',h(:,3:5))

            set(plotelos,'XData',s(:,1),'YData',s(:,2),'CData',s(:,3:5))

        end

        if color==2;

            set(plott,'XData',h(:,1),'YData',h(:,2),'CData',[1 1 1])

            set(plotelos,'XData',s(:,1),'YData',s(:,2),'CData',[1 1 1])

        end

    end

    function key(~,event);

        switch event.Key;

            case 'uparrow';

                po=[s1(1,:);s1(1,:);s1(1,:);s1(1,:)];

                pp=[5,23;5,23;5,23;5,23];

                pa=[s(1,3:5);s(1,3:5);s(1,3:5);s(1,3:5)];

                pos=po-pp;

                if change==21;

                    if length(intersect(B2+pos,wall1,'rows'))==0;

                        if length(intersect(B2+pos,wall2,'rows'))==0;

                            if length(intersect(B2+pos,wall3,'rows'))==0;

                                s=[B2+pos,pa];

                                s1=B2+pos;

                                change=22;

                            end

                        end

                    end

                end

                if change==23;

                    if length(intersect(B1+pos,wall1,'rows'))==0;

                        if length(intersect(B1+pos,wall2,'rows'))==0;

                            if length(intersect(B1+pos,wall3,'rows'))==0;

                                s=[B1+pos,pa];

                                s1=B1+pos;

                                change=20;

                            end

                        end

                    end

                end

                if change==31;

                    if length(intersect(C2+pos,wall1,'rows'))==0;

                        if length(intersect(C2+pos,wall2,'rows'))==0;

                            if length(intersect(C2+pos,wall3,'rows'))==0;

                                s=[C2+pos,pa];

                                s1=C2+pos;

                                change=32;

                            end

                        end

                    end

                end

                if change==33;

                    if length(intersect(C3+pos,wall1,'rows'))==0;

                        if length(intersect(C3+pos,wall2,'rows'))==0;

                            if length(intersect(C3+pos,wall3,'rows'))==0;

                                s=[C3+pos,pa];

                                s1=C3+pos;

                                change=34;

                            end

                        end

                    end

                end

                if change==35;

                    if isempty(intersect(C4+pos,wall1,'rows'));

                        if length(intersect(C4+pos,wall2,'rows'))==0;

                            if length(intersect(C4+pos,wall3,'rows'))==0;

                                s=[C4+pos,pa];

                                s1=C4+pos;

                                change=36;

                            end

                        end

                    end

                end

                if change==37;

                    if length(intersect(C1+pos,wall1,'rows'))==0;

                        if length(intersect(C1+pos,wall2,'rows'))==0;

                            if length(intersect(C1+pos,wall3,'rows'))==0;

                                s=[C1+pos,pa];

                                s1=C1+pos;

                                change=30;

                            end

                        end

                    end

                end

                if change==41;

                    if length(intersect(D2+pos,wall1,'rows'))==0;

                        if length(intersect(D2+pos,wall2,'rows'))==0; 

                            if length(intersect(D2+pos,wall3,'rows'))==0; 

                                s=[D2+pos,pa];

                                s1=D2+pos;

                                change=42;

                            end

                        end

                    end

                end

                if change==43;

                    if length(intersect(D3+pos,wall1,'rows'))==0;

                        if length(intersect(D3+pos,wall2,'rows'))==0;

                            if length(intersect(D3+pos,wall3,'rows'))==0;

                                s=[D3+pos,pa];

                                s1=D3+pos;

                                change=44;

                            end

                        end

                    end

                end

                if change==45;

                    if length(intersect(D4+pos,wall1,'rows'))==0;

                        if length(intersect(D4+pos,wall2,'rows'))==0;

                            if length(intersect(D4+pos,wall3,'rows'))==0;

                                s=[D4+pos,pa];

                                s1=D4+pos;

                                change=46;

                            end

                        end

                    end

                end

                if change==47;

                    if length(intersect(D1+pos,wall1,'rows'))==0;

                        if length(intersect(D1+pos,wall2,'rows'))==0;

                            if length(intersect(D1+pos,wall3,'rows'))==0;

                                s=[D1+pos,pa];

                                s1=D1+pos;

                                change=40;

                            end

                        end

                    end

                end

                if change==51;

                    if length(intersect(E2+pos,wall1,'rows'))==0;

                        if length(intersect(E2+pos,wall2,'rows'))==0;

                            if length(intersect(E2+pos,wall3,'rows'))==0;

                                s=[E2+pos,pa];

                                s1=E2+pos;

                                change=52;

                            end

                        end

                    end

                end

                if change==53;

                    if length(intersect(E3+pos,wall1,'rows'))==0;

                        if length(intersect(E3+pos,wall2,'rows'))==0;

                            if length(intersect(E3+pos,wall3,'rows'))==0;

                                s=[E3+pos,pa];

                                s1=E3+pos;

                                change=54;

                            end

                        end

                    end

                end

                if change==55;

                    if length(intersect(E4+pos,wall1,'rows'))==0;

                        if length(intersect(E4+pos,wall2,'rows'))==0;

                            if length(intersect(E4+pos,wall3,'rows'))==0;

                                s=[E4+pos,pa];

                                s1=E4+pos;

                                change=56;

                            end

                        end

                    end

                end

                if change==57;

                    if length(intersect(E1+pos,wall1,'rows'))==0;

                        if length(intersect(E1+pos,wall2,'rows'))==0;

                            if length(intersect(E1+pos,wall3,'rows'))==0; 

                                s=[E1+pos,pa];

                                s1=E1+pos;

                                change=50;

                            end

                        end

                    end

                end

                if change==61;

                    if length(intersect(F2+pos,wall1,'rows'))==0;

                        if length(intersect(F2+pos,wall2,'rows'))==0;

                            if length(intersect(F2+pos,wall3,'rows'))==0;

                                s=[F2+pos,pa];

                                s1=F2+pos;

                                change=62;

                            end

                        end

                    end

                end

                if change==63;

                    if length(intersect(F3+pos,wall1,'rows'))==0;

                        if length(intersect(F3+pos,wall2,'rows'))==0;

                            if length(intersect(F3+pos,wall3,'rows'))==0;

                                s=[F3+pos,pa];

                                s1=F3+pos;

                                change=64;

                            end

                        end

                    end

                end

                if change==65;

                    if length(intersect(F4+pos,wall1,'rows'))==0;

                        if length(intersect(F4+pos,wall2,'rows'))==0;

                            if length(intersect(F4+pos,wall3,'rows'))==0;

                                s=[F4+pos,pa];

                                s1=F4+pos;

                                change=66;

                            end

                        end

                    end

                end

                if change==67;

                    if length(intersect(F1+pos,wall1,'rows'))==0;

                        if length(intersect(F1+pos,wall2,'rows'))==0;

                            if length(intersect(F1+pos,wall3,'rows'))==0;

                                s=[F1+pos,pa];

                                s1=F1+pos;

                                change=60;

                            end

                        end

                    end

                end

                if change==71;

                    if length(intersect(G2+pos,wall1,'rows'))==0;

                        if length(intersect(G2+pos,wall2,'rows'))==0;

                            if length(intersect(G2+pos,wall3,'rows'))==0;

                                s=[G2+pos,pa];

                                s1=G2+pos;

                                change=72;

                            end

                        end

                    end

                end

                if change==73;

                    if length(intersect(G3+pos,wall1,'rows'))==0;

                        if length(intersect(G3+pos,wall2,'rows'))==0;

                            if length(intersect(G3+pos,wall3,'rows'))==0;

                                s=[G3+pos,pa];

                                s1=G3+pos;

                                change=74;

                            end

                        end

                    end

                end

                if change==75;

                    if length(intersect(G4+pos,wall1,'rows'))==0;

                        if length(intersect(G4+pos,wall2,'rows'))==0;

                            if length(intersect(G4+pos,wall3,'rows'))==0;

                                s=[G4+pos,pa];

                                s1=G4+pos;

                                change=76;

                            end

                        end

                    end

                end

                if change==77;

                    if length(intersect(G1+pos,wall1,'rows'))==0;

                        if length(intersect(G1+pos,wall2,'rows'))==0;

                            if length(intersect(G1+pos,wall3,'rows'))==0;

                                s=[G1+pos,pa];

                                s1=G1+pos;

                                change=70;

                            end

                        end

                    end

                end

                change=change+1;

            case 'w'

                color=2;

            case 'c'

                color=1

            case '1';

                waigua=1;

            case '2';

                waigua=2;

            case 'leftarrow';

                if length(intersect(s1+lefty,wall1,'rows'))==0

                    if length(intersect(s1+leftyy,wall1,'rows'))==0

                        if length(intersect(s1+lefty,wall2,'rows'))==0;

                            s=s+left;

                            s1=s1+lefty;

                        end

                    end

                end

            case 'rightarrow';

                if length(intersect(s1+righty,wall1,'rows'))==0

                    if length(intersect(s1+rightyy,wall1,'rows'))==0

                        if length(intersect(s1+righty,wall3,'rows'))==0;

                            s=s+right;

                            s1=s1+righty;

                        end

                    end

                end

        end

    end

end


版权声明 : 本文内容来源于互联网或用户自行发布贡献,该文观点仅代表原作者本人。本站仅提供信息存储空间服务和不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权, 违法违规的内容, 请发送邮件至2530232025#qq.cn(#换@)举报,一经查实,本站将立刻删除。
原文链接 : https://blog.csdn.net/slandarer/article/details/104084227
相关文章
  • C++中类的六大默认成员函数的介绍

    C++中类的六大默认成员函数的介绍
    一、类的默认成员函数 二、构造函数Date(形参列表) 构造函数主要完成初始化对象,相当于C语言阶段写的Init函数。 默认构造函数:无参的构
  • C/C++实现遍历文件夹最全方法总结介绍

    C/C++实现遍历文件夹最全方法总结介绍
    一、filesystem(推荐) 在c++17中,引入了文件系统,使用起来非常方便 在VS中,可以直接在项目属性中调整: 只要是C++17即以上都可 然后头文件
  • C语言实现手写Map(数组+链表+红黑树)的代码

    C语言实现手写Map(数组+链表+红黑树)的代码
    要求 需要准备数组集合(List) 数据结构 需要准备单向链表(Linked) 数据结构 需要准备红黑树(Rbtree)数据结构 需要准备红黑树和链表适配策略
  • MySQL系列教程之使用C语言来连接数据库

    MySQL系列教程之使用C语言来连接数据库
    写在前面 知道了 Java中使用 JDBC编程 来连接数据库了,但是使用 C语言 来连接数据库却总是连接不上去~ 立即安排一波使用 C语言连接 MySQL数
  • 基于C语言实现简单学生成绩管理系统

    基于C语言实现简单学生成绩管理系统
    一、系统主要功能 1、密码登录 2、输入数据 3、查询成绩 4、修改成绩 5、输出所有学生成绩 6、退出系统 二、代码实现 1 2 3 4 5 6 7 8 9 10 11
  • C语言实现共享单车管理系统

    C语言实现共享单车管理系统
    1.功能模块图; 2.各个模块详细的功能描述。 1.登陆:登陆分为用户登陆,管理员登陆以及维修员登录,登陆后不同的用户所执行的操作
  • C++继承与菱形继承的介绍

    C++继承与菱形继承的介绍
    继承的概念和定义 继承机制是面向对象程序设计的一种实现代码复用的重要手段,它允许程序员在保持原有类特性的基础上进行拓展,增加
  • C/C++指针介绍与使用介绍

    C/C++指针介绍与使用介绍
    什么是指针 C/C++语言拥有在程序运行时获得变量的地址和操作地址的能力,这种用来操作地址的特殊类型变量被称作指针。 翻译翻译什么
  • C++进程的创建和进程ID标识介绍
    进程的ID 进程的ID,可称为PID。它是进程的唯一标识,类似于我们的身份证号是唯一标识,因为名字可能会和其他人相同,生日可能会与其他
  • C++分析如何用虚析构与纯虚析构处理内存泄漏

    C++分析如何用虚析构与纯虚析构处理内存泄漏
    一、问题引入 使用多态时,如果有一些子类的成员开辟在堆区,那么在父类执行完毕释放后,没有办法去释放子类的内存,这样会导致内存
  • 本站所有内容来源于互联网或用户自行发布,本站仅提供信息存储空间服务,不拥有版权,不承担法律责任。如有侵犯您的权益,请您联系站长处理!
  • Copyright © 2017-2022 F11.CN All Rights Reserved. F11站长开发者网 版权所有 | 苏ICP备2022031554号-1 | 51LA统计