NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

#include <iostream>
#include <GL/glut.h>
#include <string.h>
#include <math.h>
#include <cstdlib>
#include<time.h>

#define WIDTH 700
#define HEIGHT 600

using namespace std;
float pos = 0;
float pos1 = rand() % 4 + 2;

float sc = rand() % 2;
double dizi[5000][4];
float x1 = rand() % 500 + 1, x2 = rand() % 400 + 1, x3 = rand() % 500 + 1;
float s1 = rand() % 600 + 1, s2 = rand() % 600 + 1, s3 = rand() % 600 + 1;
float a1 = 50;
float g1 = 50;
float t1;
float t2;
float t3;
int z = 0;
float r1 = rand() % 6 + 1;
float r2 = rand() % 3 + 0.1;
float r3 = rand() % 3 + 0.1;
int i, a = 0;
int flag = 0;
float radius = 0.03;
int ptr = 0;
int sayac = 0;
int faltu_bit = 1;
float color[3][3] = { { 1.0, 1.0, 1.0 }, { 1.0, 1.0, 0.0 }, { 0.0, 1.0, 0.0 } };
float dizi1[] = { t1, t2, t3 };
float min, j;
void yaziyaz(char *str, float x, float y, int id)
{
int i;
int len = strlen(str);

glColor3f(color[id][0], color[id][1], color[id][2]);
glRasterPos2f(x, y);
for (i = 0; i<len; i++)

glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, str[i]);

}


void init()
{
glClearColor(0.0, 0.0, 0.0, 1.0);
glMatrixMode(GL_PROJECTION);
gluOrtho2D(0.0, WIDTH, 0.0, HEIGHT);
memset(dizi, 0, 5000);

glPointSize(30);
glPointSize(30);
}




float mouse_x(int x)
{
double ox = x / (double)WIDTH*(WIDTH);
return ox;
}

float mouse_y(int y)
{
double oy = (1 - y / (double)HEIGHT)*HEIGHT;
return oy;
}



void kopek(float x, float y)
{
glBegin(GL_POINTS);
glColor3f(1.0, 1.0, 1.0);
glVertex2f(x, y);

glEnd();
}
void agil()
{
glColor3f(0.0f, 1.0f, 0.0f);
glRectf(600, 0, 700, 600);
yaziyaz("AGIL", 650, 300, 1);
}
void Koyunsay(){
if (x1 > 600)
yaziyaz("1", 300, 55, 1);
}
void koyunlar()

{

int yon = 1;



sc -= 10;
glBegin(GL_POINTS);
sc += 0.01;
glColor3f(1.0, 1.0, 0.0);
glVertex2f(x1, s1);
glColor3f(1.0, 1.0, 0.0);
glVertex2f(x2, s2);
glColor3f(1.0, 1.0, 0.0);
glVertex2f(x3, s3);
glEnd();






//1.koyun


}

void kurt(){
glBegin(GL_POINTS);
glColor3f(1.0f, 0.0f, 0.0f);
glVertex2f(a1, g1);
glEnd();


}

void cizgiciz(int start)
{
glBegin(GL_LINE_STRIP);
glColor3f(1.0, 0.0, 0.0);
for (int i = start; i<z; i++)
{
glVertex2f(dizi[i][0], dizi[i][1]);
}
glEnd();
}




void koordinatguncelle(int x, int y)
{



dizi[z][0] = mouse_x(x);
dizi[z++][1] = mouse_y(y);





}

void hesapla(){



int j;

t1 = sqrt(((x1 - a1)*(x1 - a1)) + ((s1 - g1)*(s1 - g1)));
t2 = sqrt(((x2 - a1)*(x2 - a1)) + ((s2 - g1)*(s2 - g1)));
t3 = sqrt(((x3 - a1)*(x3 - a1)) + ((s3 - g1)*(s3 - g1)));
float dizi[] = { t1, t2, t3 };

float min = dizi1[0];
int u = 0;

for (j = 1; j < 3; j++) {

if (min > dizi1[j])
min = dizi1[j];

}

if (min == t1){

if (a1 != x1){
a1++;
}
g1 = s1;
}
else if (min == t2){


a1 = x2;
g1 = s2;
}
else if (min == t3){


a1 = x3;
g1 = s3;
}




}







void Ekran()
{
glClear(GL_COLOR_BUFFER_BIT);
glClear(GL_COLOR_BUFFER_BIT);
if (faltu_bit)
{
yaziyaz("SEVIYE 1", 250.0, 400.0, 0);
yaziyaz("SEVIYE 2", 250.0, 300.0, 1);
yaziyaz("SEVIYE 3", 250.0, 200.0, 2);
}
else{
Koyunsay();
kurt();
koyunlar();

cizgiciz(ptr);



agil();

kopek(dizi[ptr][0], dizi[ptr][1]);



}
glutSwapBuffers();
glutPostRedisplay();


glFlush();
}


