Hi there,
ok i'm pretty new to programming so this is maybe or surely not specific to borland builer but anyway......OK i want to make a checkers game so i declare a kind ...
typedef enum {
Piece1,Piece2, Piece3,Piece4,Piece5,Piece6,Piece7,Piece8,Piece9
,Piece10,Piece11,Piece12,aucun
} pieces_name;
typedef enum {
red,black,none
} pieces_color;
struct piece_t {
pieces_name kind;
pieces_color color;
};
Its for the piece. Making a structure for a piece with his kind and his color. I have made a table representing the board.
So I tried to put piece in it but it gave me an error of 'EAccessViolation'. Here is what I started.
for (int j=0;j<=3;j++){
for (int i=0;i<=7;i+2) {
tab[j]->color = red ;
}
}
}
This 'for' is not finish... Please help me ...Here is what could be inflencing I dont know...(header of declaration)
//////////////////////////Main.h////////////////////////
//---------------------------------------------------------------------------
#ifndef MainH
#define MainH
//---------------------------------------------------------------------------
#include <sysutils.hpp>
#include <windows.hpp>
#include <messages.hpp>
#include <sysutils.hpp>
#include <classes.hpp>
#include <graphics.hpp>
#include <controls.hpp>
#include <forms.hpp>
#include <dialogs.hpp>
#include <stdctrls.hpp>
#include <buttons.hpp>
#include <extctrls.hpp>
#include <menus.hpp>
#include <Buttons.hpp>
#include <Classes.hpp>
#include <Controls.hpp>
#include <Dialogs.hpp>
#include <ExtCtrls.hpp>
#include <Menus.hpp>
#include <Graphics.hpp>
#include <StdCtrls.hpp>
#include <jpeg.hpp>
typedef enum {
Piece1,Piece2, Piece3,Piece4,Piece5,Piece6,Piece7,Piece8,Piece9
,Piece10,Piece11,Piece12,aucun
} pieces_name;
typedef enum {
red,black,none
} pieces_color;
struct piece_t {
pieces_name kind;
pieces_color color;
};
piece_t *tab[8][8] ={
{NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL},
{NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL},
{NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL},
{NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL},
{NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL},
{NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL},
{NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL},
{NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL},
};
//---------------------------------------------------------------------------
class TMainForm : public TForm
{
__published:
TMainMenu *MainMenu;
TMenuItem *FileNewItem;
TMenuItem *FileOpenItem;
TMenuItem *FileSaveItem;
TMenuItem *FileSaveAsItem;
TMenuItem *FileExitItem;
TOpenDialog *OpenDialog;
TSaveDialog *SaveDialog;
TPanel *SpeedBar;
TSpeedButton *SpeedButton1; // &New
TSpeedButton *SpeedButton2; // &Open...
TSpeedButton *SpeedButton3; // &Save
TSpeedButton *SpeedButton4; // Save &As...
TSpeedButton *SpeedButton5;
TImage *RPiece1;
TEdit *testing;
TImage *imgChessboard;
TButton *Button1; // E&xit
void __fastcall FileNew(TObject *Sender);
void __fastcall FileOpen(TObject *Sender);
void __fastcall FileSave(TObject *Sender);
void __fastcall FileSaveAs(TObject *Sender);
void __fastcall FileExit(TObject *Sender);
void __fastcall test(TObject *Sender);
bool __fastcall MoveAllowed (int xstart,int ystart, int xend,int yend);
private: // private user declarations
public: // public user declarations
virtual __fastcall TMainForm(TComponent* Owner);
piece_t *tab[8][8];
};
//---------------------------------------------------------------------------
extern TMainForm *MainForm;
//---------------------------------------------------------------------------
#endif
ok i'm pretty new to programming so this is maybe or surely not specific to borland builer but anyway......OK i want to make a checkers game so i declare a kind ...
typedef enum {
Piece1,Piece2, Piece3,Piece4,Piece5,Piece6,Piece7,Piece8,Piece9
,Piece10,Piece11,Piece12,aucun
} pieces_name;
typedef enum {
red,black,none
} pieces_color;
struct piece_t {
pieces_name kind;
pieces_color color;
};
Its for the piece. Making a structure for a piece with his kind and his color. I have made a table representing the board.
So I tried to put piece in it but it gave me an error of 'EAccessViolation'. Here is what I started.
for (int j=0;j<=3;j++){
for (int i=0;i<=7;i+2) {
tab[j]->color = red ;
}
}
}
This 'for' is not finish... Please help me ...Here is what could be inflencing I dont know...(header of declaration)
//////////////////////////Main.h////////////////////////
//---------------------------------------------------------------------------
#ifndef MainH
#define MainH
//---------------------------------------------------------------------------
#include <sysutils.hpp>
#include <windows.hpp>
#include <messages.hpp>
#include <sysutils.hpp>
#include <classes.hpp>
#include <graphics.hpp>
#include <controls.hpp>
#include <forms.hpp>
#include <dialogs.hpp>
#include <stdctrls.hpp>
#include <buttons.hpp>
#include <extctrls.hpp>
#include <menus.hpp>
#include <Buttons.hpp>
#include <Classes.hpp>
#include <Controls.hpp>
#include <Dialogs.hpp>
#include <ExtCtrls.hpp>
#include <Menus.hpp>
#include <Graphics.hpp>
#include <StdCtrls.hpp>
#include <jpeg.hpp>
typedef enum {
Piece1,Piece2, Piece3,Piece4,Piece5,Piece6,Piece7,Piece8,Piece9
,Piece10,Piece11,Piece12,aucun
} pieces_name;
typedef enum {
red,black,none
} pieces_color;
struct piece_t {
pieces_name kind;
pieces_color color;
};
piece_t *tab[8][8] ={
{NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL},
{NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL},
{NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL},
{NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL},
{NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL},
{NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL},
{NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL},
{NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL},
};
//---------------------------------------------------------------------------
class TMainForm : public TForm
{
__published:
TMainMenu *MainMenu;
TMenuItem *FileNewItem;
TMenuItem *FileOpenItem;
TMenuItem *FileSaveItem;
TMenuItem *FileSaveAsItem;
TMenuItem *FileExitItem;
TOpenDialog *OpenDialog;
TSaveDialog *SaveDialog;
TPanel *SpeedBar;
TSpeedButton *SpeedButton1; // &New
TSpeedButton *SpeedButton2; // &Open...
TSpeedButton *SpeedButton3; // &Save
TSpeedButton *SpeedButton4; // Save &As...
TSpeedButton *SpeedButton5;
TImage *RPiece1;
TEdit *testing;
TImage *imgChessboard;
TButton *Button1; // E&xit
void __fastcall FileNew(TObject *Sender);
void __fastcall FileOpen(TObject *Sender);
void __fastcall FileSave(TObject *Sender);
void __fastcall FileSaveAs(TObject *Sender);
void __fastcall FileExit(TObject *Sender);
void __fastcall test(TObject *Sender);
bool __fastcall MoveAllowed (int xstart,int ystart, int xend,int yend);
private: // private user declarations
public: // public user declarations
virtual __fastcall TMainForm(TComponent* Owner);
piece_t *tab[8][8];
};
//---------------------------------------------------------------------------
extern TMainForm *MainForm;
//---------------------------------------------------------------------------
#endif