Sie sind auf Seite 1von 5

Quelle.

cpp_______________________________

# include "Igel.h"
# include <iostream>
using namespace std;

int x = 500;
int y = 400;

/*void drawEllipse(struct ellipse k)


{
ellipse(k.r.lo.x, k.r.lo.y, k.r.ru.x, k.r.ru.y, k.strich, RGB(0, 0, 0), RGB(rand() % 256, rand() % 256,
rand() % 256));
}
void drawLinie(struct linie & lin)
{
moveto(lin.anfang.x, lin.anfang.y);
lineto(lin.ende.x, lin.ende.y, lin.strich, RGB(rand() % 256, rand() % 256, rand() % 256));
}
void zeichen()
{
FILE * pf;
int xo, yo, xu, yu, strich, fr, fill;
char text[50];
struct ellipse e;
struct linie lin;
pf = fopen("zeichnung.txt", "r");
if (!pf)
{
cout << "Die Datei kann nicht geffnet werden" << endl;
return;
}
while (1)
{
fscanf(pf, "%s %d %d %d %d %d %d %d", text, &xo, &yo, &xu, &yu, &strich, &fr, &fill);

if (!strcmp(text, "Ellipse"))
{
e.r.lo.x = xo;
e.r.lo.y = yo;
e.r.ru.x = xu;
e.r.ru.y = yu;
e.strich = strich;
drawEllipse(e);
}
else if (!strcmp(text, "Linie"))
{
lin.anfang.x = xu;
lin.anfang.y = yu;
lin.ende.x = xo;
lin.ende.y = yo;
lin.strich = strich;
drawLinie(lin);

}
if (feof(pf)) break;
}
}
void IgelMain()
{
int anzahl, min, max;
int i;
zeichen();

for (int i = 0; i =2; i++)


{
moveto(x, y);
drawRect();
x = x + 100;
}

for (int i = 0; i = 2; i++)


{
moveto(x, y+100);
drawRect();
x = x + 100;
}

for (int i = 0; i = 2; i++)


{
moveto(x, y + 200);
drawRect();
x = x + 100;
}

}*/

int pFeld[3][3] = { 0 };

void IgelMain()
{
show_console();
//int pFeld[3][3] = { 0 };
for (int i = 0; i < 3; i++)
for (int k = 0; k < 3; k++)
printf("%d", pFeld[k][i]);
hide_console();
zeichneFeld();
ausfhrung();

void ausfhrung()
{
boolean player = 1;
int evt;

for (; ;)
{
int mx, my, u;
//update
//klickphase
evt = mouse_event(&u, &mx, &my, 1);
if (evt = WM_LBUTTONDOWN)
{
//Feld oben links
if (mx > 100 && mx < 300 && my > 100 && my < 300)
{
if (pFeld[0][0] == 0 && player == 1) // Player 1 O
{
ellipse(120, 120, 280, 280, 1, RGB(0, 0, 0), RGB(255,
255, 255));
pFeld[0][0] = 1;
}
if (pFeld[0][0] == 0 && player == 2) //Player 2 X
{
int x = 120, y = 120;
zeichnex(x, y);
pFeld[0][0] = 2;
}
//show_console();
}
}

//Textfeld erstellen? Wenn man es anklickt -> O bzw X


}
}

void zeichneFeld()
{
int x = 100;
int y = 100;

moveto(x, y);

//Aussenrahmen
lineto(x + 600, y, 1, (0, 0, 0));
lineto(x + 600, y + 600, 1, (0, 0, 0));
lineto(x, y + 600, 1, (0, 0, 0));
lineto(x, y, 1, (0, 0, 0));

//Innenlinien senkrecht

moveto(x + 200, y);


lineto(x + 200, y + 600, 1, (0, 0, 0));
moveto(x + 400, y);
lineto(x + 400, y + 600, 1, (0, 0, 0));

//Innenlinien waagerecht

moveto(x, y + 200);
lineto(x + 600, y + 200, 1, (0, 0, 0));
moveto(x, y + 400);
lineto(x + 600, y + 400, 1, (0, 0, 0));
}

void zeichnex(int x, int y)


{
moveto(x, y);
lineto(x + 160, y + 160, 5, RGB(0, 0, 0));
moveto(x + 160, y);
lineto(x, y + 160, 5, RGB(0, 0, 0));

}
HEADER.h ______________________________________________________________________________

# ifndef IGEL_H
# define IGEL_H

# include <stdio.h>
# include <windows.h>
# include <conio.h>

# define printf _cprintf


# define scanf _cscanf

struct punkt
{
int x;
int y;
};
struct rect
{
struct punkt lo;
struct punkt ru;
};
;
struct ellipse
{
int strich;
struct rect r;
char text[30];
};
struct linie
{
punkt anfang;
punkt ende;
int strich;
};

extern void ellipse(int lox, int loy, int rux, int ruy, int strich, COLORREF frame, COLORREF fill);
extern void eframe(int lox, int loy, int rux, int ruy, int strich, COLORREF frame);
extern void fill(int x, int y, COLORREF fill, COLORREF border);
extern void lineto(int x, int y, int strich, COLORREF c);
extern void moveto(int x, int y);
extern void setpixel(int x, int y, COLORREF c);
extern COLORREF getpixel(int x, int y);
extern void rectangle(int lox, int loy, int rux, int ruy, int strich, COLORREF frame, COLORREF
fill);
extern void rframe(int lox, int loy, int rux, int ruy, int strich, COLORREF c);
extern void text(int x, int y, int siz, COLORREF bkc, COLORREF txc, int mode, char *fmt, ...);
extern void textbox(int lox, int loy, int rux, int ruy, int strich, COLORREF frame, COLORREF fill,
int siz, COLORREF txc, char *fmt, ...);
extern int load_bitmap(char *bmpfile);

extern void zeichneFeld();


extern void zeichnex(int x, int y);
extern void ausfhrung();

extern void get_windowsize(int *breite, int *hoehe);

extern void wait(unsigned int msecs);

extern int mouse_event(int *flags, int *x, int *y, int wait);
extern int select(int anzahl, ...);

extern void show_console();


extern void hide_console();

# endif

Das könnte Ihnen auch gefallen