This is a big improvement for the player compared to just walking on the bottom of the Stage, as in the Basketball game. The Ground sprite has hills and slopes that the cat can walk on, and you can change the Ground sprite to pretty much any shape in the Paint Editor. #GAME MAKER SCREEN WRAP BEFORE LEAVING SCR ZIP FILE#If you’re lost, open platformer2.sb in the resources ZIP file and continue reading from this point. Then click the red stop sign and save your program. Now the Cat sprite should never sink into the ground. Make the cat walk around or use the mouse to drop the cat from the top of the Stage as before. #GAME MAKER SCREEN WRAP BEFORE LEAVING SCR CODE#Check the checkbox next to Run without screen refresh.Ĭlick the green flag to test the code so far. Name the block handle ground, and then click the gray Options triangle. Go to the More Blocks category, and click the Make a Block button. The dark purple custom blocks can help us do this. This code needs to run so fast that the player only sees the sprite on top of the ground, not in it. The big problem with the code right now is that the Cat sprite is lifted from inside the ground to on top of it very slowly. Click File Upload from your computer in the Scratch editor to load the file, and continue reading from this point. If your program isn’t working and you can’t figure out why, load the project file platformer1.sb2 from the resources ZIP file. This platformer has many scripts, so you might get lost if you get confused. If the Cat sprite walks off the edge of the Ground sprite and falls to the bottom of the Stage, the Cat sprite should reappear at the top. Press the A and D keys to make the cat walk up and down the slopes. Coding is a bit trickier, because we want the ground to have hills and eventually platforms!Ĭlick the green flag to test the code so far. The important difference is that in the platform game, the cat lands when it touches a ground sprite rather than the bottom of the Stage. In the first part, we’ll add gravity, falling, and landing code, similar to the Basketball game in Chapter 4. The skeleton project file has all the sprites already loaded, so you’ll only need to drag the code blocks into each sprite. #GAME MAKER SCREEN WRAP BEFORE LEAVING SCR DOWNLOAD#Go to and download the ZIP file to your computer by right-clicking the link and selecting Save link as or Save target as. If you want to save time, you can start from the skeleton project file, named platformer-skeleton.sb2, in the resources ZIP file. #GAME MAKER SCREEN WRAP BEFORE LEAVING SCR FREE#Hope you find it useful.Ī note about surfaces: remember to free the surfaces if you don’t need them anymore, otherwise it will lead to memory leaks.This platform game is the most ambitious one in the book, but anyone can code it if they follow the steps in this chapter. I will implement a similar version for vertical tearings (for underwater levels? maybe?). Tearings_y = (tearings_y + tearing_speed) % (band_height * band_num)Īnd this is how I make that effect. We draw parts of our application surface on tearings surfaceįor (var current_band = 0 current_band < band_num * 2 current_band++)ĭraw_surface_part(application_surface, 0, band_height * current_band - tearings_y, dw, band_height, sin( (degtorad(360) / band_num ) * current_band) * tearings_x_offset, band_height * current_band - tearings_y)ĭraw_surface_stretched(tearings_surface, -tearings_x_offset, 0, dw + tearings_x_offset * 2, dh) Tearings_surface = surface_create(display_get_width(), display_get_height()) I place the following code inside a draw_post event of my controller. Tearing_speed = 4 // Change this to speed up/slow down the tearings Tearings_x_offset = 32 // How much you want to displace the bands horizontally Tearings_surface = surface_create(dw, dh) // We'll draw on this surfaceīand_num = 16 // How many bands you want on screen This goes into the create event of your game controller object. I wrote the code so it could be easily hackable. I jotted down some code and immediately hit a wall after asking around in the yoyogames forums, reading other’s comments, I could finally come up with a pretty decent solution. Knowing nothing about shaders, I was left with surfaces. I didn’t know how he achieved it so I had to start from scratch and think about different approaches. After playing Environmental Station Alpha, I decided I wanted to implement the screen tearing effect Hempuli is using in his game.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |