HSP sun HSP Programming Guide

HSP Guide [2]

Display message string

Let's display the character in the window of HSP. "mes" The instruction is used. The displayed character encloses ahead and the back with " of normal-width. Put the TAB space pushing the TAB key at the left of the keyboard in front of character Nao of "mes". (The source code : for easiness to see. )

	mes "Hello World!"

"mes" The call, and the paragraph of and the specified character changes line (line below) and is displayed the display of the instruction. Please note that the character representation doesn't stick to the part of the first character in the back.

	mes "Hello World!"
	mes "Hi!"

"mes" The sign of "\n" (yen mark and normal-width alphabet "n") is used to make the instruction change line only once.

	mes "Hello World!\nHi!"

Set string position

Let's change the character and change the display position. "pos" The instruction is used. It specifies it for the parameter by the coordinates numerical value (unit of the dot) in the direction of X and the direction of Y. It is a position on the left of the HSP window (It is a white part usually).

	pos 100,50
	mes "Hello!"

	pos 300,200
	mes "HSP Programming!"

Because the position (length) in which the character was displayed is understood when system variable "ginfo_mesx" is seen if it wants to display it without changing line behind, it is specified for this "pso" instruction.

	mes "Hello World!"

	pos ginfo_mesx,0
	mes "Hi, HSP!"

Multiple function in a line

When the code above is adjusted to one line, it becomes a way below. When the compilation execution is done, operation is quite the same.

	pos 100,50:mes "Hello!":pos 300,200:mes "HSP Programming!"

The speed of the program doesn't quicken separately because it made it to one line like this. Only it is that the code becomes hard to see oppositely and note it, please if you write a lot of processing in one line.


Sentences where what is shown in the source by a specific place are said, "Comment". There are three kinds of ending comment signs (";", "//", and "/*?*/") processed as a comment in HSP. Sentences in this comment will not exist when becoming an execution file.

;comment-out for a line

	;string position
	pos 100,50
//	Hello message
	mes "Hello World!"

comment-out for nultiple line
;	pos 100,200

	mes "Hello HSP World!"	// Say hello

;	inline comment-out
	pos 0,0 : /*mes "!!" :*/ mes "??"

Is it a part where a certain specific place on earth does what processing? еее It forgets when it is man. If the program source grows, it is still a saucer. We will encourage seeing to use ending comment as understood later by because it doesn't influence the size of the execution file and the speed of processing at all even if sentences of a large amount of are written in ending comment.

Set message color

Let's change the character and change the display color. "color" The instruction is used. The color code of R(red), G(green), and B(blue) is specified for the parameter.

	pos 100,50

//	red
	color 255,0,0

	mes "Hello HSP World!"

The color code is a range from 0 to 255 respectively. The middle becomes 128. It is "Light's three primary colors. "Some the color codes are put because everything is given and there is no cod alone.

//	black
	color 0,0,0

//	white
	color 255,255,255

//	blue
	color 0,0,255

//	green
	color 0,0,255

//	yellow
	color 255,255,0

//	sea
	color 0,255,255

Set string size

The display size of the character is changed. The "font" instruction that sets the font, the font size, and the character style is used. The numerical value is specified for the first parameter. The character is displayed in the strapping in a larger numerical value.

	font "",50

	mes "Hello HSP World!"

The font is changed. It doesn't mean the font in case of not being my personal computer alone even if it sets it because the font uses the entering one for the personal computer.

	font "Arial",30
	mes "Hello HSP World!"
	font "Gothic",20
	mes "HSP Guide!"

"font" The display style is also revokable in the second parameter of the instruction. It is a bold-faced type, an oblique character (italics), and is an underline, and the denial lines. Processing named Antieirias beautifully displayed can be used by losing the burr of the character representation if it is OS since WindowsXP. If the numerical value of the style is added, the union combination can be divided ..two or more style.. at the same time.

	font "Arial",20,2
	mes "HSP3 Guide"

	font "Arial",40,4+8
	mes "HSP3.0"

Display slowly message

This is displayed by slowly one character though the character specified that the "mes" instruction is usually used momentarily is displayed. "text" The weight time is specified by the instruction, and the character string slowly displayed by the "emes" instruction is specified. If ink is not neatly loaded, the module file of "hsp3util.as" cannot be used because this two are prepared by not the instruction that corresponds by the standard but the module.

//	include module file
#include "hsp3util.as"

//	The unit is a millisecond (0.5 second)
	text 500
	emes "Hi. This code is display slowly message."

< Prev | Next >


Welcome to HSP sun. Here is a site to introduces HSP, a free script language system.


Copyright(c) HSP sun [HSP]

inserted by FC2 system