2022年8月11日木曜日

Anyone can easily start programming! Introduction to HackforPlay [Slime remodels to become stronger]

https://www.hackforplay.xyz/

Reprinted for study.



Last time, I introduced how to place characters and items on the stage using the new RPG kit.
This time, I will introduce how to strengthen the slime placed on the stage.
Only slime on arena map
First, put the slime on the stage with the + button
I tried setting it to the background of "Togijo" from the button to change the map1

Modify slime to make it stronger

Please pay attention to the upper left of the screen where the program is written
icon on the top left of the code screen
In this column, icons of things placed on the stage are lined up.
There are only the player and the slime in the game right now, so there are only these two icons.
Now let's click the blue slime icon on the right
Modification code for slime
Then ... the program written on the screen changed
Here is a blue slime
  • Set HP to 3 when created in-game
  • Always repeat attack → wait
  • Creates (drops) a green gem when knocked down
And so on... A program about blue slime is written
I read this program as blue slime modification code
Image diagram of switching files being edited
This operation goes from the code about the stage to the modding code for the blue slime.
It is an image that switches the file to be edited

Let's increase the physical strength of the slime

Physical strength is written around line 8
this.n('たいりょく', ('▼ を', 'イコール'), 3) // 体力をきめる
is determined by the code
Now, let's rewrite the written numbers 3to10
Rewrite physical strength and press the play button
Don't forget to press the play button on the upper right after rewriting
Then...
Slime with 10 HP
Slime is a little stronger now

Let's decide the skill of the slime

Next, let's insert a line to set the skill in the blue slime's modification code so that the slime can shoot magic.
To insert the program that sets the skill, first press the + button
The + button is on the upper left of the screen
Then the list of characters will be displayed first , select the skill category and press the red whirlpool
Accidental → Skill → Red Whirlpool
You can select where in the program to insert the code that sets the skill from the button that says select by clicking ▼ .
Click to select ▼ → When created → + Send to stage
Let's choose when it was created this time
After that, when you press + put on stage ...
Game screen.  Slimes now shoot magic whirlpools
A magical whirlpool attacks the player!

When was it made?

blue slime
Part of the program after inserting the code to set the red whirlpool to the skill
This means that when a blue slime is created in the game, the code written between {the parenthesis on line 5 and the parenthesis on line 14 }will be executed line by line.
Therefore, the code written at the time of creation often determines the initial settings of the character.
Besides this
  • Always ... Repeat the written code and run it over and over
  • When knocked down ... Execute the written code when the character's HP reaches 0
And so on

What are skills anyway?

The code for the skill we just added is inserted around line 13
this.skill = '赤色のうず' // 自分のスキルをかえる
This code determines what  the character puts when attacking.  is. For example this
this.skill = 'ばくだん'
, every time the slime attacks, it will place a bomb in front of it.
Slime that puts bombs many times

Let's change the movement of the slime

The code for the movement is always written inside around lines 16-21
always the code
This is because the blue slime always
  1. attack
  2. wait (1 second)
represents a repetition of
So let's insert a line of code here to chase the player
+ button → move category → please  select
Flow until you choose Okake
Click to select ▼ button → select always  → + put on stage button You can insert it by pressing
Select and insert always
Then...
Slime chasing while shooting magic
This is a formidable enemy...!
By the way, my program always looked like this:
always program
Line 22 await this.chase4('プレイヤー') // おいかけるis the inserted code

What happens if you place multiple blue slimes?

Press the icon of the house mark on the upper left of the screen where the program is written
house icon
Then you can go back to the original program where you put things and characters on the stage
In the stage's code, press the add button
Now, place the second blue slime from the + button.
The number of magic-shooting slimes has increased to 2.
The number of powerful enemy slimes has increased to 2!?
This way the mod code change will be applied to all blue slimes in the game

But I wonder if there are more than 2... can't you erase the slime?

To remove the slime we just added, delete the one line of code that makes the slime
rule.つくる('青色のスライム', 1, 4, 'map1', ('▼ むき', Dir.ひだり))it 's around line 14
1, 4,Click somewhere (e.g. around or where there is no button)
Image from Gyazo
Then, a button to copy one line and delete one line is displayed under the 14th line .
Let's delete the selected line with the erase line button and update the game with the play button
Game screen with the slime added earlier disappearing
One-on-one!

try to modify the player

player icon
For that, let's first go to the player mod code

Change player appearance (skin)

After that, please see the category by clicking the + button
Mitame Category
From the Appearance category, you can insert code that allows you to change your appearance
This time, I will insert it when the skin Yusha Woman is created
Player looks like a girl
There are other skins such as red slime, and it's fun even if you become a slime.
Change to your favorite character

make the player stronger

Let's make the player strong like a blue slime.
This time, the author is the player's "when created"
  • Change physical strength (HP) to 10
  • Insert code to beam skill
  • Insert the code that sets the speed to 3 in the strength category
and made the change
Stronger player (game screen)
Speed ​​to toy with slime!

Complete!

The game is now complete! ...... I thought, but actually this game, there is no game clear as it is
It is necessary to insert a program that clears the game at an appropriate location
This time , let's insert it when the blue slime hits the betta
System category
Game clear is in the system category
Hack.gameclear() // ゲームクリア
will insert the code

You can play the completed sample game here

0 コメント:

コメントを投稿