3 parameter function conversion errors.

The key function returns an integer value from a key input. Which then i input into the d function to move the snake around using the snakex and snakey variables. If you look at the d function it has 3 parameters. Everything seems like it should be a okay, but im getting these errors.
Line 64 is what needs to work.
1
2
3
4
5
6
7
||=== Build file: "no target" in "no project" (compiler: unknown) ===|
D:\Eclipse Workspace\MyfirstGame\src\MyfirstGame.cpp||In function 'int main()':|
D:\Eclipse Workspace\MyfirstGame\src\MyfirstGame.cpp|71|error: invalid conversion from 'int (*)()' to 'int' [-fpermissive]|
D:\Eclipse Workspace\MyfirstGame\src\MyfirstGame.cpp|16|note:   initializing argument 1 of 'long int d(int, int&, int&)'|
D:\Eclipse Workspace\MyfirstGame\src\MyfirstGame.cpp||In function 'long int d(int, int&, int&)':|
D:\Eclipse Workspace\MyfirstGame\src\MyfirstGame.cpp|122|warning: no return statement in function returning non-void [-Wreturn-type]|
||=== Build failed: 1 error(s), 1 warning(s) (0 minute(s), 0 second(s)) ===|


This is the code.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <windows.h>
#include <unistd.h>
#include <conio.h>
int key();
long d(int x, int &t, int &c);
int snakex=9;
int snakey=9;
bool running=true;
char map[20][20]={};
void Map_r() {
	int i=0;
	int j=0;

	start:
	do{
	map[i][j]=('i');
	char x=map[i][j];
	++j;
	std::cout<<x<<" ";
	}while(j<20);
	std::cout<<std::endl;
	j=0;
	++i;
	if(i<20){
		goto start;
	}

}
void Map_p() {
	int i=0;
	int j=0;

	startf:
	do{
	char x=map[i][j];
	++j;
	std::cout<<x<<" ";
	}while(j<20);
	std::cout<<std::endl;
	j=0;
	++i;
	if(i<20){

		goto startf;
	}

}
void snake(int &o, int&p)
{
 map[o][p]=('0');
}

int main(){
int rows=20;
snake(snakex,snakey);
	while(running)
	{
	Map_r();
    system("CLS");
//THIS isnt workingvvvvvvvvvvvvvv
	d(key,snakex,snakey);
//This isnt working^^^^^^^^^
	Map_p();
	sleep(10);
system("CLS");
	}
}
int i;
int key()
{
while(1)
{
for(i = 8; i <= 190; i++)
{
if (GetAsyncKeyState(i) & 0x8000)
 {

     return (i);
     }}
return 0;
}
}


long d(int x, int &t, int &c)
{
switch (x)
{
case 38:{
c+=1;
map[t][c]={0};
break;
}
case 40:
{
//down
break;
}
case 37:
{
//left
break;
}
case 39:
{
//right
break;
default:
map[t][c]=0;
}
}
map[t][c]=0;
}


Im having problems with the d function. The key() function is supposed to input in the the d() function along with the snakex, and snake y variables through reference. Line 64 should work in theory, but it doesn't.
Last edited on
Hi,

The key() function is supposed to input in the the d() function along with the snakex, and snake y variables through reference.


So how would you call the key function at that point?
Topic archived. No new replies allowed.