Project:Sandbox

Notes:Hikaru

Subpages
GENERAL INFORMATION ABOUT: Hikaru is a platform-adventure video game developed in the Game Maker Studio Engine running completely in the Scripting Language, Game Maker Language (GML).
 * Believe it or not, Mighty Atom gave me inspiration to work on this Project, I can't get enough of it >.<

PLATFORMS: Microsoft Windows, OS X LINUX, Android (Upon paying for the Professional Version of Game Maker Studio, I was able to port the game over to Android.)

CODE: (For Student and Teacher)

Text Format
ROOM DATA FORMAT:

SETTINGS Width: 640 Height: 480 Speed: 60 (60 FPS) Persistent? (NO)

(Not all of these are used anymore) ??? (1 byte) ??? (1 byte) Music ID (1 byte) Music ??? [Seems to have some effect on instruments] (1 byte) Background toggle variable (1 byte) Background ??? variable (1 byte) Background X & Y offsets (1 byte) Foreground X & Y offsets (1 byte) Dark object palette toggle (1 byte) ??? (1 byte) ??? (1 byte) Object to create at spawn point (2 bytes) ??? (1 byte) ??? (1 byte) ??? (1 byte) ??? (1 byte)

BASIC ROOM GRAPHICS DATA: Tileset - 256x256 OVER 16X16 2X4

IMPORTANT INFORMATION ABOUT DOOR WARPS The layering of the Door is created with a mask (obj_door_mask) with a creation code of "can=1". This is placed into a room, these are controlled by ID's, for example... "if global.game_progress<2 room_id=2 else room_id=4" This will send you to a room with a Door that is indicated with "room_id=3" These vary when changing to different rooms/doors

THE CREATION OF HIKARU Hikaru was one of the most time consuming aspects of design and frankly the largest object in terms of size in the game, but I suppose it turned out okay, below is Hikaru's source code.

CREATION: CODE DOCUMENT 1: image_speed=0 view_xaccelerate=0 hacc=0.2 maxhspeed=3 hspd=0 xscale=1 jump_max=38 jump=0 jumpspd=4 wxoffset=6 wyoffset=2 wangle=0 grav=.24 inwater=1 launch=1 empty=1 bubbles=2 can_bubble=1 aird=1 hit=0 damage=0 xp=0 drawing=1 player_bump=0 face_chating=0 checking=0 jumped=1 can_jump=1 alarming=0 acid_touch=0

//for water_room if room=water_room{if global.room_id_2!=3 xscale=-1}

DESTROY: CODE DOCUMENT 1: if global.death_type=1 { if place_meeting(x,y+1,Block) repeat(18)instance_create(x,y,obj_puff_effect_up) else repeat(18)instance_create(x,y,obj_puff_effect) }

ALARM 0: CODE DOCUMENT 1: if (sprite_index=player_walk or sprite_index=player_up) && image_speed>0 && gravity=0 && global.fading=0 { sound_play(footstep) alarm[0]=10 }

ALARM 1: CODE DOCUMENT 1: launch=1

ALARM 2: CODE DOCUMENT 1: empty=1

ALARM 3: CODE DOCUMENT 1: if global.weapon=2 and bubbles=1{bubbles=2 with(hud)weapon[2,3]+=1}

ALARM 4: CODE DOCUMENT 1: if global.weapon=2 and bubbles=1{bubbles=2 with(hud)weapon[2,3]+=1}

ALARM 5: CODE DOCUMENT 1: aird=1

ALARM 6: CODE DOCUMENT 1: can_bubble=1

ALARM 10: CODE DOCUMENT 1: draw_xp

ALARM 11: CODE DOCUMENT 1: draw_damage

