🎉 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!

Which language to learn?

Started by
11 comments, last by 8Observer8 4 years ago

Hi people,

In your opinion, which programming language should I learn (and is most appropriate) to develop a game : C or C++ ? Another one?

And why?

Advertisement

Well, imho you should learn C++ or C# to develop games. Thats what Unreal and Unity mainly uses.

Minecraft was coded with Java, Fortnite uses C++. Like JJCA said, the Unreal engine and the game asset creation tool Unity uses C#. Many simple, yet highly additive (and successful) can be made from Python, especially in regards to AI development. There are many facets of game programming-AI development, physics, scripting algorithms and more. I would decide what you would specialize in coding, ItsOff, before choosing a language to learn. As a beginner you are in good hands with Java or Python. If you decide on Python, then the book Head First: Learn to Code is seriously the best purchase you can make this year. Hope my long-ass reply helps! LOL.

Thank you for your answers.

Actually I have some programming skills in PHP and plan to develop a 2D game on Windows. If I understand well, C++ would be a better choice than C language.

Can you explain me what are the main interests to have an object approach instead of a functional one to develop a game?

ItsOff said:

Can you explain me what are the main interests to have an object approach instead of a functional one to develop a game?

What do you mean by object approach, and why wouldn't you accomplish some tasks using a functional approach? It's a separate discussion, IMO, and not something necessarily bound by the chosen language. Pick up C++ and write a little console monopoly game to get the feel of the language.

But I'd totally go with python and forget C++ for now.

ItsOff said:
In your opinion, which programming language should I learn (and is most appropriate) to develop a game

SuperVGA said:
But I'd totally go with GoDot and forget C++ for now.

I can't find GoDot listed on any of the top programming languages lists.

🙂🙂🙂🙂🙂<←The tone posse, ready for action.

fleabay said:

ItsOff said:
In your opinion, which programming language should I learn (and is most appropriate) to develop a game

SuperVGA said:
But I'd totally go with GoDot and forget C++ for now.

I can't find GoDot listed on any of the top programming languages lists.

Alright, my bad.

E: a better comeback would be to suggest them using GDscript, but enough staircase wit…

E2: Also, their follow-up comment indicates that they might be a little confused on languages and general approaches to making games, so I thought to myself “why not give this person a little nudge if they really just want to make 2D games. Perhaps they don't know that they don't need to do a lot of stuff from scratch" etc.

If you have just limited programming experience, i would suggest starting with Python. The reason is that Python is probably the most humanly readable language for beginners, which will teach you most of the concepts applicable to most other programming languages.

Later when you're past making your first “frogger” game, you will find the transition to something like C++ quite bit less confusing and frustrating.

I would not recommend C at this day and age. While there are still plenty scenarios where it's use is mandated. but it's somewhat archaic and lacks quite a few features we come to get used to in more modern languages like C++

What also very important is choosing the right IDE. While there are heaps to choose from, both paid and free, if you're on windows platform Visual Studio Community (free) is probably the most feature complete and easy to use solution that supports all the major languages.

ItsOff said:
Another one?

I study UPBGE (https://upbge.org/)​ It uses Python and Logic Bricks (like Blueprint in UE4). It based on Blender 2.7. The next release of UPBGE 0.3 EEVEE (alpha version is available) will be based on Blender 2.9 and Eevee Render Engine

You should to choose what game engine you are going to use in the future. For example, If you want to use Unreal Engine for 3D games and SFML for 3D games you should to study C++.

You can start to study pure C++ in console by creating simple games using SFML. It is very fun to study C++ with games. Install MinGW and lightweight editor VSCode: https://code.visualstudio.com/docs/languages/cpp

I will publish here my example in SFML and Makefile. Maybe it will be useful for someone.

Type the command: mingw32-make

Makefile

# -mwindows - without a console window

CC = g++

INC = -I"E:\Libs\SFML-2.5.1-windows-gcc-7.3.0-mingw-32-bit\include"

LIB = -L"E:\Libs\SFML-2.5.1-windows-gcc-7.3.0-mingw-32-bit\lib"

all: main.o
	$(CC) -mwindows main.o $(LIB) -lsfml-system -lsfml-window -lsfml-graphics -o app

main.o: main.cpp
	$(CC) -c $(INC) main.cpp

main.cpp

#include <iostream>
#include <sstream>
#include <SFML/Graphics.hpp>

template <typename T>
std::string to_string_with_presision(const T a_value, const int n = 1)
{
    std::ostringstream out;
    out.precision(n);
    out << std::fixed << a_value;
    return out.str();
}

int main()
{
    sf::RenderWindow window(sf::VideoMode(280, 280), L"Отскоки круга");
 
    sf::CircleShape disk(20.f);
    disk.setFillColor(sf::Color::Green);
    disk.setOrigin(20, 20);
    
    sf::Font font;
    if (!font.loadFromFile("C:/Windows/Fonts/arial.ttf"))
    {
        std::cout << "Failed to load the font file.";
        return EXIT_FAILURE;
    }

    sf::Text text;
    text.setFont(font);
    text.setCharacterSize(24);
    text.setFillColor(sf::Color::Red);
    text.setStyle(sf::Text::Bold);
    text.setString("(000.0, 000.0)");
    float textWidth = text.getLocalBounds().width;
    float textHeight = text.getLocalBounds().height;
    text.setOrigin(textWidth / 2, textHeight / 2);
 
    float x = 50;
    float y = 150;
    float x_speed = 0.1f;
    float y_speed = 0.1f;
 
    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }

        x += x_speed;
        y += y_speed;
        if (x < 0 + disk.getRadius() || window.getSize().x - disk.getRadius() < x)
        {
            x_speed *= -1;
        }

        if (y < 0 + disk.getRadius() || window.getSize().y - disk.getRadius() < y)
        {
            y_speed *= -1;
        }

        disk.setPosition(x, y);
        text.setPosition(x, y - disk.getRadius() - textHeight);
        text.setString("(" + to_string_with_presision(x) + ", " + to_string_with_presision(y) + ")");
 
        window.clear(sf::Color::White);
        window.draw(disk);
        window.draw(text);
        window.display();
    }
 
    return EXIT_SUCCESS;
}

This topic is closed to new replies.

Advertisement