看博客学学Android(九)

原文地址:http://bigosaur.com/blog/8-aliens-fly-and-die

Day 7: Change of layout and screen orientation

You can shoot aliens now. Since the graphics is retro style, I decided to explode the alien's large pixels (I draw aliens using large zoom tool in Gimp, and then I enlarge the image 5x

without any interpolation). I wrote a custom particle manager code and use built in tweening in libGDX to send each piece in a random direction away from center.

Particle effects libGDX and Android

You may notice that there is no you on the screen. This is on purpose. In case you did not realize yet, this is a first person shooter. ROFL. Well, at least technically, it is. You don't get

to see yourself, you only shoot at enemies. In some test version I also tried to scale the aliens to give a feeling of depth and them coming from far away, but it's hard to shoot small

sprites on Android using your finger, so I gave up on the idea.

To make the game more interesting, the laser gun you're using would need reloading. You got 10 shots and then you need to hit the Reload button at lower left corner of the screen.

I'm still not sure about this feature - needs testing.

As I was testing this, one thing bothered me a lot: While I shoot the aliens, my index finger is all over the screen and it's hard to see what's going on. Then I looked at different Android games on my phone and realized that it would be much better if screen was oriented in portrait mode. When in portrait mode, your index finger does not come from below, but from right side (if you're right-handed, of course). Most of the screen is still visible in this case. I'm also changing the flying direction. Instead of going from left to right, aliens are coming from the top of the screen.

Because of this, I'm also changing the main game concept. Instead of playing a fixed amount of time, you would play until you allow one of the aliens to get past you. My initial idea was that you would play for one minute and score as many points possible during that time (something like fruit ninja arcade mode). But now I'm thinking you could have 3 lives or something like that, and if you let some aliens pass, it's game over.

I also changed the nebulas in the background. I wrote before about that tutorial how to draw a night sky with stars and nebulas in Gimp, but I had to experiment a bit to get the look I wanted. It works by using Subtract layer effect on two layers with rendered Solid Noise, and then colored using Overlay with a single color and a gradient. The problem is that Subtracting those two layers always created a "small" nebula, while I wanted the whole screen to be full with color. I draw the stars by placing a bunch of random dots using pencil and a couple of different colors. I separated the stars in 3 layers. On one of the layers I added a 2px drop shadow (with no offset), on second one I used blur and I left the third one as it is. The trick to nice stars is that those drawn close to each other should always be different color or have different sharpness. This is the way it is on the real sky. The stars that look close together are lightyears away and only appear close from Earth.

第七天:改变布局和屏幕方向

现在你可以开始射击外星人了。由于图形还是古典的风格,所以我决定放大外星人的大像素点(我使用Gimp中一个缩放比例大的工具来绘制外星人,同时在没有任何插值的情况下,我直接将图片放大了五倍)。

我写了一个自定义的微粒管理代码,同时使用libGDX中一个渐变的生成方式将每一部分从中央随机的发射向任何方向。

也许你注意到了,在屏幕中“没有你”。这是有意这样设计的。如果你现在还没意识到,这一个第一视角的设计游戏。哈哈~ROFL(Rolling On the Floor Laughing,主要表示笑的满地打滚了,滚在地上笑, 我哈哈大笑, 太可笑了等意思,因特网聊天俚语,特别是在美国和加拿大青少年之间)。好吧,至少在技术上它是这样的。你不能看到你自己,你只能射击外星人。在一个测试的版本中,我也会尝试着去缩放外星人来

找到一个深层次的感觉,同时他们从更远的地方而来,但是,在安卓上使用你的手指是很难射中太小的东西的,所以我又有了一个主意。

为了是游戏更加的有趣,你正在使用的激光枪将会被重新进行加载。你初始有10发子弹,随后你需要点击屏幕左下角的重新加载按钮。

我现在还不确定这个方案,需要多次测试。

正如我测试的那样,一件事情困扰了我许久:当我射击外星人的时候,我的食指挡住了整个屏幕,这样将很难看到什么东西过来了。随后,我翻找了我手机上其它的一些安卓游戏,同时意识到,如果屏幕是横向面对着的会好人多。当是横向的时候,你食指不在是从底部滑上来,而是从右边过来的(当然,如果你是右撇子的话)。这样屏幕上依旧有大部分地方时可以看到的。我也改变了飞行方向。外星人不再是从左飞向右边,而是从屏幕顶部到来。

正因为是这样,我也改变了主要的游戏概念。取代之前固定的游戏时间,你可以一直玩知道你漏过了一个外星人。我最初的想法是你可以在一分钟内尽可能的多得分(类似于水果忍者的街机模式)。但是现在,我想你应该有3次生命或者类似这样的,同时,如果你漏过了一些外星人,游戏将会结束。

我也改变了

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

我也改变了星云的背景。之前我写了关于该教程如何绘制夜空的恒星和星云在GIMP,但我不得不尝试有点让我想看看。它的工作原理减去层两层呈现固体噪声影响,再以五色使用一个单一的颜色和渐变叠加。问题是,减去这两个层总是创建一个“小”的星云,而我想要的颜色充满整个屏幕。我画的星星放置一堆随机点,使用不同颜色的铅笔和一对夫妇。我分开了3层的星星。层之一,我加了一个的2px的阴影(无偏移),第二个我用模糊,我离开了,因为它是第三个。招漂亮的明星是那些绘制接近对方应该永远是不同的颜色或有不同的清晰度。是这样,这是对真实的天空。星星看起来并拢光年,距离只离地球出现。

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 

 

 

 

转载于:https://www.cnblogs.com/NorthDrift/p/3407532.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值