STEP CODE DOCUMENT 1: if xscale=1 vxoffset=-150 if xscale=-1 vxoffset=-500 if keyboard_check_released(vk_up) && sprite_index=player_up && global.fading=0 sprite_index=player_walk if keyboard_check_released(vk_down) && sprite_index=player_down && place_free(x,y+2) && global.fading=0 sprite_index=player_walk if keyboard_check_pressed(vk_up) && global.fading=0 sprite_index=player_up if keyboard_check(vk_down)&& place_free(x,y+2) && global.fading=0 sprite_index=player_down if keyboard_check_pressed(vk_down) && !place_free(x,y+2) && global.fading=0 { if sprite_index!=player_down && !keyboard_check(vk_right) && !keyboard_check(vk_left) { if instance_exists(obj_door_mask) if collision_point(x,y,obj_door_mask,0,0) && obj_door_mask.can=1 {with(obj_fade_line)instance_destroy with(obj_fade)instance_destroy next=instance_create(x,y,fade_create) next.alarm[1]=145 if global.game_progress<3 {sound_play(open_door) obj_door_opened.visible=1}} else { if face_chating!=1 instance_create(x,y-6,popup) } sprite_index=player_down } }

if global.viewing=1 and global.fading=0 { if view_xview!=x+vxoffset { xacc=(hspd*4+xscale)/6 if view_xview+((x+vxoffset)-view_xview)/240+xacc>0 && view_xview+((x+vxoffset)-view_xview)/240+xaccx+vxoffset && view_xview+x+vxoffset>0 && view_xview+x+vxoffset>room_width-view_wview+vxoffset view_xview=x+vxoffset if xscale=-1 && view_xview0 && view_xview+x+vxoffset>room_width-view_wview+vxoffset view_xview=x+vxoffset } } }

if keyboard_check(vk_left) && global.fading=0 { if sprite_index=player_down && gravity=0 && !place_free(x,y+2) sprite_index=player_walk xscale=-1 if sprite_index!=player_down image_speed=0.2 if alarm[0]=-1 alarm[0]=10 if !place_meeting(x+hspd,y,Block) && !place_meeting(x+hspd,y,Block2){if hspd>-maxhspeed hspd-=hacc} } if keyboard_check(vk_right) && global.fading=0 { if sprite_index=player_down && gravity=0 && !place_free(x,y+2) sprite_index=player_walk xscale=1 if sprite_index!=player_down image_speed=0.2 if alarm[0]=-1 alarm[0]=10 if !place_meeting(x+hspd,y,Block) && !place_meeting(x+hspd,y,Block2){if hspdhacc*4 hspd-=hacc*4 else if hspd<-hacc*4 hspd+=hacc*4 else {hspd=0} } } if vspeed=0 && gravity=0 && hspd!=0 else {if !place_meeting(x+hspd,y,Block)x+=hspd else{x-=hspd hspd=0}} if keyboard_check_pressed(ord('Z')) && gravity=0 && jump0 && can_jump=1 {vspeed=-jumpspd if sprite_index=player_down && gravity=0 && !place_free(x,y+2) sprite_index=player_walk} if keyboard_check_released(ord('Z')) && global.fading=0 && vspeed=-4 or jump>=jump_max {gravity=grav jumped-=1}

if !keyboard_check(ord('Z')) and gravity=0{jumped=1}

if vspeed<0 jump+=2 if gravity=0 && !place_free(x,y+4) { hacc=0.4 maxhspeed=3 } if gravity>0 or !place_free(x,y+4) { hacc=0.1 maxhspeed=3

} if place_free(x,y+2) && gravity=0 && vspeed>=0 gravity=.20 if sprite_index=player_down { image_speed=0 if !place_free(x,y+4) image_index=1 if gravity!=0 or vspeed!=0 or place_free(x,y+2) image_index=0 } if collision_point(x,y+10,water_mark,0,0) or acid_touch=1 { if vspeed>0 and inwater=1{sound_play(water_splash) part_emitter_region(global.ps,global.emitter,player.x,player.x,player.y,player.y,ps_shape_line,ps_distr_linear)part_emitter_burst (global.ps,global.emitter,global.wat,8)inwater=0 } hacc=0.2 maxhspeed=1 jump_max=24 jumpspd=2 grav=.10 if vspeed>4 vspeed=4 } if !collision_point(x,y,water_mark,0,0) && acid_touch=0 { hacc=0.2 maxhspeed=3 jump_max=38 jumpspd=4 grav=.20 inwater=1 }

