-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathBeginners_-_switch_default.c
65 lines (50 loc) · 2.16 KB
/
Beginners_-_switch_default.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
enum flag{rub,adub,bub};
#include "raylib.h"
int main(void)
{
// Initialization
//--------------------------------------------------------------------------------------
const int screenWidth = 800;
const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib example.");
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
//
// Here we show how to use a switch statement.
//
// Note that you can not initialize arrays inside switch cases.
int what=3;
switch (what){
case rub:
break;
case adub:
//int i=0; <<<<<<< You can not initialize things like this in a case label :
//for(int i=0;i<10;i++){//<<<<<<<<< You can do these things in the switch statements.
//int a=10; <<<<<< Here you can initialize ints.
//};
break;
case bub:
break;
default:
DrawText("default switch case.",100,200,30,GRAY);
break;
}
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}