🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

How to make a calculator

Started by
26 comments, last by SuperVGA 3 years, 10 months ago
Advertisement

This isn't Google. Put some effort in asking your question. What exactly are you trying to do? What parts have you go out? What have you found on the web? Why was that not the information you were looking for?

@undefined I just want to make a iphone or android calculator with opengl imgui. Buttons beside and under one another and the display box. I learned how to remove title so now I am trying calculator

ImGui::Begin("hello", nullptr, ImGuiWindoFlag_NoTitleBar)

Simple calculator with buttons and display box

@shaanveer How did the Godot tutorial go?

You've returned to this imgui thing once again, and it's fine to not let something go, but you have to understand that forum correspondence likely won't result in easy code for you to copy and paste over in your project.

You've been shown tutorials out there which you can follow, repeat and tinker with to learn. You'll be able to build that calculator, eventually.

@undefined i finished all the goofy tutorials I saw.

I have this just left to make and you were right godot did help a lot

Know I just need to know ho to render multiple buttons and a display box

Calculator

@undefined i didnt mean to say goofy I meant all

Shaanveer said:

I have this just left to make and you were right godot did help a lot

That's great! So with all the Godot tutorials you saw now finished, you're able to position buttons whereever you want, and link their events to your scripts.

They touch on common UI elements here, and a more comprehensive tutorial here.

It's really cool that you took the time to finish them all - now you're able to do so much.

@undefined ya this is the only thing I dont understand and I was surprised u could even positions buttons anywhere with imgui

I wrote a very simple calculator for practice using HTML and JavaScript. Run on playground

Source code:

<!DOCTYPE html>

<html>
  <head>
    <title>Very Simple Calculator. JavaScript, ES6</title>
  </head>

  <body>
    <h1>Calculator</h1>

    Enter the first number: <input id="firstNumber" type="text" /><br>
    Enter the second number: <input id="secondNumber" type="text" /><br>
    <button id="btnSum">Sum</button><br>
    Result: <span id="output"></span>

    <script>
      // Get the first number element
      const firstNumberElement = document.getElementById("firstNumber");
      // Get the second number element
      const secondNumberElement = document.getElementById("secondNumber");

      // Calculate the result
      let result = 0;
      const btnSum = document.getElementById("btnSum");
      btnSum.onclick = () => {
        // Get numbers
        let firstNumber = parseFloat(firstNumberElement.value);
        let secondNumber = parseFloat(secondNumberElement.value);
        // Result
        result = firstNumber + secondNumber;
        // Output
        const outputElement = document.getElementById("output");
        outputElement.innerText = result;
      };

    </script>
  </body>
</html>

This is very cool but not what I'm talking about. I am talking a about a google or apple calculator with imgui c++ with a display box

This topic is closed to new replies.

Advertisement