
// 2015.12.13 CODEINSIDE.codesafer
#include "glue_screen.h"
#ifndef _DEBUG
#pragma comment(linker, "/SUBSYSTEM:windows /ENTRY:mainCRTStartup")
#endif
#define SCREEN_WIDTH 640
#define SCREEN_HEIGHT 480
typedef struct SNOW
{
float x, y, z;
SNOW()
{
x = rand() % SCREEN_WIDTH;
y = -rand() % SCREEN_HEIGHT * 3;
z = rand() % 50 + 1;
}
void move()
{
x += ( rand() % (int)z - (int)z / 2 ) / 20;
y += z / 50.f;
if ( y > SCREEN_HEIGHT )
y = - rand() % SCREEN_HEIGHT * 3;
}
} SNOW;
SNOW snow_set[5000];
size_t snow_count = sizeof snow_set / sizeof snow_set[0];
void clear( const COLOR32 color )
{
for( size_t y = 0; y < screen.get_height(); ++y )
for( size_t x = 0; x < screen.get_width(); ++x )
screen.put_pixel( x, y, color );
}
void scene()
{
clear( BLACK );
for( size_t i = 0; i < snow_count; ++i )
{
snow_set[i].move();
i8u snow_intensity = snow_set[ i ].z * 3 + 100;
screen.put_pixel( snow_set[i].x, snow_set[i].y,
COLOR32( snow_intensity, snow_intensity, snow_intensity ) );
}
}
int main()
{
screen.open();
screen.on_draw_scene = scene;
screen.run();
screen.close();
return 0;
}
// Fin.
참고하세요 :)
모듈이 조금 세분화 되었습니다.
첫댓글 i8u snow_intensity = snow_set[ i ].z * 5 + 5; 요렇게 하면 공간감이 좀 더 깊어져유~
glue_screen.h는 먼가여
아 밑글에 있군요