@Rafael/ARMO, post #2
@mateusz_s, post #3
@asman, post #5
@mateusz_s, post #7
if (losuj() = 0) { //... }
@asman, post #5
Jeśli ten algorytm wybiera tylko parzyste liczby przez ileś tam początkowych losowań to zawsze będzie zero w Twoim przypadku
@asman, post #8
if (losuj() = 0) { //... }
if (funkcja()==0)
if (!funkcja())
@MDW, post #14
@asman, post #8
void SYS__run(void) { // Signal mask for window. ULONG signal_mask = ( 1 << SYS__window->UserPort->mp_SigBit ); char debug_string[32]; UBYTE current_buffer = 0; srand(time(NULL)); // Enter main loop. while (G_io__prefs.is_loop) { // Enter Window Message Loop - handle messages and events. if(SetSignal(0L, signal_mask) & signal_mask) { struct IntuiMessage *imsg; while( imsg = (struct IntuiMessage *)GetMsg(SYS__window->UserPort) ) { switch (imsg->Class) { case IDCMP_MOUSEMOVE: break; case IDCMP_RAWKEY: break; } ReplyMsg((struct Message *)imsg); } } // If using AGA make c2p conversion to the output buffer and display. if (SYS__is_aga) { // Rendering the game. G_run(); // Chunky to planar conversion. c2p1x1_8_c5_040(G_io__prefs.view_buffer, SYS__buffer[current_buffer]->sb_BitMap->Planes[0]); // Swap Buffers with sync. if (G_io__prefs.is_sync) { if (!SYS__safetochange) { while (!GetMsg(SYS__display_port)) WaitPort(SYS__display_port); SYS__safetochange = TRUE; } if (ChangeScreenBuffer(SYS__screen, SYS__buffer[current_buffer])) { SYS__safetochange = FALSE; } } // Switch buffers. current_buffer ^= 1; } else { // Puting into screen display the otherone bitmap. SYS__screen->RastPort.BitMap = SYS__buffer[current_buffer^1]->sb_BitMap; SYS__screen->ViewPort.RasInfo->BitMap = SYS__buffer[current_buffer^1]->sb_BitMap; // Sync with the monitor. if (G_io__prefs.is_sync) { RethinkDisplay(); } // Setting the game output buffer adress into one of the system bitmaps. // Now the geme will render directly into one of the system bitmaps. G_io__prefs.view_buffer = SYS__buffer[current_buffer]->sb_BitMap->Planes[0]; // Rendering the game. G_run(); // Switch buffers. current_buffer ^= 1; } // Show some debug info. if (G_io__prefs.is_debug) { sprintf(debug_string, "fps: %d dt: %.4f sync: %d", rand()%2, G_io__prefs.delta_time, G_io__prefs.is_sync); Move(SYS__window->RPort, 0,20); Text(SYS__window->RPort, (CONST_STRPTR)debug_string, strlen(debug_string)); } } }
int a = ((rand()%20) < 10);
@teh_KaiN, post #15
żeby nie było - przypisanie wartości do wywołania funkcji zawsze skończy się błędem w c/cpp.
Warto mieć włączone -Werror co by kompilator traktował warningi jako errory.
A co do niewidoczności wykrzyknika - może wypadałoby zainwestować w jakiś lepszy schemat kolorowania składni, co by operatory miały inny kolor niż nawiasy. Albo fonta zwiększyć. ;)
@Phibrizzo, post #18
@mateusz_s, post #16
#include <stdio.h> #include <stdlib.h> #include <time.h> int main(void) { char debug_string[32]; srand(time(NULL)); for (int i = 0; i < 20; ++i) { sprintf(debug_string, "fps: %d \n", rand() & 1); printf("%s", debug_string); } return 0; }
Dlatego wolę własną implementacje która ma jakiś własny kontekst.nie ma problemu z mieszaniem wywołań. I to też polecam zrobić.
@MDW, post #14
if( ! funkcja() )
@MDW, post #17
@mateusz_s, post #24