if hspd>maxhspeed hspd=maxhspeed if hspd<-maxhspeed hspd=-maxhspeed

if global.fading>0 and global.fading<4 and face_chating=0 and instance_number(fade_create)=0 {hacc=0 hspeed=0 hspd=0 sprite_index=player_walk} if keyboard_check(vk_right) && keyboard_check(vk_left) and global.fading=0{if hspd<0 hspd+=0.2 if hspd>0 hspd-=0.2}

if global.fading>0 && room=start{if gravity=0 && !place_free(x,y+2){if hspd=0 {image_index=0 image_speed=0} else image_speed=0.2}}

if instance_exists(Balrog_fly) x=Balrog_fly.x+16

CODE DOCUMENT 2: if sprite_index=player_up { wangle=90 wxoffset=2 if image_speed=0 wyoffset=-6 if image_index>0-image_speed wyoffset=-6 if image_index>0.5-image_speed wyoffset=-8 if image_index>1.5-image_speed wyoffset=-6 if image_index>2.5-image_speed wyoffset=-8 } if sprite_index=player_walk { wangle=0 wxoffset=6 if image_speed=0 wyoffset=2 if image_index>0-image_speed wyoffset=2 if image_index>0.5-image_speed wyoffset=0 if image_index>1.5-image_speed wyoffset=2 if image_index>2.5-image_speed wyoffset=0 }

if sprite_index=player_down { if image_index=0 { wxoffset=6 wyoffset=2 wangle=270 } if image_index=1 { wangle=0 wxoffset=6 wyoffset=2 } }

acid_touch=0 face_chating=0

CODE DOCUMENT 3: if sprite_index=player_walk and xscale=1{global.direct=1} if sprite_index=player_walk and xscale=-1{global.direct=2} if sprite_index=player_down and image_index=0{global.direct=3} if sprite_index=player_up{global.direct=4}

CODE DOCUMENT 4: //Weapons script 1 [SINGLE-SHOT] if global.fading=0 if keyboard_check_pressed(ord('X')) { if sprite_index=player_down && gravity=0 && !place_free(x,y+2) sprite_index=player_walk xx=0 yy=0 if sprite_index=player_walk { xx=30*xscale yy=1 } if sprite_index=player_up { xx=1*xscale yy=-30 } if sprite_index=player_down { xx=1*xscale yy=30 } //Polar Star - Level 1 / Level 2 / Level 3 if global.weapon=0 {instance_create(x,y,obj_Polar) star_effect}

//Missle Launcher - Level 1 / Level 2 / Level 3 if global.weapon=1 and launch=1 and hud.weapon[1,3]>0 {if hud.weapon[1,1]>2 repeat(3)instance_create(x,y,obj_missle) else instance_create(x,y,obj_missle) star_effect launch=0 alarm[1]=30 with(hud)weapon[1,3]-=1} else {if global.weapon=1 and hud.weapon[1,3]=0 and empty=1 {instance_create(x,y,obj_empty) sound_play(weapon_empty) empty=0 alarm[2]=35} } if instance_number(obj_missle)=0{launch=1 alarm[1]=-10}

//Bubble Gun - Level 1 if hud.weapon[2,1]=1 { if global.weapon=2 and hud.weapon[2,3]>0 {instance_create(x,y,obj_bubble) star_effect} else {if global.weapon=2 and hud.weapon[2,3]=0 and empty=1 {instance_create(x,y,obj_empty) sound_play(weapon_empty) empty=0 alarm[2]=35} }

if global.weapon=2 {if hud.weapon[2,3]>0{with(hud)weapon[2,3]-=1 bubbles=0 if alarm[3]>0 {alarm[3]=30 alarm[4]=0} if alarm[4]>0 {alarm[4]=15}} {if bubbles=0 and hud.weapon[2,3]<100{bubbles=1 alarm[3]=30} } } } } if hud.weapon[2,1]=1 and bubbles=2 and hud.weapon[2,3]<100 and global.fading=0{bubbles=1 alarm[4]=15}

