C# · Chapter 3.3 · Basic level
Game Logic (if-else Dragon Boss Gate!)
गेम लॉजिक (if-else से ड्रैगन बॉस अनलॉक करना!)
In games, the Boss Arena stays locked until your Hero reaches Level 10! Notice how C#'s if-else compares with Python's:
• In Python: if level >= 10: (uses colon : + spaces)
• In C#: if (level >= 10) { ... } else { ... } (condition goes inside round brackets ( ), and actions go inside curly braces { } — no colon!).
हर गेम में बॉस फाइट का दरवाज़ा तभी खुलता है जब प्लेयर का level कम से कम 10 हो जाए! देखो C# का if-else कितना साफ़ है:
• शर्त हमेशा गोल ब्रैकेट (level >= 10) के अंदर आती है।
• काम कर्ली ब्रैकेट { ... } के अंदर लिखा जाता है (यहाँ : नहीं लगता)!
Words and symbols in this chapter
int level = 10;- Sets Hero's current game level (
10unlocks the Boss!). - हीरो का लेवल
10रखता है (इसे5करके देखोगे तो दरवाज़ा बंद रहेगा!)। if (level >= 10)- Condition inside
( )— checks iflevelis 10 or higher. - गोल ब्रैकेट
( )में शर्त — क्याlevel10 या उससे ऊपर है? { ... }- Curly braces wrap the commands that run when the condition is true.
{ }के अंदर वे कमांड्स आती हैं जो शर्त सच होने पर चलेंगी।else { ... }- Runs when
levelis below 10 ("Keep Training!"). - अगर लेवल 10 से कम हो तो
elseवाला हिस्सा चलता है।
Ready example
int level = 10;
if (level >= 10) {
Console.WriteLine("Boss Fight Unlocked!");
} else {
Console.WriteLine("Keep Training!");
}
What you will see: At level = 10, a fierce fire-breathing Dragon Boss bursts onto the 2D Game Stage!
जैसे ही level = 10 के साथ Run करोगे, गेम स्टेज पर आग उगलता विशाल ड्रैगन बॉस प्रकट हो जाएगा!
Line by line
int level = 10;- Try
10(Dragon appears!) vs4(Training mode!). 10पर ड्रैगन बॉस आएगा,4करने पर ट्रेनिंग मोड दिखेगा!if (level >= 10) {- Checks if player reached Level 10.
- चेक करता है कि क्या प्लेयर लेवल 10 पर पहुँच गया।
Console.WriteLine("Boss Fight Unlocked!");- Unlocks the Dragon Boss on the 2D Game Stage!
- गेम एरीना में विशाल ड्रैगन बॉस को सामने लाता है!
Common mistake
✗ Wrong
if level >= 10 {
Console.WriteLine("Boss");
}✓ Right
if (level >= 10) {
Console.WriteLine("Boss");
}Unlike Python, C# requires round brackets ( ... ) around every if condition!
Python से अलग, C# में if की शर्त को हमेशा गोल ब्रैकेट ( ... ) के अंदर बंद करना पड़ता है!
Your task
Set int level = 10; and write if (level >= 10) to print "Boss Fight Unlocked!"!
int level = 10; बनाओ और if (level >= 10) लगाकर "Boss Fight Unlocked!" प्रिंट करो!
- Write
int level = 10;.int level = 10;लिखो। - Write
if (level >= 10) { Console.WriteLine("Boss Fight Unlocked!"); }.if (level >= 10)के{ }मेंConsole.WriteLine("Boss Fight Unlocked!");लिखो। - Click ▶ Run & Preview to summon the Dragon Boss!
▶ Run & Preview दबाकर ड्रैगन बॉस को अनलॉक करो!
Starter code for the task
int level = 3;
Console.WriteLine("Current level: " + level);
// TODO 1: upar level ko 10 (ya usse zyada) karo
// TODO 2: if (level >= 10) { Console.WriteLine("Boss Fight Unlocked!"); } likho
// TODO 3: else { Console.WriteLine("Keep Training!"); } bhi jodoDo this task in the classroom: your code is checked automatically and you get hints if something is missing.
Recap
if (condition) { ... } else { ... }chooses what to run.- The condition goes in round brackets
( ), the actions in curly braces{ }. - No colon
:in C# — that is the Python style.
if (condition) { ... } else { ... }तय करता है कि क्या चलेगा।- शर्त गोल ब्रैकेट
( )में, काम curly braces{ }में। - C# में colon
:नहीं लगता — वह Python का तरीका है।
Quick quiz
How do you write an if check in C#?
C# में if की शर्त लिखने का सही तरीका क्या है?
Show the answer
Answer: B (if (level >= 10) { ... })
C# wraps the condition in ( ) and the block body inside { }!
C# में शर्त ( ) के अंदर और कोड ब्लॉक { } के अंदर लिखा जाता है!
Practice problems for this chapter
- Railway Ticket Fare (if / else if / else)
रेलवे टिकट किराया (if / else if / else)
Solve them in the Practice Zone, where each answer is checked automatically and two hints are available.