Two newbie questions (window edge, and Behaviours)
G'day everyone! First post here, but I've been tinkering with TGF and MMF demos off and on over the last couple of years. Still at a very newbie level of understanding though...
I'm trying to make a simple side-scrolling game with eight-directional movement. I'm using a simple custom movement adapted from Jenkins J. Rutherford's example on The Daily Click. I've only used the parts of the code for left and right, and adapted them for up and down also. It works great, with perfect collision detection and none of that annoying bouncing or sticking (and no fastloops, which I don't understand yet).
However, I've run into two problems:
1. I can't stop the player at the edge of the window. I don't want them to be able to leave the screen, but since the custom movement uses Static movement, I can't use the 'Stop movement' action or anything like that. Is there an easy solution to this?
(I thought of placing Active Objects around the edges and making them scroll with the screen, and then testing for collisions using the same code I use for testing obstacle backgrounds, so that they act as barriers. But see below...)
2. Is there a way to perform actions involving Qualifier groups in the Behaviour code? My custom movement code is in the player object's Behaviour, not the Event Editor. I want to test for collisions with Active Objects (like enemies, or the scroll barriers) by assigning them all to Group.Neutral and just testing for collisions with that group. The trouble is, I can't seem to use groups in the Behaviour section, only individual objects. This would mean I would have to write collision tests for every single type of barrier and enemy. Is there a way around this?
Thanks for any help you can give me...
Re: Two newbie questions (window edge, and Behaviours)
Welcome to the forums!
Quote:
1. I can't stop the player at the edge of the window. I don't want them to be able to leave the screen, but since the custom movement uses Static movement, I can't use the 'Stop movement' action or anything like that. Is there an easy solution to this?
(I thought of placing Active Objects around the edges and making them scroll with the screen, and then testing for collisions using the same code I use for testing obstacle backgrounds, so that they act as barriers. But see below...)
1. Try doing:
+ Test position (left,right,up,down)
- The same action as when the player collides with the active
Quote:
2. Is there a way to perform actions involving Qualifier groups in the Behaviour code? My custom movement code is in the player object's Behaviour, not the Event Editor. I want to test for collisions with Active Objects (like enemies, or the scroll barriers) by assigning them all to Group.Neutral and just testing for collisions with that group. The trouble is, I can't seem to use groups in the Behaviour section, only individual objects. This would mean I would have to write collision tests for every single type of barrier and enemy. Is there a way around this?
2. Not sure about that one, but I would be interested to know as I have had this problem.
Hope this helps!
Re: Two newbie questions (window edge, and Behavio
Thanks for the prompt reply Game_Master. :) I've tried the 'test position' action, but it seems to work on the frame (playfield), rather than the window.
However, you did get me thinking, and I've tried making the player object compare its X and Y positions relative to the X and Y of the various window edges. Now it only shifts position if its X is greater than the X of the left edge and less than the right, etc, in addition to not overlapping a background obstacle. It works! :D
(Well, it slightly overlaps the edges of the window because it measures the X and Y coordinates from the hotspot, which I've put in the centre. But I think that's actually better, as it gives the player a little more freedom of movement, rather than an 'all your limbs must remain inside the window at all times' kind of thing... )
Incidentally this means I don't have to worry quite so much about the Qualifiers in the Behaviour, as I won't have to add code for collisions between four window-enclosing barriers.
...but of course I've immediately struck another, unrelated problem :eek:
Originally, I had the player object keep up with the scrolling window like this: always set 'X player object' to 'X player object'+1. After browsing the forums I realised that I didn't need to do this--I could just uncheck 'follow the frame' instead. (...which I used to think meant 'follow the window', but of course it means the opposite... :crazy: )
However, by unchecking 'follow the frame', my lovely little custom movement suddenly can't cope with obstacle background collisions. Now collision detection only works when I'm pressing a direction key. If I don't touch anything, the player object slides right through the obstacles. Good grief. I wonder why?
Edit: Whoops, actually that's not quite right. Collision detection on the obstacles doesn't work when they run into the player object due to the scrolling, whether I'm pressing a key or not. As soon as the scrolling stops, the detection works. I guess this is because I've told the player object to stop when it hits an obstacle but not to be pushed backwards by that obstacle. Maybe I should go back to my original scrolling method after all.