第二关预览图:
判断是否为第二关
if (sort == 2) {}
砖块位置图:
砖块坐标:
A(240,390) B(270,360)
C(300,330) D(270,360)
E(300,360) F(330,390)
G(360,360) H(390,390)
I(420,390) f1(240,300)
空1(420,270) 空2(480,270)
空3(540,270) 空4 (600,270)
绘制地面
//绘制第一关的地面,上地面type=1,下地面type=2for (int i = 0;i < 27;i++) {obstacleList.add(new Obstacle(i*30,420,1,this));}for (int j = 0;j <= 120;j += 30) {for (int i = 0;i < 27;i++) {obstacleList.add(new Obstacle(i*30,570-j,2,this));}}
绘制第一个水管
//绘制第一个水管for (int i = 360;i <= 600;i += 25) {if (i == 360) {obstacleList.add(new Obstacle(60,i,3,this));obstacleList.add(new Obstacle(85,i,4,this));}else {obstacleList.add(new Obstacle(60,i,5,this));obstacleList.add(new Obstacle(85,i,6,this));}}
绘制第二个水管
//绘制第二个水管for (int i = 330;i <= 600;i += 25) {if (i == 330) {obstacleList.add(new Obstacle(620,i,3,this));obstacleList.add(new Obstacle(645,i,4,this));}else {obstacleList.add(new Obstacle(620,i,5,this));obstacleList.add(new Obstacle(645,i,6,this));}}
绘制砖块C
//绘制砖块CobstacleList.add(new Obstacle(300,330,0,this));
绘制砖块B,E,G
//绘制砖块B,E,Gfor (int i = 270;i <= 330;i += 30) {if (i == 270 || i == 330) {obstacleList.add(new Obstacle(i,360,0,this));}else {obstacleList.add(new Obstacle(i,360,7,this));}}
绘制砖块A,D,F,H,I
//绘制砖块A,D,F,H,Ifor (int i = 240;i <= 360;i += 30) {if (i == 240 || i == 360) {obstacleList.add(new Obstacle(i,390,0,this));}else {obstacleList.add(new Obstacle(i,390,7,this));}}
绘制砖块f1
//绘制妨碍1砖块obstacleList.add(new Obstacle(240,300,0,this));
绘制砖块空1,空2,空3,空4
//绘制空1-4砖块for (int i = 360;i <= 540;i += 60) {obstacleList.add(new Obstacle(i,270,7,this));}
注:本文仅作为学习笔记,参考的视频链接
10_超级玛丽--第二关的设计_尚学堂_哔哩哔哩_bilibili
如果觉得《java小游戏超级玛丽:06.第二关的设计》对你有帮助,请点赞、收藏,并留下你的观点哦!