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>
#include <iostream>
#include <windows.h>

#define WIDTH 700
#define HEIGHT 600

using namespace std;
float pos = 0;
float eg=0.0,c;
int hareket=0;
int say=0;
float pos1 = rand() % 4 + 2;
float m1;
float sc = rand() % 2;
double dizi[5000][4];
float sx1 = rand() % 500 + 1, sx2 = rand() % 300 + 1, sx3 = rand() % 500 + 1;
float sy1 = rand() % 400 + 1, sy2 = rand() % 300 + 1, sy3 = rand() % 400 + 1;
float wx = 50;
float wy = 50;
float yenix,yeniy;
float t1;
float t2;
float t3;
int z = 0;
int i, a = 0;
int flag = 0;
float radius = 0.03;
int ptr = 0;
int faltu_bit = 1;
float dizi1[] = { t1, t2, t3 };
float color[3][3] = { { 1.0, 1.0, 1.0 }, { 1.0, 1.0, 0.0 }, { 0.0, 1.0, 0.0 } };
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, 1.0, 0.0, 0.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, 0.0f, 0.0f);
glRectf(600, 0, 700, 600);
yaziyaz("AGIL", 620, 300, 1);
}
void Koyunsay(){
if (sx1 > 600)
yaziyaz("I", 10, 10, 1);
if (sx2> 600)
yaziyaz("II", 10, 10, 1);
if (sx3 > 600)
yaziyaz("III", 10, 10, 1);



}
void koyunlar()

{






glBegin(GL_POINTS);
glColor3f(1.0, 1.0, 0.0);
glVertex2f(sx1, sy1);
glColor3f(1.0, 1.0, 0.0);
glVertex2f(sx2, sy2);
glColor3f(1.0, 1.0, 0.0);
glVertex2f(sx3, sy3);
glEnd();









}

void kurt(float wx,float wy){
glBegin(GL_POINTS);
glColor3f(1.0f, 0.0f, 0.0f);
glVertex2f(wx, wy);
glEnd();


}

void algoritma(){

t1 = sqrt(((sx1 - wx)*(sx1 - wx)) + ((sy1 - wy)*(sy1 - wy)));
t2 = sqrt(((sx2 - wx)*(sx2 - wx)) + ((sy2 - wy)*(sy2 - wy)));
t3 = sqrt(((sx3 - wx)*(sx3 - wy)) + ((sy3 - wy)*(sy3 - wy)));
float dizi[] = { t1, t2, t3 };




if (hareket == 0){
eg = (sy1 - wy) / (sx1 - wx);
yenix = wx;
yeniy = wy;
c=yeniy -eg*yenix;


hareket = 1;
}
else if (hareket == 1 && yenix != sy1){


kurt(yenix, yeniy);


}
}

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]);
//PlaySound("C:\Users\Emind\Desktop\Project5\sheeph.wav", NULL, SND_ASYNC);
}
glEnd();
}




void koordinatguncelle(int x, int y)
{



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





}







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, 1);
}
else{

Koyunsay();
kurt(yenix,yeniy);
algoritma();
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') {
PlaySound("C:\Users\Emind\Desktop\Project6\hav.wav", NULL, SND_ASYNC);
if ((dizi[ptr][0]<sx1) && (dizi[ptr][1]<sy1)){
int fark = dizi[ptr][0] - sx1;
int fark1 = dizi[ptr][1] - sy1;

if ((-fark) <= 100 && (-fark1) <= 100)
{
sx1 -= (fark);
sy1 -= (fark1);
PlaySound("C:\Users\Emind\Desktop\Project6\sheep.wav", NULL, SND_ASYNC);
}
}
else if ((dizi[ptr][0]>sx1) && (dizi[ptr][1]>sy1)){
int fark2 = dizi[ptr][0] - sx1;
int fark3 = dizi[ptr][1] - sy1;

if ((fark2) <= 100 && (fark3) <= 100)
{
sx1 -= fark2;
sy1 -= fark3;
PlaySound("C:\Users\Emind\Desktop\Project6\sheep.wav", NULL, SND_ASYNC);
}
}
else if ((dizi[ptr][0]<sx1) && (dizi[ptr][1]>sy1))
{
int fark4 = dizi[ptr][0] - sx1;
int fark5 = dizi[ptr][1] - sy1;


if ((-fark4) <= 100 && (fark5) <= 100)
{
sx1 -= fark4;
sy1 -= fark5;
PlaySound("C:\Users\Emind\Desktop\Project6\sheep.wav", NULL, SND_ASYNC);
}
}
else if ((dizi[ptr][0]>sx1) && (dizi[ptr][1]<sy1))

{
int fark6 = dizi[ptr][0] - sx1;
int fark7 = dizi[ptr][1] - sy1;


if ((fark6) <= 100 && (-fark7) <= 100)
{

sx1 -= fark6;
sy1 -= fark7;
}
}


if ((dizi[ptr][0]<sx2) && (dizi[ptr][1]<sy2)){
int fark = dizi[ptr][0] - sx2;
int fark1 = dizi[ptr][1] - sy2;

if ((-fark) <= 100 && (-fark1) <= 100)
{
sx2 -= fark;
sy2 -= fark1;
}
}
else if ((dizi[ptr][0]>sx2) && (dizi[ptr][1]>sy2)){
int fark2 = dizi[ptr][0] - sx2;
int fark3 = dizi[ptr][1] - sy2;

if ((fark2) <= 100 && (fark3) <= 100)
{
sx2 -= fark2;
sy2 -= fark3;
}
}
else if ((dizi[ptr][0]<sx2) && (dizi[ptr][1]>sy2))
{
int fark4 = dizi[ptr][0] - sx2;
int fark5 = dizi[ptr][1] - sy2;


if ((-fark4) <= 100 && (fark5) <= 100)
{
sx2 -= fark4;
sy2 -= fark5;
}
}
else if ((dizi[ptr][0]>sx2) && (dizi[ptr][1]<sy2))
{
int fark6 = dizi[ptr][0] - sx2;
int fark7 = dizi[ptr][1] - sy2;


if ((fark6) <= 100 && (-fark7) <= 100)
{

sx2 -= fark6;
sy2 -=fark7;
}
}

if ((dizi[ptr][0]<sx3) && (dizi[ptr][1]<sy3)){
int fark = dizi[ptr][0] - sx3;
int fark1 = dizi[ptr][1] - sy3;
if ((-fark) <= 100 && (-fark1) <= 100)
{
sx3 -= fark;
sy3 -= fark1;
}
}
else if ((dizi[ptr][0]>sx3) && (dizi[ptr][1]>sy3)){
int fark2 = dizi[ptr][0] - sx3;
int fark3 = dizi[ptr][1] - sy3;

if ((fark2) <= 100 && (fark3) <= 100)
{
sx3 -= fark2;
sy3 -= fark3;
}
}
else if ((dizi[ptr][0]<sx3) && (dizi[ptr][1]>sy3))
{
int fark4 = dizi[ptr][0] - sx3;
int fark5 = dizi[ptr][1] - sy3;


if ((-fark4) <= 100 && (fark5) <= 100)
{
sx3 -= fark4;
sy3 -= fark5;
}
}
else if ((dizi[ptr][0]>sx3) && (dizi[ptr][1]<sy3))
{
int fark6 = dizi[ptr][0] - sx3;
int fark7 = dizi[ptr][1] - sy3;


if ((fark6) <= 100 && (-fark7) <= 100)
{

sx3 -= fark6;
sy3 -= fark7;
}
}

}
}
void myPressedMove(int x, int y)
{
if (flag)
{
koordinatguncelle(x, y);
}
}

void myTimer(int t)
{

if (ptr != z - 1)
{



ptr++;



}

if (yenix != sy1 && hareket==1){
yenix++;
yeniy = eg*yenix + c;
}


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("Kurtarma");

algoritma();
glutDisplayFunc(Ekran);
init();
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.