Working with GLUT to create a connect 4 program. I'm struggling to figure out how to attach a circle token ( of either black or red depending on the player) to be attached to the mouse . So, the circle always moves with the mouse, and when the player clicks wherever, as long as its a good move, changes the other players color. I have no idea how to do this. I have a cursor function:
void cursor(int x, int y) {} and a drag function: void drag(int x, int y){} and a function for clicking, that I have already implemented. Any ideas?
#This I have implemented in python as you have not mentioned the language that you are using
| def draw(a=[]): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def tc(a): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if a==0: return " " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if a==1: return "X" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if a==2: return "Y" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| print "\n\n --------------------------- " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| print " [%s] [%s] [%s] [%s] [%s] [%s] [%s] "%(tc(a[5][0]),tc(a[5][1]),tc(a[5][2]),tc(a[5][3]),tc(a[5][4]),tc(a[5][5]),tc(a[5][6])) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| print " [%s] [%s] [%s] [%s] [%s] [%s] [%s] "%(tc(a[4][0]),tc(a[4][1]),tc(a[4][2]),tc(a[4][3]),tc(a[4][4]),tc(a[4][5]),tc(a[4][6])) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| print " [%s] [%s] [%s] [%s] [%s] [%s] [%s] "%(tc(a[3][0]),tc(a[3][1]),tc(a[3][2]),tc(a[3][3]),tc(a[3][4]),tc(a[3][5]),tc(a[3][6])) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| print " [%s] [%s] [%s] [%s] [%s] [%s] [%s] "%(tc(a[2][0]),tc(a[2][1]),tc(a[2][2]),tc(a[2][3]),tc(a[2][4]),tc(a[2][5]),tc(a[2][6])) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| print " [%s] [%s] [%s] [%s] [%s] [%s] [%s] "%(tc(a[1][0]),tc(a[1][1]),tc(a[1][2]),tc(a[1][3]),tc(a[1][4]),tc(a[1][5]),tc(a[1][6])) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| print " [%s] [%s] [%s] [%s] [%s] [%s] [%s] "%(tc(a[0][0]),tc(a[0][1]),tc(a[0][2]),tc(a[0][3]),tc(a[0][4]),tc(a[0][5]),tc(a[0][6])) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| print " --------------------------- " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
print " 1 2 3 4 5 6 7 \n\n"
|
Working with GLUT to create a connect 4 program. I'm struggling to figure out how to...
Connect 4 is a 2 player game where each player has a set of colored tokens (red or yellow). Players take turns during which they place a single token into one of the columns of an n by m grid (where n is the number of rows and m is the number of columns. They place their token into a slot at the top of the column and it falls into the lowest unoccupied slot in that column. A player...
Have been working on this code for awhile and cant get it to
work with Glut. Wondering if there is anything I can fix
#include <iostream>
#include "graph1.h"
using namespace std;
//Add Function Prototypes Here
int getNoPoints();
void getPoints(int x[], int y[], int no_points);
void drawPolyLine(int x[], int y[], int no_points);
int main()
{
//Variable Declaration/Initialization
int no_points = 0;
const int MAX_POINTS = 10;
int x[MAX_POINTS];
int y[MAX_POINTS];
//Display Graphics Window
displayGraphics();...
This task is a program framework that you should complete. The
program should allow the user to move a circular figure with the
mouse over a drawing area. The current position of the figure is
displayed continuously:
Given is the main program:
import javafx.scene.Scene;
import javafx.application.Application;
import javafx.beans.value.*;
import javafx.scene.*;
import javafx.scene.paint.Color;
import javafx.scene.text.Text;
import javafx.stage.Stage;
public class Main extends Application {
private DraggableCircle dc;
private Text text;
private void updateText() {
text.setText("("+dc.getCenterX()+", "+dc.getCenterY()+")");
}
@Override
public void start(final Stage...
Hi! I am struggling trying to figure out how to do this. For this lab, you must have two implementations of calculating the Fibonacci sequence. You are required to calculate it utilizing an array and then with a pointer. You must use the array provided and you must malloc space for your pointer. Your algorithms must be in-place, meaning they do not use a temporary variable to calculate the next sequence number. Lastly, you must insert a comment above each...
Here is the code I have so far. I'm trying to figure out how to
implement a boolean and use precedence. The 2nd expression should
be 14 but it comes out as 28 so I'm definitely not
understanding.
#include <stack>
#include <iostream>
#include <string>
using namespace std;
// Function to find precedence of
// operators.
int precedence(char op) {
if (op == '+' || op == '-')
return 1;
if (op == '*' || op ==...
I've created a functioning program but I can't figure out how to implement class structure into it. I'm currently studying classes and I'm wondering if you could help me recreate my program with classes so I can have a better understanding of how classes work. Thank you. #pragma once #include <iostream> using namespace std; bool DeclareResults(char ch, char gameboard[][3]); bool FilledBoard(char gameboard[][3]); void printGameBoard(char gameboard[][3]); #include "fnt.h"; #include <iostream> using namespace std; int main() { //declare...
C++
please
Project: Working with Text Write an object-oriented program the performs the following tasks: . Reads a text file provided along with this data and maintains it an object. Determines the number of characters and keeps in the object. Determines the number of words and retains the result in the object. Determines the number of paragraphs and keeps the result in the object. A possible class definition: class Textutil { string text = ** int words = @; int...
How to write the insert, search, and remove functions for this hash table program? I'm stuck... This program is written in C++ Hash Tables Hash Table Header File Copy and paste the following code into a header file named HashTable.h Please do not alter this file in any way or you may not receive credit for this lab For this lab, you will implement each of the hash table functions whose prototypes are in HashTable.h. Write these functions in a...
Game Description: Most of you have played a very interesting game “Snake” on your old Nokia phones (Black & White). Now it is your time to create it with more interesting colors and features. When the game is started a snake is controlled by up, down, left and right keys to eat food which appears on random locations. By eating food snake’s length increases one unit and player’s score increases by 5 points. Food disappears after 15 seconds and appears...
Java Painter Class This is the class that will contain main. Main will create a new Painter object - and this is the only thing it will do. Most of the work is done in Painter’s constructor. The Painter class should extend JFrame in its constructor. Recall that you will want to set its size and the default close operation. You will also want to create an overall holder JPanel to add the various components to. It is this JPanel that...