top of page
Screenshot 2023-01-08 182026.png

Hello World

Introduction

In this article you will learn the basics which are needed for Level 0.

 - You will learn what importing is.

 - You will write your first program in rgame.

 - You will also learn how to use the RG_MainScript object.

Importing

Importing is you letting Python know what tools you will use in your code.

There are 2 types of imports:

import tool

and

from tool import*

The first tells python you will always write tool.Something when you what to use something from the tool. You use this when you only want to use the tool once or twice.

The second says that you will not bother with tool.Something and that if there is something in the tool that matches what you wrote then it should be used from the tool. If you will use the tool frequently then this is what you will use.

In this course you will be using rgame a lot so you will need to write this line of code at the beginning of every file.

from rgame import*

This tells python that you will use rgame and that you will not write out rgame.something when you want to use something from rgame.

Run!

When you use rgame you need to tell RGame what to run. This will be your code of course but this needs to be told to RGame in a way that it understands it. The solution is to give your code to an RG_MainScript object which RGame can then run. You do this by putting your code in a container and giving it a name and then giving that name to the main script. In coding we call these groups functions or methods but we will expand on this later. You also have to tell RGame that you do not want a window. Here is the code:

def Before(self):
       
self.Stop = True
        pass

Run(RG_MainScript(Before))

Here we called our code 'Before '. As for why, we will discuss in the next lesson. For now just go along with this part. We will clarify a lot of it later.

Also notice how the way we gave things information was by writing their name and then writing the information in brackets.

We also stopped RGame from making a window by setting 'self.Stop ' to True

Hello World!

During the development of your game you will likely want to print things out onto the screen. The way you do that is by writing the most famous line of all:

print("Hello World!")

However do not forget to put this inside the code which you are telling RGame to run!

If you run this code you will also see a lot of other stuff but this is because RGame is not designed for Console development so it will fill the console with a lot of other things which are useful for game development but not for seeing what you printed on the screen.

Summary

In this lesson you learn how to:

 - Tell python that you are using RGame

 - Tell RGame to run your code

 - Print something onto the screen

The code you should have produced:

from rgame import*

def
Before(self):       
        
self.Stop = True
        print("Hello World!")
        pass

Run(RG_MainScript(Before))

Task

Here is what you need to do to get to Level 0:

 1) Rename the group of code you are sending to RGame to something else.

 2) Print out something else.

bottom of page