在j2me中的蛇游戏对象 [英] snake game objects in j2me

查看:70
本文介绍了在j2me中的蛇游戏对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



i我是j2me的新手

并且想要写一个蛇游戏,

哪些物品可以用于蛇体和食物和董事会?

我可以为他们使用图像吗?

我怎样才能在每部手机中全屏显示这款游戏?

谢谢

hi
i am newbie to j2me
and want to write a snake game,
which objects can i use for snake body and food and board?
can i use images for them?
how can i write this game that in every mobile it be full screen?
thanks

推荐答案

根据您的问题判断,您需要花一些时间研究游戏程序(可能还有Java)的结构。尝试谷歌搜索j2me游戏,查看 J2ME [ ^ ]网站和CodeProject文章。
Judging by your question(s) you need to spend some time researching the structure of games programs (and probably Java). Try a Google search for "j2me games", look at the J2ME[^] web site, and the CodeProject articles.


你可以使用图片,但因为你是一个新手,我不会把注意力集中在那里。现在只需绘制不同颜色的矩形。能够以全屏显示它同样适用,但在这里你应该介意缩放。最简单的方法是将游戏场定义为小块(可以是蛇,食物或障碍物的平安)。您可以为此创建一个类。该类还可以将其绘制为图形(因此可以在OnPaint事件中调用它)。此类确保按照给定的屏幕高度和宽度以正确的比例绘制所有块。所以每个块的宽度和高度是 screen_width / horizo​​ntal_number_of_blocks screen_width / horizo​​ntal_number_of_blocks 。您还可以使用此缩放值通过将其与该值相乘来确定每个块的位置。



希望上面的文字有点清楚我的意思。如果你有问题,就问吧 :)。首先要做的最重要的事情是构建一个工作游戏的基础知识,然后从那里开始。只需保持代码尽可能干净,因此理解起来非常清楚,并且只包含您实际理解的代码。



祝你好运!
You can use images but because you are a newbie I wouldn''t focus to much on that. Simply draw rectangles of different colors for now. The same goes for being able to show it in full screen, but here you should mind scaling. The easiest way is to define the play field as little blocks (which can be a peace of snake, food or obstacle). You can create a class for this. This class can also draw this to a graphic (so it can be called in the OnPaint event). This class makes sure that all the blocks are drawn in the correct scale accordingly to the given height and width of the screen. So the width and height of each block is screen_width / horizontal_number_of_blocks, screen_width / horizontal_number_of_blocks. You also use this scaled value to determine the position of each block by multiplying it with that value.

Hopefully the above text makes somewhat clear what I mean. If you have any questions, just ask :). The most important thing to do first is to build the basics of a working game and then go from there. Just keep the code as clean as possible so it is very clear to understand and consists only of code you actually understand.

Good luck!


这篇关于在j2me中的蛇游戏对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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