CODE DOCUMENT 5: //Weapons script 2 [MULTI-SHOTS] if global.fading=0 if keyboard_check(ord('X')) { //Bubble Gun - Level 2 / Level 3 if hud.weapon[2,1]>1 { if global.weapon=2 and can_bubble=1 and hud.weapon[2,3]>0 {instance_create(x,y,obj_bubble) star_effect alarm[6]=10 if sprite_index=player_down && gravity=0 && !place_free(x,y+2) sprite_index=player_walk xx=0 yy=0 if sprite_index=player_walk { xx=30*xscale yy=1 } if sprite_index=player_up { xx=1*xscale yy=-30 } if sprite_index=player_down { xx=1*xscale yy=30 }} else {if global.weapon=2 and hud.weapon[2,3]=0 and empty=1 {instance_create(x,y,obj_empty) sound_play(weapon_empty) empty=0 alarm[2]=35} }

if global.weapon=2 {if hud.weapon[2,3]>0 and can_bubble=1{with(hud)weapon[2,3]-=1 can_bubble=0 alarm[3]=4} } } } if !keyboard_check(ord('X')) and hud.weapon[2,1]>1 and bubbles=2 and hud.weapon[2,3]<100 and global.fading=0{bubbles=1 alarm[3]=4} if !keyboard_check(ord('X')) and hud.weapon[2,1]>1 and bubbles=2 and hud.weapon[2,3]<100 and global.fading=0{bubbles=1 alarm[4]=4} if keyboard_check_released(ord('X')) or global.fading>0 {if instance_exists(obj_bubble) if obj_bubble.sprite_index=bubble_lv3 sound_play(snd_bubble_throw) with(obj_bubble){ if sprite_index=bubble_lv3 { alarm[1]=-1 hspeed=0 vspeed=-0.1 friction=-0.1 if pop=1 {image_index=0 pop=0} sprite_index=missle_trail_2 image_speed=0.25 depth=-17 instance_create(x,y,obj_bubble_bullet) }}if instance_exists(obj_bubble) if obj_bubble.sprite_index=bubble_lv3 sound_play(snd_bubble_throw)}

BEGIN STEP CODE DOCUMENT 1:

if place_meeting(x,y-4+vspeed,Block) or place_meeting(x,y-4+vspeed,Block2) && vspeed<0 { sound_play(bump) y+=2+vspeed vspeed=0 gravity=grav } if place_meeting(x,y+2+vspeed,Block) or place_meeting(x,y+2+vspeed,Block2)&& vspeed!=0 && vspeed>0 && gravity!=0 { if sprite_index=player_down sprite_index=player_walk vspeed=0 gravity=0 jump=0 contact_solid(6) }

if place_meeting(x,y-10,obj_press){ ID=instance_create(x,y,obj_damage) ID.damage=127 global.hp-=127}

END STEP: CODE DOCUMENT 1: if alarm[5]=0 && global.player_dead=0 {global.air100=100 with(obj_AIR_100){alarm[0]=5 alarm[1]=10 alarm[2]=15 alarm[3]=20 alarm[4]=25}}

if hit=1{with(hud)alarm[0]=50 with(obj_player_hit){affect=1} player_bump=1 hit=2}

if player_bump=1{vspeed=-2.2 gravity=0.10 sound_play(player_hit) player_bump=0} //Bumping when player got hit.

if player_bump=4{vspeed=-2.2 gravity=0.10 player_bump=0} //Bumping when chating.

COLLISION WITH > water_mark CODE DOCUMENT 1: if aird=1 { if global.air100>0{global.air100-=1} alarm[5]=10 aird=0}

obj_AIR_100.visible=true obj_AIR.visible=true

COLLISION WITH > obj_door_mask CODE DOCUMENT 1: if global.fading=2 { if other.room_id=1 {room_goto(start)} if other.room_id=2 {room_goto(machine_room)} if other.room_id=3 {room_goto(sand_room)} if other.room_id=4 {room_goto(machine_room2)} if other.room_id=5 {room_goto(cave_room)} if other.room_id=6 {room_goto(water_room)} global.fading=3 hud.alarm[3]=145 global.next_room=1 }

COLLISION WITH > items_mark CODE DOCUMENT 1: face_chating=1

if keyboard_check_pressed(vk_down) && !place_free(x,y+2) && global.fading=0 && other.can=1 { if !keyboard_check(vk_right) && !keyboard_check(vk_left) run_chat(other.current_chat) }

COLLISION WITH > laser_ball CODE DOCUMENT 1: if hit=0 and global.fading=0{global.hp-=12 damage+=12 hud.weapon[global.weapon,2]-=12 alarm[11]=30 hit=1}

COLLISION WITH > obj_shock_ball CODE DOCUMENT 1: if hit=0 and global.fading=0{global.hp-=6 damage+=6 hud.weapon[global.weapon,2]-=6 alarm[11]=30 hit=1}

COLLISION WITH > obj_knight_boss CODE DOCUMENT 1: if hit=0 and global.fading=0 and other.dead=0{global.hp-=2 damage+=2 hud.weapon[global.weapon,2]-=2 alarm[11]=30 hit=1}

COLLISION WITH > obj_Polar_enemy CODE DOCUMENT 1: if hit=0 and global.fading=0{global.hp-=other.weapon_dmg damage+=other.weapon_dmg hud.weapon[global.weapon,2]-=other.weapon_dmg alarm[11]=30 hit=1}

COLLISION WITH > obj_timer CODE DOCUMENT 1: face_chating=1

if keyboard_check_pressed(vk_down) && !place_free(x,y+1) && global.fading=0 && other.can=1 { if !keyboard_check(vk_right) && !keyboard_check(vk_left) {other.can=0 sound_play(chest_sound) items_mark.current_chat=4 run_chat(3)} }

COLLISION WITH > obj_life CODE DOCUMENT 1: face_chating=1

if other.visible=1 { if keyboard_check_pressed(vk_down) && !place_free(x,y+2) && global.fading=0 { if !keyboard_check(vk_right) && !keyboard_check(vk_left) run_chat(100) } }

COLLISION WITH > obj_save CODE DOCUMENT 1: face_chating=1

if other.visible=1 { if keyboard_check_pressed(vk_down) && !place_free(x,y+2) && global.fading=0 { if !keyboard_check(vk_right) && !keyboard_check(vk_left) run_chat(200) } }

COLLISION WITH > obj_bat CODE DOCUMENT 1: if hit=0 and global.fading=0{global.hp-=2 damage+=2 hud.weapon[global.weapon,2]-=2 alarm[11]=30 hit=1}

COLLISION WITH > Block2 CODE DOCUMENT 1: if !place_free(x,y-1)vspeed=0 if !place_free(x-1,y) or !place_free(x+1,y) hspd=0

COLLISION WITH > objAcidWater CODE DOCUMENT 1: if aird=1 { if global.air100>0{global.air100-=1} alarm[5]=10 aird=0}

obj_AIR_100.visible=true obj_AIR.visible=true

acid_touch=1

hacc=0.1 maxhspeed=0.5 jump_max=12 jumpspd=1 grav=.05 if vspeed>2 vspeed=2

COLLISION WITH > obj_bat2 CODE DOCUMENT 1: if hit=0 and global.fading=0{global.hp-=2 damage+=2 hud.weapon[global.weapon,2]-=2 alarm[11]=30 hit=1}

IF THE PLAYER IS OUTSIDE ROOM > DESTROY THE PLAYER

DRAW EVENT CODE DOCUMENT 1: if drawing=1{ if global.fading=0 or global.fading=2{draw_sprite_ext(spr_weapons,global.weapon,x+(wxoffset*xscale),round(y)+wyoffset,xscale,1,wangle*xscale,image_blend,image_alpha)} draw_sprite_ext(sprite_index,image_index,round(x),round(y),xscale,1,0,image_blend,image_alpha)}

That pretty much does it for the Player object.