All pastes #144584 Raw Edit

Unnamed

public c v1 · immutable
#144584 ·published 2006-08-22 16:14 UTC
rendered paste body
#include <stdio.h>#include "pz.h"#include <string.h>#include <stdlib.h>#include <math.h>#include <time.h>static PzModule *module;static TWindow *window;static TWidget *wid;static int w, h, bpp;static int sys;static int i; //random numberstatic int j; //counterstatic int n; //for variablestatic int t;static int x=1; //clear screenstatic char now[50],  welcome[100],  points[10], yourscore[100], ready[50]; static int score=0;static int flag, waiting;static int timer;void draw_reflex (PzWidget *wid, ttk_surface srf){	h=ttk_screen->h;	w=ttk_screen->w;	sys = (wid->x + wid->w)/2;		switch(x)	{		case 1:		{			sprintf(welcome,"Welcome to Reflex Tester, press play to start.");			ttk_text (srf,ttk_textfont, (sys)-(ttk_text_width(ttk_textfont,welcome)/2), 50, ttk_makecol(255,0,0),welcome);			break;		}		case 2:		{			sprintf(ready,"READY...");			ttk_text (srf,ttk_textfont, (sys)-(ttk_text_width(ttk_textfont,ready)/2), 40, ttk_makecol(255,0,0),ready);			timer = 0;                        while(timer<i);			ttk_fillrect (srf, 0, 0, ttk_screen->w, ttk_screen->h, ttk_makecol(255,0,0));			sprintf(now,"PRESS ACTION NOW!!!");			ttk_text (srf,ttk_textfont, (sys)-(ttk_text_width(ttk_textfont,now)/2), 60, ttk_makecol(0,0,0),now);                        timer = 0;                        waiting = 1;			while(!flag){}                        score = timer;		}		case 3:		{			sprintf(yourscore,"Your score is: %i, lower is better", score);			ttk_text (srf,ttk_textfont, (sys)-(ttk_text_width(ttk_textfont,yourscore)/2), 50, ttk_makecol(255,0,0),yourscore);                        score = 0;                        again = 0;                        while(again){}                        x=1;			break;		}	}}void increment_timer(TWidget wid){    timer++;}int event_reflex (PzEvent *ev){	int ret = TTK_EV_CLICK;	switch (ev->type)	{		case PZ_EVENT_BUTTON_DOWN:			switch(ev->arg)			{				case PZ_BUTTON_PLAY:					x=2;					wid->dirty++;					break;				case PZ_BUTTON_ACTION:					x=3;                                        if(waiting) flag=1;					wid->dirty++;                                        again = 1;					break;				case PZ_BUTTON_MENU:					pz_close_window (ev->wid->win);					break;			}	}	return ret;}PzWindow *new_reflex_window(){    t=10;	n=0;	x=1;	score=0;		srand(time(0));	i = rand() % 10000;		window = pz_new_window ("reflex", PZ_WINDOW_NORMAL);    wid = pz_add_widget(window, draw_reflex, event_reflex);    wid->timer = increment_timer;    ttk_widget_set_timer(wid, 100);    return pz_finish_window (window);}void cleanup_reflex(){}void init_reflex(){    w =ttk_screen->w; //gets screen width    h =ttk_screen->h; //gets screen hieght    bpp =ttk_screen->bpp; //gets colour depth     module = pz_register_module ("reflex", cleanup_reflex);    pz_menu_add_action ("/Extras/Games/reflex", new_reflex_window);}PZ_MOD_INIT (init_reflex)