Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Pages: [1]   Go Down

Author Topic: I dont get it T_T, why?  (Read 2213 times)

0 Members and 1 Guest are viewing this topic.

Zhello

N.A.D.I.
I dont get it T_T, why?
« on: March 06, 2011, 07:15:21 pm »
  • L'homme avec beaucoup de noms.
  • *
  • Reputation: +6/-1
  • Offline Offline
  • Gender: Male
  • Posts: 925
Well I did not see this one until now.  When the player is able to find a key and open a door, for example, objLockedDoor2.  Now this is where the problems come in,  when I am re-entering the same room, the doors reappear in the same spot.

I had this code up and modified a while back on yoyogames and decided to use it, it is good but the only prob is the
(For anyone that needs this code you can use it, when it has been resolved)


objLockedDoor2 -- Persistent
Create
Code: [Select]
r=room
got=0
if room!=r{
    visible=0
    mask_index=sprInvis
}
else if room=r && !undoor2{
    visible=1
    mask_index=sprite_index
}
draw_y=0
if undoor2{
    instance_destroy()
}
image_speed=0
draw_y=-4
Alarm[0]
Code: [Select]
visible=0
solid=false
mask_index=sprInvis
instance_destroy()
Step
Code: [Select]
if room!=r && visible{
    
}
else if room=r && !undoor2 && !visible{
    visible=1
    mask_index=sprite_index
}
// part 2
 if place_meeting(x,y+6,objLink){
    if global.keys>=1 && solid{
        sound_play(Open)
        sound_play(Item)
        solid=0
        global.keys-=1
        undoor2=1
        sprite_index=sprAppear
        image_speed=0.3
        alarm[0]=15
    }
}
if sprite_index=sprAppear{
    if draw_y>-8{
        draw_y-=1
    }
}
Draw
Code: [Select]
draw_sprite(sprite_index,image_index,x,y)
if sprite_index=sprSmoke2{
    draw_sprite(sprKey,-18,x,y+draw_y)
}
Room_Start
Code: [Select]
if room!=r{
    visible=0
    mask_index=sprInvis
}
else if room=r && !undoor2{
    visible=1
    mask_index=sprite_index
}

My aim:  Trying to have a door object, that stays open, also  I do not need to make more of the same object to place in each room I have, let alone the only room I am currently using to add/fix objects.
« Last Edit: March 07, 2011, 02:56:29 am by Linkwolf48 »
Logged
The IT Guy
Intermediate Coder
Linux is a wonderful thing
~Linkwolf48/Gumstone1080~

The Legend of Zelda - New Beginnings

http://zfgc.com/forum/index.php?topic=34986.0
1.6 Demo -
https://www.dropbox.com/s/56km0iadaras56g/LoZNB%20Game%20Folder.rar?dl=0


Side Projects:

Dragon Diary - Cybernetic Threat
Story: http://wiki.zfgc.com/Cybernetic_Threat

Quote
Aero88
ZFGC is like the Hotel California.  You can come in but you can never leave!

devianart: http://linkwolf48.deviantart.com/
Re: I dont get it T_T, why?
« Reply #1 on: March 07, 2011, 12:38:27 am »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 2245
The code looks a bit of a mess. You may want to change your method though instead of using persistent objects if you plan on adding a save feature that doesn't use GMs built in save feature.
Logged

Zhello

N.A.D.I.
Re: I dont get it T_T, why?
« Reply #2 on: March 07, 2011, 02:55:16 am »
  • L'homme avec beaucoup de noms.
  • *
  • Reputation: +6/-1
  • Offline Offline
  • Gender: Male
  • Posts: 925
The code looks a bit of a mess. You may want to change your method though instead of using persistent objects if you plan on adding a save feature that doesn't use GMs built in save feature.

I tried using globals just now, that seem to be a lot messier and memory filling, about what you said, I am not sure what you mean by the save feature.
Logged
The IT Guy
Intermediate Coder
Linux is a wonderful thing
~Linkwolf48/Gumstone1080~

The Legend of Zelda - New Beginnings

http://zfgc.com/forum/index.php?topic=34986.0
1.6 Demo -
https://www.dropbox.com/s/56km0iadaras56g/LoZNB%20Game%20Folder.rar?dl=0


Side Projects:

Dragon Diary - Cybernetic Threat
Story: http://wiki.zfgc.com/Cybernetic_Threat

Quote
Aero88
ZFGC is like the Hotel California.  You can come in but you can never leave!

devianart: http://linkwolf48.deviantart.com/

Mamoruanime

@Mamoruanime
Re: I dont get it T_T, why?
« Reply #3 on: March 07, 2011, 03:01:59 am »
  • ^Not actually me.
  • *
  • Reputation: +9/-0
  • Offline Offline
  • Gender: Male
  • Posts: 9786
The code looks a bit of a mess. You may want to change your method though instead of using persistent objects if you plan on adding a save feature that doesn't use GMs built in save feature.

I tried using globals just now, that seem to be a lot messier and memory filling, about what you said, I am not sure what you mean by the save feature.

It's funny you should say "memory filling", considering GM dumps all of your source to memory to run it :P GM in itself is memory filling...

Anyway; GM's save feature IIRC just saves a memory state of the application. You're better off looking into reading and writing to streams.
Logged

Zhello

N.A.D.I.
Re: I dont get it T_T, why?
« Reply #4 on: March 07, 2011, 03:24:59 am »
  • L'homme avec beaucoup de noms.
  • *
  • Reputation: +6/-1
  • Offline Offline
  • Gender: Male
  • Posts: 925
Memory filling indeed.
@Windy
I am going to remake the code from scratch and see what that gives me and take what you said into consideration.
Ill post the new code up as well.

EDIT:

I managed to fix it and I used your suggestion windy,  as for the memory filling part, what I did before with globals, I just made the same object over and over.

All it needs now is a little sprite work, and getting the animations to play right.
« Last Edit: March 08, 2011, 09:35:24 pm by Linkwolf48 »
Logged
The IT Guy
Intermediate Coder
Linux is a wonderful thing
~Linkwolf48/Gumstone1080~

The Legend of Zelda - New Beginnings

http://zfgc.com/forum/index.php?topic=34986.0
1.6 Demo -
https://www.dropbox.com/s/56km0iadaras56g/LoZNB%20Game%20Folder.rar?dl=0


Side Projects:

Dragon Diary - Cybernetic Threat
Story: http://wiki.zfgc.com/Cybernetic_Threat

Quote
Aero88
ZFGC is like the Hotel California.  You can come in but you can never leave!

devianart: http://linkwolf48.deviantart.com/
Re: I dont get it T_T, why?
« Reply #5 on: March 07, 2011, 09:56:09 am »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 2245
Generally the best way is to have a global array that stores anything that you want to persist within the game world. This makes it easier to load as you can iterate through each value. Also if you have access to constants (< 7 or 8 pro) you can use those instead of integers as it will make it easier to know what it's for.  Alternatively if you don't have access have a file containing the number used for the index and what it's for.  Also try to use a naming scheme to make it easier to find like ROOM_OBJECT_NUMBER.  To avoid having to create duplicate doors consider using instance code for each door that will store the index of the element in the array which you can then access to find out if it's already been unlocked.
Logged
Pages: [1]   Go Up

 


Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Page created in 0.049 seconds with 47 queries.