void myMouseStat(int button, int state, int x, int y)
{
if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN)
{
if (faltu_bit)
{
faltu_bit = 0;
}

flag = 1;
}
else if (button == GLUT_LEFT_BUTTON && state == GLUT_UP)
{
if (flag)
{

flag = 0;
}
}
//1.koyun guneydogu
else if (GLUT_RIGHT_BUTTON){

}

}
void keyPressed(unsigned char key, int x, int y) {

if (key == 'H' || key == 'h') {
/*Birinci Koyun*/
if ((dizi[ptr][0]<x1) && (dizi[ptr][1]<s1)){
int gec = dizi[ptr][0] - x1;
int gec1 = dizi[ptr][1] - s1;
cout << gec;
if ((-gec) <= 100 && (-gec1) <= 100)
{
x1 -= (gec);
s1 -= (gec1);
}
}
else if ((dizi[ptr][0]>x1) && (dizi[ptr][1]>s1)){
int gec2 = dizi[ptr][0] - x1;
int gec3 = dizi[ptr][1] - s1;
cout << gec2;
if ((gec2) <= 100 && (gec3) <= 100)
{
x1 -= gec2;
s1 -= gec3;
}
}
else if ((dizi[ptr][0]<x1) && (dizi[ptr][1]>s1))
{
int gec4 = dizi[ptr][0] - x1;
int gec5 = dizi[ptr][1] - s1;
cout << -gec4, "n";
cout << gec5;

if ((-gec4) <= 100 && (gec5) <= 100)
{
x1 -= gec4;
s1 -= gec5;
}
}
else if ((dizi[ptr][0]>x1) && (dizi[ptr][1]<s1))

{
int gec6 = dizi[ptr][0] - x1;
int gec7 = dizi[ptr][1] - s1;
cout << gec6, "n";
cout << gec7;

if ((gec6) <= 100 && (-gec7) <= 100)
{

x1 -= gec6;
s1 -= gec7;
}
}
/*Birinci Koyun Son*/
/*İkinci Koyun*/
if ((dizi[ptr][0]<x2) && (dizi[ptr][1]<s2)){
int gec = dizi[ptr][0] - x2;
int gec1 = dizi[ptr][1] - s2;
cout << gec;
if ((-gec) <= 100 && (-gec1) <= 100)
{
x2 -= gec;
s2 -= gec1;
}
}
else if ((dizi[ptr][0]>x2) && (dizi[ptr][1]>s2)){
int gec2 = dizi[ptr][0] - x2;
int gec3 = dizi[ptr][1] - s2;
cout << gec2;
if ((gec2) <= 100 && (gec3) <= 100)
{
x2 -= gec2;
s2 -= gec3;
}
}
else if ((dizi[ptr][0]<x2) && (dizi[ptr][1]>s2))
{
int gec4 = dizi[ptr][0] - x2;
int gec5 = dizi[ptr][1] - s2;
cout << -gec4, "n";
cout << gec5;

if ((-gec4) <= 100 && (gec5) <= 100)
{
x2 -= gec4;
s2 -= gec5;
}
}
else if ((dizi[ptr][0]>x2) && (dizi[ptr][1]<s2))
{
int gec6 = dizi[ptr][0] - x2;
int gec7 = dizi[ptr][1] - s2;
cout << gec6, "n";
cout << gec7;

if ((gec6) <= 100 && (-gec7) <= 100)
{

x2 -= gec6;
s2 -= gec7;
}
}
/*İkinci Koyun son*/
if ((dizi[ptr][0]<x2) && (dizi[ptr][1]<s3)){
int gec = dizi[ptr][0] - x3;
int gec1 = dizi[ptr][1] - s3;
cout << gec;
if ((-gec) <= 100 && (-gec1) <= 100)
{
x3 -= gec;
s3 -= gec1;
}
}
else if ((dizi[ptr][0]>x3) && (dizi[ptr][1]>s3)){
int gec2 = dizi[ptr][0] - x3;
int gec3 = dizi[ptr][1] - s3;
cout << gec2;
if ((gec2) <= 100 && (gec3) <= 100)
{
x3 -= gec2;
s3 -= gec3;
}
}
else if ((dizi[ptr][0]<x3) && (dizi[ptr][1]>s3))
{
int gec4 = dizi[ptr][0] - x3;
int gec5 = dizi[ptr][1] - s3;
cout << -gec4, "n";
cout << gec5;

if ((-gec4) <= 100 && (gec5) <= 100)
{
x3 -= gec4;
s3 -= gec5;
}
}
else if ((dizi[ptr][0]>x3) && (dizi[ptr][1]<s3))
{
int gec6 = dizi[ptr][0] - x3;
int gec7 = dizi[ptr][1] - s3;
cout << gec6, "n";
cout << gec7;

if ((gec6) <= 100 && (-gec7) <= 100)
{

x3 -= gec6;
s3 -= gec7;
}
}
/*üçüncü koyun*/
}
}
void myPressedMove(int x, int y)
{
if (flag)
{
koordinatguncelle(x, y);
}
}

void myTimer(int t)
{

if (ptr != z - 1)
{



ptr++;



}




glutTimerFunc(55, myTimer, 0);

}

int main(int argc, char ** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
glutInitWindowPosition(100, 100);
glutInitWindowSize(WIDTH, HEIGHT);
glutCreateWindow("KoyunKurtarma");
init();
hesapla();
glutDisplayFunc(Ekran);

glutMouseFunc(myMouseStat);
glutMotionFunc(myPressedMove);
glutTimerFunc(55, myTimer, 0);
glutKeyboardFunc(keyPressed);
glutMainLoop();
return 0;
}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.