22: Survival of the Scared (Part 1)
Learning Target
- Inspect an existing project and understand how it is structured
- Implement a day night cycle
Resources
Survival Starter Project:
Starter Project.zip (97 KB)
Use these to get the mouse's position:
-
- CursorX()
- CursorY()
Instructions
Step 1:
Download the starter project and unzip it into your H: drive. Spend a little time investigating the files already provided.
Start GDevelop and open the project file:
Day and Night Starter Template.json
Open the scene and investigate the events.
JSON is a universal data format, not a specific GDevelop file format.
Step 2:
Setup the scene for the beginning of the game:
- Set the daylight to 255 so you can see while you work
- Turn off the rain
- Fix the player's movement
- Speed, acceleration, rotation, etc
- Speed, acceleration, rotation, etc
Step 3:
Find the events that set the day and night cycle. Then, add actions in the proper places to:
- Gradually change brightness of daylight during dawn / dusk

- Change to day / night when dawn / dusk ends

- Wait for time to pass during day / night

- Be sure to reset the timer whenever you switch the time of day

A variable called "brightness" is already added to the light object.
An event already exists to update the color of the light based on the variable's value.
Since there is no condition, it updates the light to the current brightness every frame.

Step 4:
We want the player to be able to see during the night.
- Add a new light object

- Add a Sticker behavior to the light

- When your scene begins, have the light stick to the Player

Now, the player should be able to see things immediately around them when it is night.
If you prefer a different style of player lighting, you can implement one of the challenges.
Challenge (Flashlight Facing Player Direction):
You can simulate a flashlight effect by doing something like this:
- Remove the top-down movement behavior from your player
- Create an invisible movement controller that has your movement behavior
- Add a sticker behavior to your visible player
- Stick your player to the controller
- Change your light object so that it is also stuck to your controller
- Move the light in front of your player so it illuminates the space in front of you
- Don't follow rotation, only the position
- Allow it to rotate
Challenge (Flashlight Follows Mouse):
You can simulate a flashlight effect by doing something like this:
- Create an invisible flashlight object
- Add a sticker behavior to your flashlight
- Stick your flashlight to the controller
- Change your light object so that it is stuck to your flashlight
- Add an event with no condition:
- Rotate the flashlight to point at the mouse coordinates CursorX() and CursorY()
- Move the light in front of your player so it illuminates the space in front of you
Grading
| Your submission... | Your grade... |
|---|---|
|
Emerging Developer
|
A+ |
|
Exceptional
|
A |
|
Good
|
B |
|
Reasonable
|
C |
|
Needs Improvement
|
D |
|
Insufficient
|
F |
| Scores may be rounded to the nearest whole number. | |