lordcyber:
Hi everyone, While I am developing stuff things to Ninjular at slow speed,some ideas pop in my mind from nothing,and I make some code experiments with these.So I will use this topic to share these ideas with you.Maybe can be useful,or maybe a waste of your time.So let's try.
1-Zelda style room transition
A time ago, I tried to create a camera system where I divide a room in smaller sections that limit the camera's motion.If the player move to another section,the camera move to the new section.Firstly I was frustated because I can't get the section's size to use as a limit in the camera's section.Last week, I figured a way.I'm not good in explain in english the details,but if you test the file attached,you'll understand the most part.I tried make the system more custom possible. In a simple way, a section is limited by 4 yellow blocks.the block with I need be put in the top right and the block with II need be put in the bottom right.The other block with disk put in the reaming edge.When the player move to another section,is created 2 invisible objects named obj_track,that moves in the border's section to send the section's dimensions to the camera. The player moves with directional keys.
Still need some tweaks,like turn the camera's move smooth when moves to another section.This concept can be useful in Zelda,Metroidvania type games.
lordcyber:
2-"spr_"+"player"+"_"+"action"
what is cited in the title is that many people wanted use it.The only problem is that,for example, spr_player_action isn't a string and is a shortcut that store the sprite' id.A way to create system of combinating words that define a specific sprite is creating a map containing a the sprite's name as a key and his id as a value.This script was taken from GMLscript.
--- Code: ---/* ** Usage: ** map_sprites(ds_map) ** Arguments: ** ds_map map to which all sprites are loaded ** Returns: ** nothing, but fills the map with {key=name, val=index} pairs ** GMLscripts.com*/ { var no,i,ds_map; ds_map=argument0; no=sprite_create_from_screen(0,0,1,1,false,false,0,0); sprite_delete(no); for (i=0; i<no; i+=1) if(sprite_exists(i))ds_map_add(ds_map,sprite_get_name(i),i);
} --- End code ---
I am simple way, he create a sprite,which id is the biggest value(that is named no).so the others sprites has id between 0 and no-1.If a sprite exist for this the id "i".it adds on the map.
It is important that the map used as argument0 is a global map and you code just that this script run only one time(because this is enough). a practical use is this in the script load_ninja.
--- Code: ---//loading ninja sprites 1:black ninja 2:green ninja 3:red ninja 4:blue ninja var ninja_i; switch(argument0){ case 1:ninja_i='spr_ninjab_';break; case 2:ninja_i='spr_ninjag_';break; case 3:ninja_i='spr_ninjar_';break; case 4:ninja_i='spr_ninjablue_';break; } switch(action){ case 'double_jump': case 'spin': sprite_index=ds_map_find_value(map,ninja_i+'spin'); image_speed=0.5; break; case 'climb_up': case 'climb_down': sprite_index=ds_map_find_value(map,ninja_i+'climb'); image_speed=0; break; case 'hurt': case 'dead': sprite_index=ds_map_find_value(map,ninja_i+action); image_speed=0;image_index=is_behind; break; case 'fatal_hit': image_speed=0.4; if(is_behind==0)sprite_index=ds_map_find_value(map,ninja_i+'fatal_hit'); else sprite_index=ds_map_find_value(map,ninja_i+'fatal_hit2'); break; default: image_speed=0.2; sprite_index=ds_map_find_value(map,ninja_i+action); break; }
--- End code ---
where "map"(horrible choice of name , I know) is the map of the sprite index.This reduce the code size,comparing I do the same thing to the sprites of 4 ninjas in the brute way.
lordcyber:
3-3d sky effect/Star wars effect
While I'm contributing with SCV3 , one request that Las request too much is simulate the sky effect from the Dracula's Keep in the SOTN. At first I tried replicate the effect using 3d functions or drawing a textured primitive, with no sucessful.But I have a better, despite is expected that can have slowdown if you try perform to very big sprites.
The paln is simple: drawing a background "line by line", and the next line will displaced and scaled in a way that the background is fit in a trapezoid.To simulate the motion, it involces the change of the argument "top" in the draw_background_part.So I will show you a wip version of the a object named obj_3dsky and a background name bg_sky. In the create event:
The "a" is the background vertical speed in the trapezoid.This was used like the screen is 320x240 and the trapezoid is set in point likes (0,0) , (320,0) , (x2,y2) , (320-x2,y2).
Magnemania:
If you want to have a smooth Zelda-style room transition, what I did (in an attempt at making a Megaman engine) was to have the game sleep for a few milliseconds, move the character and the camera, force a redraw of the screen, and repeat that until the new room was fully on the screen.
lordcyber:
Yes, this method I implemented in the SCV3.That old method was use in one single big room with smaller sections instead of separated rooms.