java - 使用 Java 和处理连接 5 游戏实现
问题描述
我正在开发一款 Connect 5 游戏。这里有一个这样的游戏的例子。即使它不是最好的解决方案,我也会使用 Java 和Processing for GUI。我想创建一个二维数组,其中每个元素为零、一或二。最初,每个元素都是零,然后我将根据它的移动将值更新为 1 或 2。我打算把它分解成几个功能:
boolean gameEnd(int move){
// returns true is player 1 or player 2 just won
// else return false
}
void makeMove(int column, int player){
// checks the first available square in the columns and updates the value with 1 or 2
}
void drawMap(int [][] map){
// draws a map using processing depending on the current state of map
}
int getMove(){
// Depending on the coordinate of the click calculate the column where the move was made
}
void setup(){
// initialize array
// call draw function
}
我对这个想法有点怀疑,觉得它可以以更好的方式实现。另外,我不确定实现 drawMap 函数的最佳方法。对于如何使用 Java 和 Processing 实现游戏,我将不胜感激。
解决方案
推荐阅读
- r - 如何用不同的变量处理覆盖两个图?
- python - 在xml python中查找子元素的子元素
- python - 代码不适用于列 CONTENT 每一行的停用词
- sql - 将非结构化字符串转换为特定格式
- elasticsearch - Elasticsearch - 包括在_source中排除的突出显示字段
- javascript - 对象内部的数组拆分
- android - 我可以声明一个 OnClickListener 派生类并将其实例传递给 Frida 中视图的 setOnClickListener 方法吗
- java - 限制客户端仅使用从 yml 文件创建的配置列表中的一种配置
- c++ - C++ - “类”类型重新定义
- ios - 如何解码具有动态嵌套级别数的嵌套 JSON 结构?