- 1
- 2
PI = math.pi
TWOPI = PI*2.0
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−173
PI = math.pi
TWOPI = PI*2.0
Геймоделы.
+142
#include <stdio.h>
#include <stdlib.h>
#include <gb/gb.h>
#include <gb/drawing.h>
#include <rand.h>
#define OBJ_EMPTY 0
#define OBJ_PLAYER 1
#define OBJ_ENEMY 2
void clearscr(void);
void waitbuttona(void);
void initgame(void);
void setcubemem(UINT8 formerx,UINT8 formery);
void enemy(void);
void wingame(void);
int game_field[5][5];
int cube_x = 2;
int cube_y = 3;
int fcx = 0;
int fcy = 0;
UINT8 genenemy = 0;
UINT8 button;
int pointx = 0;
int pointy = 0;
int i = 0;
int u = 0;
int main()
{
initrand(31415);
printf("Running Cube");
waitbuttona();
clearscr();
initgame();
while(1)
{
clearscr();
button = joypad();
fcx = cube_x;
fcy = cube_y;
genenemy = rand();
if(button == J_UP){ cube_x--; setcubemem(fcx,fcy); }
if(button == J_DOWN){ cube_x++; setcubemem(fcx,fcy);}
if(button == J_LEFT){ cube_y--; setcubemem(fcx,fcy);}
if(button == J_RIGHT){ cube_y++; setcubemem(fcx,fcy);}
box(cube_y*20,cube_x*20,cube_y*20+10,cube_x*20+10,M_FILL);
if(genenemy % 4 == 0) enemy();
}
return(0);
}
void clearscr(void)
{
color(WHITE,WHITE,SOLID);
box(0,0,GRAPHICS_WIDTH,GRAPHICS_HEIGHT);
color(BLACK,WHITE,SOLID);
}
void waitbuttona(void)
{
while(1)
{
if(joypad() == J_A) break;
}
}
void setcubemem(UINT8 formerx,UINT8 formery)
{
game_field[formerx][formery] = 0;
game_field[cube_x][cube_y] = OBJ_PLAYER;
}
void initgame(void)
{
game_field[2][3] = OBJ_PLAYER;
}
void enemy(void)
{
initrand(2);
game_field[rand()][rand()] = OBJ_ENEMY;
circle(3*20,1*20,20,1);
if(game_field[cube_x-2][cube_y-2] == OBJ_ENEMY || game_field[cube_x-1][cube_y-1] == OBJ_ENEMY || game_field[cube_x][cube_y] == OBJ_ENEMY || game_field[cube_x+1][cube_y+1] == OBJ_ENEMY || game_field[cube_x+2][cube_y+2] == OBJ_ENEMY)
{
wingame();
}
}
void wingame(void)
{
clearscr();
gotogxy(40,50);
gprintf("You've won!");
delay(1000);
reset();
}
Игра на Gameboy Classic(GBDK,написана мною). Без комментариев.
+142
RECT rect;
GetWindowRect(hWnd, &rect);
int iWidth = rect.right - rect.left;
int iHeight = rect.bottom - rect.top;
Line(hDC, 0, 0, 5000, 0);
Line(hDC, 0, 0, 0, 5000);
Line(hDC, 0, iHeight - 1, iWidth, iHeight - 1);
Line(hDC, iWidth - 1, 0, iWidth - 1, iHeight - 1);
Рисование линий на границе окна.
+141
$skillusers = array($users['str']); //Ну нахера?!!
Зачем, ну зачем оно могло понадобиццо? :-D
+68
String convertingForUi = new Gson().toJson(elements).replaceAll(" \"", " ");
convertingForUi = convertingForUi.replaceAll("\"\\[", "[");
convertingForUi = convertingForUi.replaceAll("]\"", "]");
convertingForUi = convertingForUi.replaceAll("\":", ":");
convertingForUi = convertingForUi.replaceAll(": \"", ": '");
convertingForUi = convertingForUi.replaceAll("\",", "',");
convertingForUi = convertingForUi.replaceAll("\"\n", "'\n");
convertingForUi = convertingForUi.replaceAll("'green'", "green")
...
+67
enum MethodCallResult {
OK,
INTERNAL_ERROR,
INVALID_ARGUMENTS,
...
}
MethodCallResult result = ...;
switch (result.ordinal()) {
case 0:
...
break;
case 1:
...
break;
...
}
Натолкнулся в офигенном Ынтырпрайз-проекте, который спихнули на поддержку. Утверждали, что Sonar выдает 0 ошибок.
−92
Зачем в питоне re.match, re.search = re.match('^' + regexp) и re.findall? Первые 2 меня вообще вымораживают.
+144
scrollValue = scrollValue; //refresh
+144
//перевод даты в timestamp
function strtotimestamp($time) {
$tmp = explode(' ', $time);
$date = explode('.', $tmp[0]);
$hours = explode(':',$tmp[1]);
$tmp = mktime($hours[0], $hours[1], 0, $date[1], $date[0], $date[2]);
return $tmp;
}
когда нужно быстро сделать работающее решение, а времени на чтение гугла нет
−146
n = 0
for i in range(n):
pass
print i
NameError: name 'i' is not defined