I wanted to make a game. And I wanted it to be original. So by just thinking about some of my previous games and other random stuff that drifted through my mind I came up with this idea somehow.
The basic idea is pretty simple. Every screen is a closed room and is divided into X squares (views). All are visible at once and are fixed. Now, the character can jump and stuff and interact with creatures and objects. But for all the squares excpet the one the character is in, time is frozen. Which means that all the objects and creatures there just freeze, then being restored and resuming all actions when they are unfrozen. Or, time is frozen only in the current square. Or, time freezes/unfreezes in all squares the character enters. Or... yeah, you get the idea. Anyway, this would make some very interest puzzling possibilities. I think. Because I haven't come up with any yet. Because I have been busy trying to get the basics to work.
Everything seems to work except that the creatures are frozen or unfrozen all the time, not caring about views. I know where the fault is, but can not really figure out why or how I can fix it.
Did I mention I use Game Maker? Well it's pretty simple, so you should have no problem understanding if you have basic programming knowledge. The following results in the monster being permanently frozen:
Information about object: char
Sprite: CHAR
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>
Create Event:
set variable view to 4 //starting view
Step Event:
set variable view to 28 //after subtracting all views it is outside of it will have the value of the current view number
Keyboard Event for <Left> Key:
jump relative to position (-5,0)
Keyboard Event for <Up> Key:
jump relative to position (0,-5)
Keyboard Event for <Right> Key:
jump relative to position (5,0)
Keyboard Event for <Down> Key:
jump relative to position (0,5)
Mouse Event for Glob Left Pressed:
restart the game
Other Event: Outside View 0:
set variable view relative to -0 //just for the sake of it
Other Event: Outside View 1:
set variable view relative to -1
Other Event: Outside View 2:
set variable view relative to -2
Other Event: Outside View 3:
set variable view relative to -3
Other Event: Outside View 4:
set variable view relative to -4
Other Event: Outside View 5:
set variable view relative to -5
Other Event: Outside View 6:
set variable view relative to -6
Other Event: Outside View 7:
set variable view relative to -7
Information about object: mon
Sprite: MON
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>
Create Event:
set variable view to 4 //starting view, although it will not change view
set variable freeze to 0
set variable unfreeze to 0
set variable frozen to 0
set the gravity to 0.1 in direction 270 //gm is weird, 270 is down
set the vertical speed to -5 //will jump
Step Event:
if freeze is equal to 1 //if it is about to gain frozen status
set variable frozen to 1 //make it frozen
set variable freeze to 0
if unfreeze is equal to 1 //if about to remove frozen status
set variable frozen to 0 //make it unfrozen
set variable unfreeze to 0
if view is not equal to char.view //if they are in different squares (if this is inverted it will remain unfrozen instead)
if frozen is equal to 0 //(if this is inverted it will remain unfrozen instead)
set variable freeze to 1 //it will become frozen next step
else
set variable freeze to 0
else
if frozen is equal to 1
set variable unfreeze to 1 //will become unfrozen next step
if freeze is equal to 1
set variable _vspeed to vspeed //storing the variable
set variable vspeed to 0
set the gravity to 0 in direction 270
if unfreeze is equal to 1
set variable vspeed to _vspeed //loading the variable
set the gravity to 0.1 in direction 270
if frozen is equal to 1
exit this event
set variable view to 28 //after subtracting all views it is outside of it will have the value of the current view number
Collision Event with object wall:
if frozen is equal to 1
exit this event
set the vertical speed to -5 //this will make it constantly jump if unfrozen
Other Event: Outside View 0:
if frozen is equal to 1
exit this event
set variable view relative to -0 //just for the sake of it
Other Event: Outside View 1:
if frozen is equal to 1
exit this event
set variable view relative to -1
Other Event: Outside View 2:
if frozen is equal to 1
exit this event
set variable view relative to -2
Other Event: Outside View 3:
if frozen is equal to 1
exit this event
set variable view relative to -3
Other Event: Outside View 4:
if frozen is equal to 1
exit this event
set variable view relative to -4
Other Event: Outside View 5:
if frozen is equal to 1
exit this event
set variable view relative to -5
Other Event: Outside View 6:
if frozen is equal to 1
exit this event
set variable view relative to -6
Other Event: Outside View 7:
if frozen is equal to 1
exit this event
set variable view relative to -7
So, can anyone tell me what I missed/did wrong? It seems it's something with the if view is not equal to char.view and the following if frozen is equal to 0, or the whole block.
Oh and ofcourse the source file so you can play around with it!
http://www.mediafire.com/?wzudyryntgkMany thanks, any answer will be appreciated.