Quote (ace07 @ Mar 6 2012 11:31pm)
forráskódot nem posztolsz hozzá?
még a végén ellopod

Code
#include "graphics.hpp"
#include <ctime>
#include <vector>
#include <sstream>
#include <iostream>
#include <cstdlib>
using namespace std;
using namespace genv;
const int szeles=800;
const int magas=400;
struct koord
{
int x;
int y;
};
struct loves
{
koord hely;
bool van;
loves()
{
van=false;
}
void rajz()
{
if (van)
{
gout << move_to(hely.x,hely.y) << color (245,245,0);
gout << box(6,2);
}
if (hely.x>=szeles)
{
van=false;
}
}
void mozog()
{
hely.x=hely.x+8;
}
};
struct csillag
{
koord hely;
int p;
csillag()
{
hely.x=rand()%szeles;
hely.y=rand()%magas;
p=rand()%3+3;
}
void rajz()
{
gout << move_to(hely.x,hely.y);
gout << color(200,200,200) << box(p,1);
}
void mozog()
{
if (hely.x<=0)
{
hely.x=szeles;
hely.y=rand()%magas;
}
hely.x=hely.x-p;
}
};
struct urhajo
{
koord hely;
urhajo()
{
hely.x=20;
hely.y=magas/2;
}
void rajz()
{
gout << move_to(hely.x,hely.y) << color(255,255,255);
gout << move_to(hely.x-11,hely.y);
gout << box(22,2);
gout << move_to(hely.x-3,hely.y-2);
gout << box(6,2);
gout << move_to(hely.x-7,hely.y+2);
gout << box(14,2);
gout << move_to(hely.x+5,hely.y+4);
gout << box(2,2);
gout << move_to(hely.x-7,hely.y+4);
gout << box(2,2);
gout << move_to(hely.x-5,hely.y+6);
gout << box(4,2);
gout << move_to(hely.x+1,hely.y+6);
gout << box(4,2);
gout << move_to(hely.x-11,hely.y+2);
gout << box(2,4);
gout << move_to(hely.x+9,hely.y+2);
gout << box(2,4);
gout << move_to(hely.x-9,hely.y-2);
gout << box(4,2);
gout << move_to(hely.x+5,hely.y-2);
gout << box(4,2);
gout << move_to(hely.x-7,hely.y-4);
gout << box(14,2);
gout << move_to(hely.x+3,hely.y-6);
gout << box(2,2);
gout << move_to(hely.x-5,hely.y-6);
gout << box(2,2);
gout << move_to(hely.x+5,hely.y-8);
gout << box(2,2);
gout << move_to(hely.x-7,hely.y-8);
gout << box(2,2);
}
void mozog(int y)
{
if(hely.y+y<10)
{
y=y-y;
}
if(hely.y+y>magas-10)
{
y=y-y;
}
if (hely.y>10 && hely.y<magas-10)
{
hely.y=hely.y+y;
}
}
};
struct gonosz
{
koord hely;
bool van;
gonosz()
{
hely.x=szeles-11;
hely.y=rand()%magas;
van=true;
}
void rajz()
{
if (hely.x<0+11)
{
van=false;
}
if (van)
{
gout << color(255,255,255);
gout << move_to(hely.x-11,hely.y);
gout << box(22,2);
gout << move_to(hely.x-3,hely.y-2);
gout << box(6,2);
gout << move_to(hely.x-7,hely.y+2);
gout << box(14,2);
gout << move_to(hely.x+5,hely.y+4);
gout << box(2,2);
gout << move_to(hely.x-7,hely.y+4);
gout << box(2,2);
gout << move_to(hely.x-5,hely.y+6);
gout << box(4,2);
gout << move_to(hely.x+1,hely.y+6);
gout << box(4,2);
gout << move_to(hely.x-11,hely.y+2);
gout << box(2,4);
gout << move_to(hely.x+9,hely.y+2);
gout << box(2,4);
gout << move_to(hely.x-9,hely.y-2);
gout << box(4,2);
gout << move_to(hely.x+5,hely.y-2);
gout << box(4,2);
gout << move_to(hely.x-7,hely.y-4);
gout << box(14,2);
gout << move_to(hely.x+3,hely.y-6);
gout << box(2,2);
gout << move_to(hely.x-5,hely.y-6);
gout << box(2,2);
gout << move_to(hely.x+5,hely.y-8);
gout << box(2,2);
gout << move_to(hely.x-7,hely.y-8);
gout << box(2,2);
}
}
void mozog()
{
hely.x=hely.x-2;
}
};
void torles()
{
gout << color(0,0,0) << move_to(0,0) << box(szeles,magas);
}
int main()
{
gout.open(szeles,magas);
bool fel=false;
bool le=false;
bool van=false;
int szamlalo=0;
int pontszam=0;
string pontszams;
stringstream buffer;
vector<csillag>univerzum;
for (int i=0; i<30; i++)
{
csillag temp;
univerzum.push_back(temp);
} //csillagok
vector<gonosz>gonoszok;
for (int i=0; i<7; i++)
{
gonosz temp;
gonoszok.push_back(temp);
} //gonoszok
vector<loves>lovesek;
for (int i=0; i<7; i++)
{
loves temp;
lovesek.push_back(temp);
} //lovesek
urhajo hajo;
gin.timer(40);
event ev;
while(gin >> ev)
{
if (ev.type==ev_key)
{
if (ev.keycode==key_up)
{
fel=true;
}
if (ev.keycode==key_down)
{
le=true;
}
if (ev.keycode==-key_up)
{
fel=false;
}
if (ev.keycode==-key_down)
{
le=false;
}
if (ev.keycode==key_space)
{
van=true;
for (int i=0; i<lovesek.size(); i++)
{
if (van)
{
if (lovesek[i].van==false)
{
lovesek[i].hely.y=hajo.hely.y;
lovesek[i].hely.x=20;
lovesek[i].van=true;
van=false;
}
}
}
}
}
if (ev.type==ev_timer)
{
torles();
hajo.rajz();
if (fel)
{
hajo.mozog(-4);
}
if (le)
{
hajo.mozog(4);
}
for (int i=0; i<univerzum.size(); i++)
{
univerzum[i].rajz();
univerzum[i].mozog();
}
for (int i=0; i<gonoszok.size(); i++)
{
gonoszok[i].rajz();
gonoszok[i].mozog();
}
for (int i=0; i<lovesek.size(); i++)
{
if (lovesek[i].van==true)
{
lovesek[i].rajz();
lovesek[i].mozog();
}
}
for (int i=0; i<lovesek.size(); i++)
{
if (lovesek[i].van==true)
{
for (int j=0; j<gonoszok.size(); j++)
{
if (gonoszok[j].van==true)
{
if ((gonoszok[j].hely.x-lovesek[i].hely.x<14) && (8>(abs(gonoszok[j].hely.y-lovesek[i].hely.y))))
{
lovesek[i].van=false;
gonoszok[j].van=false;
pontszam++;
}
}
}
}
}
if (szamlalo%150==0)
{
for (int i=0; i<gonoszok.size(); i++)
{
if (gonoszok[i].van==false)
{
gonoszok[i].hely.x=szeles-11;
gonoszok[i].hely.y=rand()%(magas-10);
gonoszok[i].van=true;
}
}
}
buffer << pontszam;buffer.clear();buffer >> pontszams;buffer.clear();
gout << move_to(magas,szeles/2-20) << color(200,10,10) << text("Score: ") << text(pontszams);
gout << refresh;
szamlalo++;
}
}
return 0;
}
/*
gout << color(255,255,255);
gout << move_to(hely.x, hely.y);
gout << color(255,255,255);
gout << move_to(hely.x-11,hely.y);
gout << box(22,2);
gout << move_to(hely.x-3,hely.y-2);
gout << box(6,2);
gout << move_to(hely.x-7,hely.y+2);
gout << box(14,2);
gout << move_to(hely.x+5,hely.y+4);
gout << box(2,2);
gout << move_to(hely.x-7,hely.y+4);
gout << box(2,2);
gout << move_to(hely.x-5,hely.y+6);
gout << box(4,2);
gout << move_to(hely.x+1,hely.y+6);
gout << box(4,2);
gout << move_to(hely.x-11,hely.y+2);
gout << box(2,4);
gout << move_to(hely.x+9,hely.y+2);
gout << box(2,4);
gout << move_to(hely.x-9,hely.y-2);
gout << box(4,2);
gout << move_to(hely.x+5,hely.y-2);
gout << box(4,2);
gout << move_to(hely.x-7,hely.y-4);
gout << box(14,2);
gout << move_to(hely.x+3,hely.y-6);
gout << box(2,2);
gout << move_to(hely.x-5,hely.y-6);
gout << box(2,2);
gout << move_to(hely.x+5,hely.y-8);
gout << box(2,2);
gout << move_to(hely.x-7,hely.y-8);
gout << box(2,2);
*/