这些东西可不可以删除啊?-Java程序解惑,希望大家帮帮忙,打砖块游戏不能用键盘控制。开始和移动都不能。运行是用application吗?-黑帮教父秘籍-小时候玩的一些游戏英语要怎么翻译?急,全部家当都给大家了!

游戏攻略05

这些东西可不可以删除啊?-Java程序解惑,希望大家帮帮忙,打砖块游戏不能用键盘控制。开始和移动都不能。运行是用application吗?-黑帮教父秘籍-小时候玩的一些游戏英语要怎么翻译?急,全部家当都给大家了!,第1张

这些东西可不可以删除啊?-Java程序解惑,希望大家帮帮忙,打砖块游戏不能用键盘控制。开始和移动都不能。运行是用application吗?-黑帮教父 秘籍-小时候玩的一些游戏英语要怎么翻译?急,全部家当都给大家了!
导读:俄罗斯方块实现下降速度使用编程技术:JAVA,C语言,C#。俄罗斯方块 俄罗斯方块是款非常流行的小游戏,通过七个方块的旋转和位移,构成各种变幻莫测的图案。而游戏者也在不断的叠加和消除中找到乐趣。从编程的角度来说,这个游戏混合了键盘事件,定时

俄罗斯方块实现下降速度使用编程技术:JAVA,C语言,C#。

俄罗斯方块

俄罗斯方块是款非常流行的小游戏,通过七个方块的旋转和位移,构成各种变幻莫测的图案。而游戏者也在不断的叠加和消除中找到乐趣。

从编程的角度来说,这个游戏混合了键盘事件,定时器,随机数,鼠标事件(如果没有菜单,这个也不是必需的),数据结构比较清晰,算法比较灵活,图形是比较简单的矩形,所以很适合刚学习完某种语言的语法又想做点什么的初学者。

本文使用的语言包括:c(Turboc20,VC60),JAVA(Applet),c#(NET2003)

编写这个游戏的基本过程是:

首先,把这七个方块用一种数据结构存储起来

其次,在游戏中将这七个方块随机挑选出来并显示在屏幕上,根据键盘事件进行旋转

最后,判断到达底部的方块是简单叠加还是引发消除事件

另外,对这个游戏来说,还有一些记分和过关加速的规则,这些会穿插在上面的内容中讲述。

1存储和旋转七个方块

对于OOP语言(JAVA,C#)来讲,可以写一个数据结构类,处理本游戏中的全部数据。在界面中调用这个类,以实现界面操作与数据结构分离。在后面展示这两个数据结构类的时候,会发现除了语法外,这两个类是基本相同的(把C#的类改了改,再加上键盘操作就成Applet了)。

对于过程化语言(c)来说,界面显示函数与数据结构函数地位相当,所以在形式上稍微分分就行了。

11存储七个方块

普通俄罗斯方块游戏中,只有七个基本方块:|,Z,N,L,7,|-,O,如果加上旋转,一共是19种方块(要注意哦,最后一个正方形的方块不能旋转)。这19种方块都可以画在一个44的方格中。

于是就有两个方法:一个是只存储七个方块,在游戏运行的时候计算旋转后的方块形状;另一个是将19种方块全部存储起来,在游戏运行的时候计算取其中的哪个方块。

另外,考虑到44是16,而一个int正好是16位(TC2是16位,其他的是32位),所以可以把一个方块存储在一个int数据中,取出的时候,判断它的每个bit位,为1处有小方块,为0处是空白。

分别用二维数组和bit的方法来表示这19个方块:

int blocks_shape[19][16]={

0,0,0,0,1,1,0,0,0,1,1,0,0,0,0,0,/11/

0,0,0,0,0,1,0,0,1,1,0,0,1,0,0,0,/12/

0,0,0,0,0,1,1,0,1,1,0,0,0,0,0,0,/21/

0,0,0,0,1,0,0,0,1,1,0,0,0,1,0,0,/22/

0,0,0,0,1,1,1,0,1,0,0,0,0,0,0,0,/31/

0,0,0,0,1,0,0,0,1,0,0,0,1,1,0,0,/32/

0,0,0,0,0,0,1,0,1,1,1,0,0,0,0,0,/33/

0,0,0,0,1,1,0,0,0,1,0,0,0,1,0,0,/34/

0,0,0,0,1,0,0,0,1,1,1,0,0,0,0,0,/41/

0,0,0,0,0,1,0,0,0,1,0,0,1,1,0,0,/42/

0,0,0,0,1,1,1,0,0,0,1,0,0,0,0,0,/43/

0,0,0,0,1,1,0,0,1,0,0,0,1,0,0,0,/44/

0,0,0,0,0,1,0,0,1,1,1,0,0,0,0,0,/51/

0,0,0,0,0,1,0,0,1,1,0,0,0,1,0,0,/52/

0,0,0,0,0,0,0,0,1,1,1,0,0,1,0,0,/53/

0,0,0,0,1,0,0,0,1,1,0,0,1,0,0,0,/54/

0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,/61/

0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,/62/

0,0,0,0,1,1,0,0,1,1,0,0,0,0,0,0,/71/

};

注释里第一个数字表示方块编号,第二个数字表示该方块的第几个变形。

private int[] blocks_shape = {3168,1224,1728,2244,3712,2188,736,3140,2272,1100,3616,3208,1248,1220,228,2248,3840,17476,3264};

显然,第二种方法节约了一些内存。

12旋转七个方块

在游戏中计算旋转后的方块形状:

这个其实就是考考二维坐标知识。还是不贴图。先在脑袋里想像一个44的方格,上面有个|-。|占三个方格的长度,-占一个。以左下角为原点,从左向右画x轴;从下向上画y轴。如果在游戏中想逆时针旋转方块,就把这个坐标轴顺时针旋转一次。多想几遍得到结论:原来的x坐标与新的y坐标相同,原来的y坐标与新的x坐标方向正好相反。这里的“相反”意思是,原来是4,现在是1,原来是2,现在是3。语言不好表达啦,不过想通的话就很容易理解。

在游戏中计算调用19个方块中的哪个方块:

将19个方块存入数组后,再设一数组告诉程序哪七个下标是七个基本方块。比如:private int[] start_bricks = {0,2,4,8,12,16,18};每次随机产生的方块下标都为start_bricks里的元素。当游戏者旋转方块时,将当前方块下标加1,再判断加1后的下标是否在start_bricks里。如果在的话,说明已经是另一个形状了,舍掉,使用start_bricks里原来的下标。最后根据此下标在blocks_shape数组中取出形状,显示在屏幕上。

看看代码。

private int[] bricks = {3168,1224,1728,2244,3712,2188,736,3140,2272,1100,3616,3208,1248,1220,228,2248,3840,17476,3264};

private int[] start_bricks = {0,2,4,8,12,16,18};

/mid是当前方块在bricks中的下标/

for(i=0;i<7;i++)

{

if(mid+1==start_bricks[i])

/如果mid加1后是start_bricks中的元素/

/则还是取start_bricks中原来的元素,即七个基本方块之一,不让它变形/

mid=start_bricks[i-1];

}

2方块落下的处理

21判断方块已经到达底部或是否碰到墙壁

不论是用二维数组还是用bit的方法存储的方块,最终都需要遍历方块的16个小方块中为1的地方是否将会碰到障碍物。“将会”指的是方块如果向左,向右,向下移动后就会碰到障碍物;“障碍物”指的是左右下墙壁和底部已经落下未被消除的小方块。

比较困难的地方,就是把为1的地方转换为相应的坐标,用此坐标判断是否碰到了障碍物。用旋转的办法比较简单,根据旋转的方向转换一下坐标就可以了。如果采用存储19个方块的方法的话,直接看下程序:

用二维数组:

/遍历16个小方块/

for(j=0;j<16;j++)

{

/此处有小方块,判断它是否碰到障碍物/

if(blocks_shape[i][j]==1)

{

/a,b是方块左上角坐标,aaa,bbb是新得到的小方块的坐标/

aaa=a-1+j/4;

bbb=b+j%4;

if( ( aaa==h )||( aa[aaa][bbb]>0 )||( bbb<0 )||( bbb>9 ) )

/aaa==h 表示该小块已经到达底部;aa[aaa][bbb]>0 表示底部该位置已经有了小方块/

{

/返回false,表示会碰到障碍物/

return false;

}

}

}

用bit与此类似,只是多了一个移位处理:

for(int i=0;i<16;i++)

{

/num是当前方块的int值,a,b是当前方块的左上角坐标/

if( (num>>(15-i)&1)!=0 )/此位为1/

{

if( (a+i/4>22)||(b+i%4<0)||(b+i%4>11) )/取得新坐标并加以判断/

{

flag=false;

break;

}

if( (arr[a+i/4][b+i%4]>0) )/底部该位置是否有已经落下的小方块/

{

flag=false;

break;

}

}

}

22消除一行

判断到方块落下后,就开始检查是否有满足消除条件的行了。

规则很简单:只要某行被小方块全部填充,该行就被消除,上面的小方块全部下移一行。所以,只要把原来的小方块全部擦去,计算完新方块位置后,再全部画出就可以了,计算的时候,可以遍历整个游戏区域,看有没有可以消除的行。但是在实际编程中就会发现,这样的设计虽然简单,但是计算量大,而且会引起闪烁(因为是整个擦除和重画),效果不是很好。仔细观察这个游戏,就会发现,其实每次消除的时候,只要判断当前方块所在的四行就足够了。在编程的时候,还可以为方块设一个最高高度h,每次刷新的时候,只刷新从h到当前方块底部的行。虽然这样有点烦琐,但是节约了计算时间,减少了重绘面积,效果还是挺明显的。

另外,一些关于这个游戏算法的介绍,有人建议把随机产生下一个方块的计算放在当前方块正在下落的时候,因为那时比较空闲。总之,只要用心去想,一定会写出代码紧凑,资源利用合理,界面舒适的游戏。

石头Stone(minecraft:stone)1:1

花岗岩Granite(minecraft:stone)1:2

磨制花岗岩PolishedGranite(minecraft:stone)1:3

闪长岩Diorite(minecraft:stone)1:4

磨制闪长岩PolishedDiorite(minecraft:stone)1:5

安山岩Andesite(minecraft:stone)1:6

磨制安山岩PolishedAndesite(minecraft:stone)2

草方块Grass(minecraft:grass)3

泥土Dirt(minecraft:dirt)3:1

砂土CoarseDirt(minecraft:dirt)3:2

灰化土Podzol(minecraft:dirt)4

圆石CobbleStone(minecraft:cobblestone)5

橡木板OakWoodPlank(minecraft:planks)5:1

云杉木板SpruceWoodPlank(minecraft:planks)5:2

桦木板BirchWoodPlank(minecraft:planks)5:3

丛林中的木板JungleWoodPlank(minecraft:planks)5:4

合欢木板AcaciaWoodPlank(minecraft:planks)5:5

深色橡木木板DarkOakWoodPlank(minecraft:planks)6

橡树树苗OakSapling(minecraft:sapling)6:1

云杉树苗SpruceSapling(minecraft:sapling)6:2

白桦树苗BirchSapling(minecraft:sapling)6:3

丛林树苗JungleSapling(minecraft:sapling)6:4

合欢树苗AcaciaSapling(minecraft:sapling)6:5

深色橡树苗DarkOakSapling(minecraft:sapling)7

基岩Bedrock(minecraft:bedrock)8

流水FlowingWater(minecraft:flowing_water)9

水StillWater(minecraft:water)10

流动的熔岩FlowingLava(minecraft:flowing_lava)11

熔岩StillLava(minecraft:lava)12

沙子Sand(minecraft:sand)12:1

红沙RedSand(minecraft:sand)13

沙砾Gravel(minecraft:gravel)14

金矿石GoldOre(minecraft:gold_ore)15

铁矿石IronOre(minecraft:iron_ore)16

煤矿石CoalOre(minecraft:coal_ore)17

橡木OakWood(minecraft:log)17:1

云杉木SpruceWood(minecraft:log)17:2

白桦木BirchWood(minecraft:log)17:3

丛林木JungleWood(minecraft:log)18

橡树叶OakLeaves(minecraft:leaves)18:1

云杉树叶SpruceLeaves(minecraft:leaves)18:2

白桦树叶BirchLeaves(minecraft:leaves)18:3

丛林树叶JungleLeaves(minecraft:leaves)19

海绵Sponge(minecraft:sponge)19:1

湿海绵WetSponge(minecraft:sponge)20

玻璃Glass(minecraft:glass)21

青金矿石LapisLazuliOre(minecraft:lapis_ore)22

青金石块LapisLazuliBlock(minecraft:lapis_block)23

发射器Dispenser(minecraft:dispenser)24

沙石Sandstone(minecraft:sandstone)24:1

錾制沙石ChiseledSandstone(minecraft:sandstone)24:2

光滑沙石SmoothSandstone(minecraft:sandstone)25

音符盒NoteBlock(minecraft:noteblock)26

床Bed(minecraft:bed)27

动力铁轨PoweredRail(minecraft:golden_rail)28

探测器的轨道DetectorRail(minecraft:detector_rail)29

黏性活塞StickyPiston(minecraft:sticky_piston)30

蛛网Cobweb(minecraft:web)31

死灌木DeadShrub(minecraft:tallgrass)31:1

草Grass(minecraft:tallgrass)31:2

蕨类植物Fern(minecraft:tallgrass)32

枯死的灌木DeadBush(minecraft:deadbush)33

活塞Piston(minecraft:piston)34

活塞头PistonHead(minecraft:piston_head)35

白色羊毛WhiteWool(minecraft:wool)35:1

橙色羊毛OrangeWool(minecraft:wool)35:2

品红色羊毛MagentaWool(minecraft:wool)35:3

淡蓝色羊毛LightBlueWool(minecraft:wool)35:4

**羊毛YellowWool(minecraft:wool)35:5

黄绿色羊毛LimeWool(minecraft:wool)35:6

粉色羊毛PinkWool(minecraft:wool)35:7

灰色羊毛GrayWool(minecraft:wool)35:8

浅灰色羊毛LightGrayWool(minecraft:wool)35:9

青色羊毛CyanWool(minecraft:wool)35:10

紫色羊毛PurpleWool(minecraft:wool)35:11

蓝色羊毛BlueWool(minecraft:wool)35:12

棕色羊毛BrownWool(minecraft:wool)35:13

绿色羊毛GreenWool(minecraft:wool)35:14

红毛RedWool(minecraft:wool)35:15

黑色羊毛BlackWool(minecraft:wool)37

蒲公英Dandelion(minecraft:yellow_flower)38

**Poppy(minecraft:red_flower)38:1

兰花BlueOrchid(minecraft:red_flower)38:2

小花Allium(minecraft:red_flower)38:3

茜草花AzureBluet(minecraft:red_flower)38:4

红色郁金香RedTulip(minecraft:red_flower)38:5

橙色郁金香OrangeTulip(minecraft:red_flower)38:6

白色郁金香WhiteTulip(minecraft:red_flower)38:7

粉色郁金香PinkTulip(minecraft:red_flower)38:8

雏菊OxeyeDaisy(minecraft:red_flower)39

棕色蘑菇BrownMushroom(minecraft:brown_mushroom)40

红色蘑菇RedMushroom(minecraft:red_mushroom)41

金块GoldBlock(minecraft:gold_block)42

铁块IronBlock(minecraft:iron_block)43

双层石板DoubleStoneSlab(minecraft:double_stone_slab)43:1

双层沙石板DoubleSandstoneSlab(minecraft:double_stone_slab)43:2

双层木板DoubleWoodenSlab(minecraft:double_stone_slab)43:3

双石子板DoubleCobblestoneSlab(minecraft:double_stone_slab)43:4

双层砖板DoubleBrickSlab(minecraft:double_stone_slab)43:5

双层石砖板DoubleStoneBrickSlab(minecraft:double_stone_slab)43:6

双层末地砖板DoubleNetherBrickSlab(minecraft:double_stone_slab)43:7

双层石英板DoubleQuartzSlab(minecraft:double_stone_slab)44

石板StoneSlab(minecraft:stone_slab)44:1

沙石板SandstoneSlab(minecraft:stone_slab)44:2

木板WoodenSlab(minecraft:stone_slab)44:3

圆石台阶CobblestoneSlab(minecraft:stone_slab)44:4

砖板BrickSlab(minecraft:stone_slab)44:5

石砖板StoneBrickSlab(minecraft:stone_slab)44:6

末地砖板NetherBrickSlab(minecraft:stone_slab)44:7

石英板QuartzSlab(minecraft:stone_slab)45

砖块Bricks(minecraft:brick_block)46

TNT(minecraft:tnt)47

书架Bookshelf(minecraft:bookshelf)48

苔石MossStone(minecraft:mossy_cobblestone)49

黑曜石Obsidian(minecraft:obsidian)50

火把Torch(minecraft:torch)51

火Fire(minecraft:fire)52

刷怪笼MonsterSpawner(minecraft:mob_spawner)53

橡木台阶OakWoodStairs(minecraft:oak_stairs)54

箱子Chest(minecraft:chest)55

红石RedstoneWire(minecraft:redstone_wire)56

钻石矿DiamondOre(minecraft:diamond_ore)57

钻石块DiamondBlock(minecraft:diamond_block)58

工作台CraftingTable(minecraft:crafting_table)59

小麦WheatCrops(minecraft:wheat)60

耕地Farmland(minecraft:farmland)61

熔炉Furnace(minecraft:furnace)62

燃烧的熔炉BurningFurnace(minecraft:lit_furnace)63

木牌StandingSignBlock(minecraft:standing_sign)64

橡木门OakDoorBlock(minecraft:wooden_door)65

梯子Ladder(minecraft:ladder)66

铁轨ail(minecraft:rail)67

石台阶CobblestoneStairs(minecraft:stone_stairs)68

墙上的木牌Wall-mountedSignBlock(minecraft:wall_sign)69

控制杆Lever(minecraft:lever)70

石质压力板StonePressurePlate(minecraft:stone_pressure_plate)71

铁门IronDoorBlock(minecraft:iron_door)72

木质压力板WoodenPressurePlate(minecraft:wooden_pressure_plate)73

红石矿RedstoneOre(minecraft:redstone_ore)74

发光红石矿GlowingRedstoneOre(minecraft:lit_redstone_ore)75

红石火把(灭)RedstoneTorch(off)(minecraft:unlit_redstone_torch)76

红石火把(亮)RedstoneTorch(on)(minecraft:redstone_torch)77

按钮StoneButton(minecraft:stone_button)78

雪块Snow(minecraft:snow_layer)79

冰Ice(minecraft:ice)80

雪块SnowBlock(minecraft:snow)81

仙人掌Cactus(minecraft:cactus)82

黏土Clay(minecraft:clay)83

甘蔗SugarCanes(minecraft:reeds)84

唱片机ukebox(minecraft:jukebox)85

橡木栏OakFence(minecraft:fence)86

南瓜Pumpkin(minecraft:pumpkin)87

地狱岩Netherrack(minecraft:netherrack)88

灵魂沙SoulSand(minecraft:soul_sand)89

萤石Glowstone(minecraft:glowstone)90

传送门NetherPortal(minecraft:portal)91

南瓜灯Jacko'Lantern(minecraft:lit_pumpkin)92

蛋糕CakeBlock(minecraft:cake)93

红石中继器(关)RedstoneRepeaterBlock(off)(minecraft:unpowered_repeater)94

红石中继器(开)RedstoneRepeaterBlock(on)(minecraft:powered_repeater)95

白色染色玻璃WhiteStainedGlass(minecraft:stained_glass)95:1

橙色染色玻璃OrangeStainedGlass(minecraft:stained_glass)95:2

品红染色玻璃MagentaStainedGlass(minecraft:stained_glass)95:3

淡蓝色染色玻璃LightBlueStainedGlass(minecraft:stained_glass)95:4

**染色玻璃YellowStainedGlass(minecraft:stained_glass)95:5

青柠染色玻璃LimeStainedGlass(minecraft:stained_glass)95:6

粉色染色玻璃PinkStainedGlass(minecraft:stained_glass)95:7

灰色染色玻璃GrayStainedGlass(minecraft:stained_glass)95:8

浅灰染色玻璃LightGrayStainedGlass(minecraft:stained_glass)95:9

青色染色玻璃CyanStainedGlass(minecraft:stained_glass)95:10

紫色染色玻璃PurpleStainedGlass(minecraft:stained_glass)95:11

蓝色染色玻璃BlueStainedGlass(minecraft:stained_glass)95:12

棕色染色玻璃BrownStainedGlass(minecraft:stained_glass)95:13

绿色染色玻璃GreenStainedGlass(minecraft:stained_glass)95:14

红色染色玻璃RedStainedGlass(minecraft:stained_glass)95:15

黑色染色玻璃BlackStainedGlass(minecraft:stained_glass)96

木质活版门WoodenTrapdoor(minecraft:trapdoor)97

石头刷怪蛋StoneMonsterEgg(minecraft:monster_egg)97:1

鹅卵石刷怪蛋CobblestoneMonsterEgg(minecraft:monster_egg)97:2

石砖刷怪蛋StoneBrickMonsterEgg(minecraft:monster_egg)97:3

苔石刷怪蛋MossyStoneBrickMonsterEgg(minecraft:monster_egg)97:4

裂石砖怪物蛋CrackedStoneBrickMonsterEgg(minecraft:monster_egg)97:5

錾制石砖怪物蛋ChiseledStoneBrickMonsterEgg(minecraft:monster_egg)98

石砖StoneBricks(minecraft:stonebrick)98:1

苔石砖MossyStoneBricks(minecraft:stonebrick)98:2

CrackedStoneBricks(minecraft:stonebrick)98:3

ChiseledStoneBricks(minecraft:stonebrick)99

棕色蘑菇BrownMushroomBlock(minecraft:brown_mushroom_block)100

扩展资料

如果上方ID显示不全,玩家也可以在游戏中自行查找ID。

首先在游戏中按下F3+H,游戏画面的左下角就会出现相应的提示“高级提示框 显示”;

然后打开物品栏,把屏幕中的准星对准想要查看的物品,ID就会在屏幕中显示出来了。

《我的世界》物品ID即代表了某个物品,主要在一些诸如“/give xx ID 数量”等涉及物品的指令中使用。

比如,在游戏内,输入“/give(空格)ABC(玩家名) 1(空格)1(空格)0”指令分解

意思就是这个指令给了叫做ABC的玩家一个石头。

可以删除的有:

腾讯中文搜搜、百度工具栏、toolbar for internet explorer:工具栏类流氓软件,建议删除

microsoft silverlight:类似flash的播放器插件,可删可不删,无害

Bricks'2000:一个游戏

其他的都是跟系统数据库有关和跟声卡驱动有关的程序,LZ不要删除。

import javaappletApplet;

import javaawtColor;

import javaawtDimension;

import javaawtEvent;

import javaawtFont;

import javaawtFontMetrics;

import javaawtFrame;

import javaawtGraphics;

import javaawtImage;

import javaawteventKeyEvent;

import javaawteventKeyListener;

import javaawteventWindowAdapter;

import javaawteventWindowEvent;

public class ballApplet extends Applet implements Runnable {

Dimension d;

Font bFont = new Font("Helvetica", FontBOLD, 24);

Font sFont = new Font("Helvetica", FontBOLD, 14);

FontMetrics fmSmall, fmBig;

Graphics goff;

Image img;

Thread mThread;

boolean ingame = false;

int ballx, bally, batpos;

int batdpos = 0;

int balldx = 0, balldy = 0, dxval;

int iScroe, ballNum;

boolean[] showbrick;

int brickNumOfLine;

final int bWidth = 5;

final int batW = 20;

final int ballsize = 5;

final int batH = 5;

final int scoreH = 25;

final int brickW = 15;

final int brickH = 8;

final int space = 1;

final int backcol = 0x102040;

final int line = 4;

final int startline = 32;

public void init() {

Graphics g;

d=size();

setBackground(new Color(backcol));

brickNumOfLine = (dwidth-2bWidth)/(brickW +space);

dwidth = brickNumOfLine(brickW+space)+(2bWidth);

g = getGraphics();

gsetFont(sFont);

fmSmall= ggetFontMetrics();

gsetFont(bFont);

fmBig = ggetFontMetrics();

showbrick = new boolean[brickNumOfLineline];

thisaddKeyListener(new BallGameKeyListener());

GameInit();

}

public void GameInit() {

batpos = (dwidth - batW) / 2;

ballx = (dwidth - ballsize) / 2;

bally = (dheight - ballsize - scoreH - 2 bWidth);

iScroe = 0;

ballNum = 3;

dxval = 2;

if (Mathrandom() < 05)

balldx = dxval;

else

balldx = -dxval;

balldy = -dxval;

batdpos = 0;

InitBricks();

}

public void InitBricks() {

int i;

for (i = 0; i < line brickNumOfLine; i++)

showbrick[i] = true;

}

// public boolean keyDown(Event e, int key) {

// if (ingame) {

// if (key == EventLEFT)

// batdpos = -4;

// if (key == EventRIGHT)

// batdpos = 4;

// if (key == EventESCAPE)

// ingame = false;

// } else {

// if (key == 's' || key == 'S') {

// ingame = true;

// GameInit();

// }

// }

// return true;

// }

//

// public boolean keyUp(Event e, int key) {

// if (key == EventLEFT || key == EventRIGHT)

// batdpos = 0;

// return true;

// }

public void paint(Graphics g) {

if (goff == null && dwidth > 0 && dheight > 0) {

img = createImage(dwidth, dheight);

goff = imggetGraphics();

}

if (goff == null || img == null)

return;

goffsetColor(new Color(backcol));

gofffillRect(0, 0, dwidth, dheight);

if (ingame)

PlayGame();

else

ShowIntroScreen();

gdrawImage(img, 0, 0, this);

}

public void PlayGame() {

MoveBall();

CheckBat();

CheckBricks();

DrawPlayField();

DrawBricks();

ShowScore();

}

public void ShowIntroScreen() {

MoveBall();

CheckBat();

CheckBricks();

BatDummyMove();

DrawPlayField();

DrawBricks();

ShowScore();

goffsetFont(bFont);

goffsetColor(new Color(96, 128, 255));

String s = "弹球游戏";

goffdrawString(s, (dwidth - fmBigstringWidth(s)) / 2, (dheight

- scoreH - bWidth) / 2 - 20);

goffsetFont(sFont);

goffsetColor(new Color(128, 255, 32));

s = "请按下'S'键开始游戏";

goffdrawString(s, (dwidth - fmSmallstringWidth(s)) / 2, (dheight

- scoreH - bWidth) / 2 + 30);

goffsetColor(new Color(255, 160, 64));

s = "使用方向键控制球拍移动";

goffdrawString(s, (dwidth - fmSmallstringWidth(s)) / 2, (dheight

- scoreH - bWidth) / 2 + 50);

}

public void DrawBricks() {

int i, j;

boolean nobricks = true;

int colorDelta = 255 / (line - 1);

for (j = 0; j < line; j++) {

for (i = 0; i < brickNumOfLine; i++) {

if (showbrick[j brickNumOfLine + i]) {

nobricks = false;

goffsetColor(new Color(255, j colorDelta, 255 - j

colorDelta));

gofffillRect(bWidth + i (brickW + space), startline + j

(brickH + space), brickW, brickH);

}

}

}

if (nobricks) {

InitBricks();

if (ingame)

iScroe += 100;

}

}

public void DrawPlayField() {

goffsetColor(Colorwhite);

gofffillRect(0, 0, dwidth, bWidth);

gofffillRect(0, 0, bWidth, dheight);

gofffillRect(dwidth - bWidth, 0, bWidth, dheight);

gofffillRect(0, dheight - bWidth, dwidth, bWidth);

gofffillRect(batpos, dheight - 2 bWidth - scoreH, batW, batH);

gofffillRect(ballx, bally, ballsize, ballsize);

}

public void ShowScore() {

goffsetFont(sFont);

goffsetColor(Colorwhite);

goffdrawString("得分:" + iScroe, 40, dheight - 10);

String s = "生命:" + ballNum;

goff

drawString(s, dwidth - 40 - fmSmallstringWidth(s),

dheight - 10);

}

public void MoveBall() {

ballx += balldx;

bally += balldy;

if (bally <= bWidth) {

balldy = -balldy;

bally = bWidth;

}

if (bally >= (dheight - ballsize - scoreH)) {

if (ingame) {

ballNum--;

if (ballNum <= 0)

ingame = false;

}

ballx = batpos + (batW - ballsize) / 2;

bally = startline + line (brickH + space);

balldy = dxval;

balldx = 0;

}

if (ballx >= (dwidth - bWidth - ballsize)) {

balldx = -balldx;

ballx = dwidth - bWidth - ballsize;

}

if (ballx <= bWidth) {

balldx = -balldx;

ballx = bWidth;

}

}

public void BatDummyMove() {

if (ballx < (batpos + 2))

batpos -= 3;

else if (ballx > (batpos + batW - 3))

batpos += 3;

}

public void CheckBat() {

batpos += batpos;

if (batpos < bWidth)

batpos = bWidth;

else if (batpos > (dwidth - bWidth - batW))

batpos = (dwidth - bWidth - batW);

if (bally >= (dheight - scoreH - 2 bWidth - ballsize)

&& bally < (dheight - scoreH - 2 bWidth)

&& (ballx + ballsize) >= batpos && ballx <= (batpos + batW)) {

bally = dheight - scoreH - ballsize - bWidth 2;

balldy = -dxval;

balldx = CheckBatBounce(balldx, ballx - batpos);

}

}

public int CheckBatBounce(int dy, int delta) {

int sign;

int stepsize, i = -ballsize, j = 0;

stepsize = (ballsize + batW) / 8;

if (dy > 0)

sign = 1;

else

sign = -1;

while (i < batW && delta > i) {

i += stepsize;

j++;

}

switch (j) {

case 0:

case 1:

return -4;

case 2:

return -3;

case 7:

return 3;

case 3:

case 6:

return sign 2;

case 4:

case 5:

return sign 1;

default:

return 4;

}

}

public void CheckBricks() {

int i, j, x, y;

int xspeed = balldx;

if (xspeed < 0)

xspeed = -xspeed;

int ydir = balldy;

if (bally < (startline - ballsize)

|| bally > (startline + line (space + brickH)))

return;

for (j = 0; j < line; j++) {

for (i = 0; i < brickNumOfLine; i++) {

if (showbrick[j brickNumOfLine + i]) {

y = startline + j (space + brickH);

x = bWidth + i (space + brickW);

if (bally >= (y - ballsize) && bally < (y + brickH)

&& ballx >= (x - ballsize) && ballx < (x + brickW)) {

showbrick[j brickNumOfLine + i] = false;

if (ingame)

iScroe += (line - j);

if (ballx >= (x - ballsize)

&& ballx <= (x - ballsize + 3)) {

balldx = -xspeed;

} else if (ballx <= (x + brickW - 1)

&& ballx >= (x + brickW - 4)) {

balldx = xspeed;

}

balldy = -ydir;

}

}

}

}

}

public void run() {

long starttime;

Graphics g = getGraphics();

ThreadcurrentThread()setPriority(ThreadMAX_PRIORITY);

while (true) {

starttime = SystemcurrentTimeMillis();

try {

paint(g);

starttime += 20;

Threadsleep(Math

max(0, starttime - SystemcurrentTimeMillis()));

} catch (InterruptedException e) {

break;

}

}

}

public void start() {

if (mThread == null) {

mThread = new Thread(this);

mThreadstart();

}

}

public void stop() {

if (mThread != null) {

mThreadstop();

mThread = null;

}

}

public static void main(String[] args) {

Frame frame = new Frame("弹球游戏");

ballApplet app = new ballApplet();

frameadd("Center", app);

framesetSize(270, 350);

framevalidate();

framesetVisible(true);

frameaddWindowListener(new WindowControl(app));

appinit();

appstart();

}

class BallGameKeyListener implements KeyListener{

@Override

public void keyPressed(KeyEvent e) {

int key = egetKeyCode();

// TODO Auto-generated method stub

if (ingame) {

switch(key){

case KeyEventVK_ESCAPE:

ingame = false;

break;

case KeyEventVK_RIGHT:

batdpos = 4;

break;

case KeyEventVK_LEFT:

batdpos = -4;

break;

}

} else {

if (key == KeyEventVK_S) {

ingame = true;

GameInit();

}

}

}

@Override

public void keyReleased(KeyEvent e) {

// TODO Auto-generated method stub

int key = egetKeyCode();

if (key == KeyEventVK_LEFT || key == KeyEventVK_RIGHT)

batdpos = 0;

}

@Override

public void keyTyped(KeyEvent e) {

// TODO Auto-generated method stub

}

}

}

class WindowControl extends WindowAdapter {

Applet app;

public WindowControl(Applet app) {

thisapp = app;

}

public void WindowClosing(WindowEvent e) {

appstop();

appdestroy();

Systemexit(0);

}

}

给你+了个keyListener 然后按你的理念给你加入了按键判定。按S按键可以开始游戏但方向键不能移动应该是你的方法错误了你自己修改去把懒得看了。。太长了 一般画可以移动的物体是直接按坐标来画然后移动的时候+= 好哦这-= 控制坐标 我发现你的错误是你用batdpos这个变量去控制移动。。但你根本没用这个变量去画图。。所以不能移动。。你自己去改把。。

我在游戏里按以下操作输入秘籍,比如说上帝模式,输完后还是会给人打死,秘籍跟本没起动请高手教教~!

按" ~ "键进入控制台

cheat loonies:得到狂人一个

cheat alienprophets:得到伪装群一个

cheat irissuxx:出现yeah的提示

cheat iwillmakethefamilyrich:得到一个律师

cheat iwillripyourarmsoff:得到一个强制者

cheat youlittlehottieyou:得到一个妓女

cheat pocketsfullofdough:得到一个商人

cheat yourliverlandedoverthere:得到一个火箭发射手

cheat youhadbetterwearkevlar:得到一个黑寡妇

cheat trustmewithyourlife:得到一个保镖

cheat ihavetenpoundfists:得到一个超级保镖

cheat likeatonofbricks:得到一个轰炸机

cheat youwillbestunned:得到一个刺客

cheat whatwasbrieflyyoursisnowmine:得到一个小偷

cheat iwilltakecareofyou:得到一个老妈妈

cheat thegreatvassilizaitsev:得到一个狙击手

cheat iknowodintoo:得到一个忍者

cheat kidiseeeverything:消除迷雾

cheat wowitsgreattobetheboss:上帝模式

cheat needmorelead:所有物资增加1000

cheat youbetterpay:得到100000现金

捏泥巴 pottery make

打仗 fight

打玻璃弹子 billiards

吹肥皂泡 blow bubbles

玩弹弓 slingshot

抽陀螺 spinning top

过家家 play house

跳橡皮筋 elastic dance

躲猫猫 hide and seek

木头人 wooden boy

画老人 depiction

溜溜球 yo-yo

撒游戏棒 sticks

打纸板(翻纸板)cards

斗鸡 gamecock

扯铃 jingle bell

滚铁球 iron ball roller

跳房子 hopscotch

采桑葚 mulberry picking

踢毽子 kicking shuttlecock

积木 toy bricks

竹蜻蜓 dragonfly

老鹰捉小鸡 catch me if you can

丢手帕 run after me

以上就是关于俄罗斯方块下降的速度是通过什么技术实现的全部的内容,包括:俄罗斯方块下降的速度是通过什么技术实现的、《我的世界》物品ID有哪些、这些东西可不可以删除啊等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!