Java突破每砖多次点击 [英] Java breakout multiple hits per brick

查看:75
本文介绍了Java突破每砖多次点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好



我想把一个程序作为我的作业的一部分,一个突破性的游戏。

有很多教程对于这个游戏。

但是,我们给出的挑战是,一行需要在销毁之前获得3次点击的砖块,另一行需要每次砖块击中2次,最后一行为1次按砖计算。

我试图找出不同的方法来做到这一点,但最后我想弄清楚如何通过坐标识别每块砖,以便能够进一步操纵它是最好的方式。虽然我不确定这是解决这个问题的最佳方法。

不幸的是,关于这个游戏的每块砖的多次点击没有太多信息。

如果有人可以指导我或帮我弄清楚如何解决这个问题我将非常感激。



问候

维塔利



我尝试过:



研究时间,许多YouTube视频,oracle文档等等

Hello

I am trying to make a program as part of my assignment, a breakout game.
There are plenty of tutorials for this game.
However, the challenge we've been given is that one row need to have the bricks that take 3 hits before they are destroyed, the other row 2 hits per brick and last row 1 hit per brick.
I was trying to figure out different ways to do it, though in the end I thought to figure out how to identify each brick by its coordinates in order to be able to manipulate it further is the best way. Though I am not sure it is the best approach for this problem.
Unfortunately, there is not much information about multiple hits per brick for this game out there.
If someone can guide me or help me to figure out how to solve this problem I will be very grateful.

Regards
Vitali

What I have tried:

Hours of research, many youtube videos, oracle documentation etc.

推荐答案

创建一个Brick类,如果尚未创建,则在屏幕上为每个砖创建一个实例。包含可以采用的点击数量的属性。为第一行创建实例时,将此值设置为3,对于第二行,将其设置为2,最后一次将其设置为1。每当砖块被击中时,该值会减小,当砖块达到零时,砖块会断裂。
Create a Brick class, if you have not done so already, then create an instance for each brick on the screen. Include a property for the number of hits it can take. When you create the instances for the first row set this value to three, for the second set it to two and the last set it to one. Every time the brick is hit decrement the value and when it hits zero the brick breaks.


这篇关于Java突破每砖多次点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