【GAMEMAKER】 Database INI

Information about object: obj_planets
Sprite:
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Create Event:
execute code:

planets=3;//how many planets
current=0;//which is currently selected (for drawing)
ini_open("planets.ini")//open ini file
for (i = 0; i < planets; i += 1)//loop through no of planets
{
if i=0 planet="mercury"//set section name
if i=1 planet="venus"
if i=2 planet="earth"
data[i,0]=ini_read_string(planet,"name","");//read from section and key
data[i,1]=ini_read_string(planet,"distance_to_sun","");
data[i,2]=ini_read_string(planet,"year_length","");
data[i,3]=ini_read_string(planet,"mass","");
data[i,4]=ini_read_string(planet,"escape_velocity","");
data[i,5]=ini_read_string(planet,"max_temp","");
data[i,6]=ini_read_string(planet,"min_temp","");
}
ini_close();//close when done
Step Event:
execute code:

if (keyboard_check_released(vk_left))  {current-=1;} 
if (keyboard_check_released(vk_right))  {current+=1;} 

if current==-1 current=planets-1;
if current==planets current=0;
Draw Event:
execute code:

draw_text(20,20,"Planet Name:"+data[current,0]);
draw_text(20,40,"Distance To Sun:"+data[current,1]);
draw_text(20,60,"Year Length:"+data[current,2]);
draw_text(20,80,"Planet Mass:"+data[current,3]);
draw_text(20,100,"Escape Velocity:"+data[current,4]);
draw_text(20,120,"Max Temp:"+data[current,5]);
draw_text(20,140,"Min Temp:"+data[current,6]);

No comments:

The Win Machine

The Road to Hell is Paved with Intervention ͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏    ...

Contact Form

Name

Email *

Message *