显示和放大器的最佳方法;节目游戏板? [英] Best way to display & program game board?
问题描述
什么是显示的最佳途径和放大器;程序简单的游戏板(说象棋,跳棋等等)在C#中?在控制和潜在的游戏逻辑条款。
What would be the best way to display & program simple game board (say chess, checkers and such) in C#? In terms of controls and underlying game logic.
这来到我的脑海的想法是使用图片框(或类从它继承)与董事会及放大器;现场课。
An idea that came to my mind was to use Picture Box (or class inheriting from it) with Board & Field classes.
- 是一个体面的解决方案,毕竟?
- 我怎么会分开使用此解决方案(我相信董事会及放大器;现场类可能是不够的),从游戏逻辑的图形?
- 是PictureBox的效率不够高这样的目的是什么?
谷歌搜索一些同样使用按钮/标签为每个游戏场给我带来了解决方案。但是,回到局,场和图片框。
Googling some also brought me to solutions using button/label for each game field. But back to Board, Field and PictureBox.
扩 - 设计得当会轻易让实现任何其他棋盘游戏(甚至纸牌游戏),因为它是所有关于与修改的领域毕竟板
Extendability - designing it properly would easily allow to implement any other board game (or even card game) as it's all about board with modifiable fields after all.
推荐答案
在一个面向对象的方法,想想参与游戏中的对象(如板,件)......让他们每人提供绘图方法,它接受图形
对象,并提请本身就可以了。
In an object-oriented approach, think about the objects involved in your game (e.g. the board, the pieces) … let them each provide a drawing method that takes a Graphics
object and draws itself on it.
绘图本身可以在完成图片框
- 这是该用途的理想的控制 - 但这不是真的那么重要,因为一旦你的绘图逻辑的地方,它不会依赖于那种控制。
The drawing itself could be done on a PictureBox
– this is the ideal control for such purpose – but this isn't really all that important because once your drawing logic is in place, it won't depend on the kind of control.
在一般情况下,的不的变通使用不同的控制。这可能是一个传统的GUI不错。没有那么多的游戏(或任何类型的图形重应用)。
In general, don't use workarounds with different controls. These might be nice for a conventional GUI. Not so much for games (or any kind of graphics-heavy application).
这篇关于显示和放大器的最佳方法;节目游戏板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!