L
L
Legebocker2018-03-30 20:18:35
Game development
Legebocker, 2018-03-30 20:18:35

How to program a game within a game?

A lot of games are generally dependent on their audience, this usually happens either when the author of the game has written himself out, or when the game was intended to be. This has been implemented in various ways. Some make third-party programs for creating mods, others sew in some kind of constructor to create levels. So, how to create a game in the game itself??
Lol, I almost answered my own question again. But I'm interested in the mechanism itself. Let's say I want to create an enemy in the game itself. How should I implement this in the creator itself? Can use a normal class that has normal physics for the enemy and make him attack from the secondary functions of bullet spawn, and normal moves. But I'm interested in something else. How will he live without the code?
After all, I will write it in the game, but it will not be registered in the program.
I've been scratching my head over such a simple feature for a long time, help me understand the concept of game programming in the game itself

Answer the question

In order to leave comments, you need to log in

6 answer(s)
V
VoidVolker, 2018-03-30
@EnDeRJaY

Let's say I want to create an enemy in the game itself. How should I implement this in the creator itself? Can use a normal class that has normal physics for the enemy and make him attack from the secondary functions of bullet spawn, and normal moves. But I'm interested in something else. How will he live without the code?

The same goes for any other object. What does it mean to "live without a code"? An enemy is just an object with its own properties. An object is simply a collection of related properties, united by some abstract name. A cube is a collection of points and straight line segments between those points. The same is true for any other objects. Program code is simply an instruction for the processor what to do and how to do it. No more. So in your case, you just need to write code to create an enemy, add a "create enemy" button to the game and bind this code to this button.

A
Alexander, 2018-03-30
@alexr64

After all, I will write it in the game, but it will not be registered in the program.
I've been scratching my head over such a simple feature for a long time, help me understand the concept of game programming in the game itself

How are software plugins written? A documented API is provided, accessible from a scripting (easier for the user, but you will have to provide the tools yourself) / compiled (worse for the user, better for the programmer, development tools, as a rule, are already supplied by other companies) language. And go ahead.
Or provide "bricks" - the simplest objects with some basic functionality that the player can combine into more complex objects. Like in Factorio for example.

M
Mercury13, 2018-03-30
@Mercury13

Usually a scripting engine is used for this. The most famous is Lua.
They also use triggers, the reference example is StarCraft.
But when working with triggers, it is necessary to separate the "condition" and "cause". An occasion is an impulse event that MAY cause a trigger to fire. Conditions are already additional things that are checked later.
The third possibility is a data-driven engine. For example, we set the type of attack, the amount of HP, the type of movement, and so on, and this entire library is already written in the code. A reference example is Doom (the very first, 1993). By the way, scripts appeared in his successor Hexen.

Z
Zakhar Kushchenko, 2018-03-31
@ZZahar

Let's look at this situation using the example of a 3D shooter where we have a map editor.
For example, we have an enemy class (He has variable damage, health, etc.) and the player wants to spawn him, also let's say that everyone spawns on LMB. After pressing the LMB by the player, we will spawn the enemy where the damage and health are selected by the player in advance (I.e. we will spawn the enemy in the same way as in a normal game, but when pressing the LMB with other parameters of health and damage, or the same). The player also wants to spawn a wall (Let's say the player chooses the spawn location using x,y,z in the editor). We'll just step on the same wall, but x,y,z is chosen by the player. To specify variables x,y,z, damage, health, etc., let's say on the right in the game there is a trim for variables (Like in Unity, UE4, etc.), the player enters variables for the item (class, object) that he selected with the mouse then he enters a variable there and when pressing Enter confirms that the variable EnemyDamage = 23, the same variable we use to denote damage when we spawn enemies. There are a lot of details like how objects get into textures, the maximum allowed damage so that the int variable does not overflow, instead of specifying x,y,z the flying camera with the selected object, etc. But I hope I explained the basics to you at least a little bit.

E
Emil Pruzhansky, 2018-09-22
@emil333

And this is easy, first you create artificial intelligence and give it tasks

G
gnevotch, 2020-08-26
@gnevotch

When working with triggers, it is necessary to separate the "condition" and "cause". An occasion is an impulse event that MAY cause a trigger to fire. Conditions are already additional things that are checked later. I found what I was looking for in Kosmolot when I played slots.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question