# 第8章：パーティクルシステム

このコードは、パーティクルシステムを作成するための構造体とメソッドを提供します。グラフィックスプログラミングにおいて、パーティクルシステムは、従来のレンダリング技術では再現が非常に難しいある種のぼやけた現象をシミュレートするために使用される技術です。このような現象の例には、火、煙、火花、雨などがあります。

まず、単一のパーティクルを表す`Particle`構造体を定義します。各パーティクルには、位置の`x`と`y`、速度の`x_vel`と`y_vel`、存在する期間を決定する`life`、`size`、`color`、および`alpha`（透明度）などのプロパティがあります。

その後、新しい`Particle`インスタンスを作成するための`new`メソッド、フレームごとにパーティクルの状態を変更するための`update`メソッド（位置、寿命、アルファなど）、およびパーティクルを画面に描画するための`render`メソッドを実装します。`update`関数内には、パーティクルが画面下に到達した場合に画面の上でパーティクルを再生成するための条件が含まれています。

これに続いて、異なるタイプのパーティクルを生成するための異なる関数があります - `spawn_particles_sparks`、`spawn_particles_fires`、および`spawn_particles_rain`。各関数は位置と生成するパーティクルの数を受け取り、タイプに基づいてパーティクルを変更します。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://lados-organization.gitbook.io/goku/goku-game-engine_jp/8ptikurushisutemu.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
