#Can someone help me correct the code for my mini game

74 messages Β· Page 1 of 1 (latest)

agile jasperBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

weak valve
#

you'll have to narrow it down to a specific question for us to be of any help (you didn't even ask a question)

winged badge
#

I'm making a game in c++ and it doesn't run. I wanna ask for help to correct some of the code and where did I do somehting wrong

weak valve
#

that's still not a question

vapid lotus
#

you're making it so someone has to download and compile and run your code and see what the actual bug is

weak valve
#

we're not going to debug it for you

vapid lotus
#

what's going wrong, what have you tried

#

be specific

agile jasperBOT
#

@winged badge

Please Do Not Delete Posts!

Please don't delete forum posts. They can be helpful to refer to later and other members can learn from them. In the future you can use !solved to close a post and mark a post as solved.

vapid lotus
#

smh smh

winged badge
#

The thing is Idk what's wrong

#

Im a begginer:(

#

im just trying my best

vapid lotus
#

well start with what the output is saying

#

or at least what you think is going wrong

winged badge
#

it goes like this

#

it exits the code

#

without playing the main game mechanics

vapid lotus
#

does see you next time print when it exits

#

like in the exit function

agile jasperBOT
#

Have you tried stepping through your code line by line in a debugger?

If you don't know how to use a debugger or don't have one set up, we highly recommend taking the time to do so.
Debuggers are immensely helpful tools for figuring out where problems emerge in code and especially when you're first learning it can help you build intuition and understanding for reasoning through code.

Resources:

winged badge
#

it doesn't run this part

weak valve
#

the squiggly line under driverChoice is telling you what's wrong

vapid lotus
#

you also deleted your original message so we don't have your code, you should probably send it again

winged badge
#

ohh

#

bro I dont understand how to correct this

weak valve
#

you haven't assigned a value to driverChoice

winged badge
#

My teacher just taught us the syntax like in 1 hr and made us make a game

#

ohh

vapid lotus
#

i like your game, you should learn raylib

winged badge
#

like this

weak valve
winged badge
#

yeah

#

HWAHHAHAH TAHTS RIGHT

weak valve
#

well that's special

winged badge
#

but i did try to learn it and I study it at 2 nights

#

then made the game

vapid lotus
#

one thing is avoid using goto, instead try to return from a function

winged badge
#

so far I understand some of them and some basic classes

vapid lotus
#

less bugs that way

winged badge
#

how could I do that tho

vapid lotus
#

you'll learn

#

just write your code to rely more on values returning from functions instead of blocks of code running after a goto like

                    driverReturn://dito babalik pag natamaan yung goto driverReturn
                    if (isDriverTurn)
                    {
                        bool driverHandcuff = false;
                       
                        cout << driverName + " held his gun..." << endl;
                        int driverInventory;
                        do {
                            
                            cout << "\033[1;31mHealth Remaining: " << driverHealth << " HP\033[0m" << endl;
                            cout << "\033[1;36m=========================================\033[0m" << endl;
                            cout << "\033[1;36m|           ~ ACTION MENU ~             |\033[0m" << endl;
                            cout << "\033[1;36m=========================================\033[0m" << endl;
                            cout << "\033[1;32m| 1. Eat orange 🍍 (+1 Health) [" << driverOrange << " left] |\033[0m" << endl;
                            cout << "\033[1;31m| 2. Use nail πŸ”¨ (+1 Damage) [" << driverNail << " left]    |\033[0m" << endl;
                            cout << "\033[1;33m| 3. Handcuffs πŸ”— (stun player) [" << driverHandcuffNumber << " left] |\033[0m" << endl;
                            cout << "\033[1;35m| 4. Shoot                        |\033[0m" << endl;
                            cout << "\033[1;36m=========================================\033[0m" << endl;
                            cout << "Enter your choice (1-4): ";

                            cin >> driverInventory;
#

instead, driver return could be a separate functions

#

and you can also store strings in vectors and print them using loops, so you aren't doing cout << endl everywhere

agile jasperBOT
#
How to Learn C++ Programming

We generally recommend a good book to learn the necessary fundamentals:

To actually write and run C++ code, you will need a compiler, editor, and debugger. We strongly recommend to start out using an IDE, which will provide all these tools for you:

<:microsoft:1165512917047853127> Windows
  • [Visual Studio](#1165492293810257920 message)
  • CLion
<:tux:1165505626894520361> Linux
<:apple:1165508607798943754> Mac
winged badge
#

damn, I wish I could understand you bro

vapid lotus
#

this is better for games so you have a million strings defined in one place

#

instead of all over the place

weak valve
#

I'd suggest checking out some of these sources, since your professor doesn't sound like a good source

vapid lotus
#

more organized code

#

^^

winged badge
#

oke oke thanks guys

#

so I need to replace the gotos first?

vapid lotus
#

that stuff i said is just in general for future projects once you learn more

#

dont worry too much this one looks pretty good

#

it sounds like your first project

winged badge
#

yeah it is

#

and its like big pressure cuz we need to pass it tommorow

#

thank you so much guys

vapid lotus
#

np glad to help

vapid lotus
#

this looks like my first game lol

winged badge
#

hahahahha

#

I think it's kinda working now brooo

#

Ill go check if there is some of mechanics not working

agile jasperBOT
#

@winged badge Has your question been resolved? If so, type !solved :)

winged badge
#

!solved