Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Arrays

Author
Message
Dark GDK C++ 2008
11
Years of Service
User Offline
Joined: 11th Apr 2013
Location: Place...No i mean the place called place
Posted: 11th Apr 2013 18:37
Ok so im trying to declare arrays inside a case select, but for some reason im getting just error after error for the array for itself.



void OpenSc();
void Start();
void GameArea(int[] [TILEr],int);
int objects();

bool KeysPressed();
void update(int);
void moveTs(int);
void checkWalls(int);

int Playpeice[4][4];// (only declared to be looked as a global varable to force the select/case to let me use the array)



int objects()
{
int MAX = 700;
int x = dbRND(MAX);
//int Playpeice[4][4];


switch (MAX)
{
case 100://LINE
int Playpeice[4][4] =
{
{NONE,NONE,1,NONE},
{NONE,NONE,1,NONE},
{NONE,NONE,1,NONE},
{NONE,NONE,1,NONE},
};gd

break;
case 200:// T
int Playpeice[4][4]=
{
{NONE,1,1,1},
{NONE,NONE,1,NONE},
{NONE,NONE,NONE,NONE},
{NONE,NONE,NONE,NONE},
};
break;
case 300: // SQUARE
int Playpeice[4][4]=
{
{NONE,NONE,NONE,NONE},
{NONE,1,1,NONE},
{NONE,1,1,NONE},
{NONE,NONE,NONE,NONE},
};
break;
case 400: // S GOING RIGHT
int Playpeice[4][4] =
{
{NONE,NONE,NONE,NONE},
{NONE,1,NONE,NONE},
{NONE,1,1,NONE},
{NONE,NONE,1,NONE},
};
break;
case 500:// S GOING LEFT
int Playpeice[4][4] =
{
{NONE,NONE,1,NONE},
{NONE,1,1,NONE},
{NONE,1,NONE,NONE},
{NONE,NONE,NONE,NONE},
};
break;
case 600:

break;
case 700:
break;
default:
dbPrint("no..");

}




return Playpeice[][];

}// ending of makeing items/objects appear at random places with in a range.

I only want to
Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 12th Apr 2013 00:03
You can't do declarations like that. If you don't know what the size is at the start of your program (for global variables), or the start of the function (for local variables), then you need to use some form of dynamic memory allocation.

Take a look at this site:
http://www.cplusplus.com/forum/articles/7459/

The fastest code is the code never written.
Dark GDK C++ 2008
11
Years of Service
User Offline
Joined: 11th Apr 2013
Location: Place...No i mean the place called place
Posted: 17th Apr 2013 19:47
thanks that really helped out, but now for the noob question of the year...
i see how this is implemented in c++ but some of the commands for c++ will not work for Dark gdk..
for example.
if i wanted to include (
#include "DarkGDK.h"
( i can not include)
#include <iostream>
(just for example sake)
dark comes up with errors saying it cannot find the lib.

I only want to
Mr Bigglesworth
16
Years of Service
User Offline
Joined: 4th Mar 2008
Location:
Posted: 18th Apr 2013 08:35
You need to set your project to be /MT (multi-threaded) or /MTd (multi-threaded debug) depending on your build configuration in your project's properties -> C/C++ -> Code Generation.

Here is an MSDN article about the different settings and how to change them: http://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx

Login to post a reply

Server time is: 2024-11-18 21:47:58
Your offset time is: 2024-11-18 21:47:58