Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411430 Posts in 69363 Topics- by 58416 Members - Latest Member: JamesAGreen

April 19, 2024, 11:12:36 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Game Maker for Beginners: Part III
Pages: 1 ... 7 8 [9] 10
Print
Author Topic: Game Maker for Beginners: Part III  (Read 128986 times)
daftpunk34
Level 0
*


View Profile
« Reply #160 on: March 24, 2011, 07:40:11 PM »

alright! time to noob this post UP! but...could i see the first post of this? yeah...
 Gentleman mentlegen?
Logged

Pencerkoff
CCCP
Level 4
*


Hello I am Pencerkoff


View Profile
« Reply #161 on: March 25, 2011, 01:35:33 PM »

Hello this is Pencerkoff

alright! time to noob this post UP! but...could i see the first post of this? yeah...
 Gentleman mentlegen?

First post has a link to the 2nd thread, which in turn links to the first thread.

-PENCERKOFF
Logged

PogueSquadron
Level 1
*



View Profile WWW
« Reply #162 on: December 09, 2012, 03:27:27 PM »

Sorry to bump this thread but I figured I'd ask because maybe other people are having the same problem.

I'm making a similar little game that scrolls vertically, and have put in code to deactivate objects outside the view (and activate them in the view). When I shoot over and over again, I still destroy objects outside my view. I made a test of several enemy 'blocks' that should disappear upon collision with the bullet. I fired like crazy, and as the blocks appear, all the ones I shot off screen are now gone. Couldn't this be problematic, such as when I want an enemy to fire at me only when its on screen?

Should I place in some code that tells the game to destroy my game to destroy the instance at a certain point? Or similarly, if I want an enemy to fire at me, have him ONLY fire at me when it is below view_yview[0]?

I'm sure in some games I'd want my bullets to stop at the view, but in other instances, I'd like to be able to shoot off screen (like Samus shooting a door that she hasn't quite reached yet). Is that even possible? To tell Game Maker "I'd like this bullet to go a little beyond the boundaries of my view for a little leeway, and then destroy itself" ? It sounds like it makes sense to me, and I'll do a little test after dinner.

Could someone clarify about what activating/deactivating instances actually means? The instance seems to still exist outside the view, unless I'm entering the code incorrectly. Do all the collisions still take place outside the view, but they just don't 'draw' themselves until they reach the view? I could kind of see my block test 'loading' itself as it came on screen, as though the game was simply drawing them up as they scrolled downwards.
Logged
JDM
Level 0
***


Quattro Bajeena


View Profile WWW
« Reply #163 on: December 10, 2012, 12:34:42 AM »

Hi PogueSquadron! 

Just a suggestion, but you might try telling your objects, when they get shot, to only take damage (and fire) if they're on screen.  For example:

Code:
if (x <= view_xview[0] + view_view)
{
instance_destroy()
}

I'd probably extend the active objects range a few dozen pixels past the view window, too,

In such a scenario, you could maybe have player bullets destroy themselves right before passing the border of the active object area (when doing this tutorial when I was getting started, I was frustrated by the bullets that would suddenly reappear when I caught up with them) or only do damage to enemies when actually onscreen or some work around like that.

Hope that's helpful.  If I missed what you're looking for, feel free to let me know, and I'll try to think it through better.
Logged

PogueSquadron
Level 1
*



View Profile WWW
« Reply #164 on: December 10, 2012, 01:27:12 PM »

I think I may have entered my code incorrectly. It should be fairly easy to tell my bullets to do an "instance_destroy()" when Y is less than view_yview[0]. I'll have to play around with it.

In the meantime, I created an "Outside View 0" event, and placed an "instance_destroy()" code within its Action. It shouldn't be too hard to place something like that in the Step event of obj_Enemy.

I'm definitely feeling more comfortable with GMS, at least with what I've learned so far. I feel pretty confident that without any tutorial, I can place a player object within a room, make it scroll along with the view, and provide enemies to destroy. I've also adapted the 'firingDelay' variable for the enemies, so that they will automatically start firing every X seconds after crossing a certain point in the view.

I'm basically just redoing the same elements from this tutorial over and over again until I feel that I understand exactly what I'm coding and why I'm coding it, and then once I'm comfortable with all of that, I can move on to something else. Thank you guys so much for all of your help.
Logged
whilefun
Level 1
*


Making games


View Profile WWW
« Reply #165 on: December 13, 2012, 09:25:37 AM »

I'd probably extend the active objects range a few dozen pixels past the view window, too,

I usually just use the sprite size or sprite size plus some padding constant, that way the same logic works for any object (with varying sprites, for inheritance purposes)

I've also adapted the 'firingDelay' variable for the enemies, so that they will automatically start firing every X seconds after crossing a certain point in the view.

You could also try using a randomized delay so that the firing sounds from on screen enemies is not quite so rhythmic. (so "pew...pew.pew..." instead of "pew.pew.pew."). I have found random variation to be one of the cheapest and easiest ways to add "feel" to a game (for lack of a better term)  Smiley
Logged

omraya
Level 0
*


View Profile
« Reply #166 on: January 01, 2013, 05:29:03 AM »

so yeah, I'm a noob to Game Maker,
I'm doing this tutorial and I just can't figure out that part:


...looks like the player can still steer his or her ship off the edges of the screen, that's no good.  Let's alter our control code slightly to keep the player within the confines of the view:

Code: (Step Event)
if (keyboard_check(vk_up))
{
    if (y > 0) y -= speedUp;
}
if (keyboard_check(vk_down))
{
    if (y + 12 < room_height) y += speedUp;
}
if (keyboard_check(vk_left))
{
    if (x > view_xview[0]) x -= speedUp;
}
if (keyboard_check(vk_right))
{
    if (x + 16 < view_xview[0] + view_wview[0]) x += speedUp;
}


so yeah, I put the code in the right place and
the ship does not steer off the edges as promised,
but I just don't understand why. I don't understand the logic of it..

I've looked at it and read it a few times now,
and I still don't get the why.
So, can anyone explain to me what in that syntax enabled that to happen?
Logged
Xion
Pixelhead
Level 10
******



View Profile WWW
« Reply #167 on: January 01, 2013, 09:26:03 PM »

Code: (Step Event)
if (keyboard_check(vk_up)) //if you're pressing up
   {
   if (y > 0)    //if my y position is greater than 0
                 //(aka, I am beneath the very topmost edge of the room)
   y -= speedUp; //then decrease my y position by (speedUp) amount of pixels (move up)
   }

if (keyboard_check(vk_down))//if you're pressing down
   {
   if (y + 12 < room_height)//if my y position plus 12 is less than the height of the room
                            //(aka I am 12 pixels above the bottom-most edge of the room)
   y += speedUp;            //then increase my y position by (speedUp) amount of pixels (move down)
   }

if (keyboard_check(vk_left))//if you're pressing left
   {
   if (x > view_xview[0])   //if my x position is greater than the x position of view[0]
                            //aka I'm not further left than the left edge of the screen
   x -= speedUp;            //then decrease my x position by (speedUp) amount of pixels (move left)
   }

if (keyboard_check(vk_right))//if you're pressing right
   {
   if (x + 16 < view_xview[0] + view_wview[0])
                             //if my x position is less than
                             //the x position of view[0] plus the width of view[0]
                             //aka I'm not further right than the right edge of the screen
   x += speedUp;             //then increase my x position by (speedUp) amount of pixels (move right)
   }

basically you're just making sure you're not beyond any of the boundaries of the view (horizontally) or beyond the boundaries of the room (vertically) before moving in a direction that would move you outside those boundaries.

another thing that might also work is:
x = max(min(x,view_xview[0]+view_wview[0]),view_xview[0])
y = max(min(y,room_height),0)

after you've done your movement without checking for view/room boundaries.

max(arg1,arg2,arg3...) returns the largest argument, and
min(arg1,arg2,arg3...) returns the smallest.

therefore min(10,5) will return 5.
if you put min(10,5) as an argument in max(), such as in:
max(3,min(10,5))
it will use the result of the min as the argument in max(). In the above example, 5 - the result of the min() - is greater than 3, the other argument in max(), so as a whole it would return 5.

now min(y,room_height) will return the lesser of the two variables: y and room_height.
therefore y = min(y,room_height) will allow your y position to change freely until it becomes greater than room_height, at which point the y position will be continually reset to equal room_height. This prevents you from going beyond the bottom border of the room.

Unfortunately this does nothing to keep you from going above the top of the room, which is why you nest the min(y,room_height) in a max(0,...): which will prevent the y position from going below 0.

The x version does the same thing except within the boundaries of view[0] instead of the room's dimensions.

I have no idea if this is more efficient than the method of checking your destination coordinates before you move there but it's certainly a lot smaller.
Logged

omraya
Level 0
*


View Profile
« Reply #168 on: January 02, 2013, 06:05:06 AM »

Thanks Xion,
That really helped me understand.
Logged
HaydenDavenport
Level 0
**


View Profile WWW
« Reply #169 on: March 13, 2013, 04:35:58 PM »

Hi everyone,

I'm having a strange issue that I can't find the cause of.

Basically, I can't get this part to work:

Code: (Step Event)
view_xview[0] += 1;

I read through the tutorial many times, and still don't see where I could be screwing up. I even tried to go into the source files to see if there was anything I could find that differed from my file.

I tried copy/pasting the code directly from the source to my version, and it didn't work. Then I tried deleting the step function directly from the source code, then adding it back with the code. It worked.

Then I tried deleting oGame from the source code. I made oGame again, made the step function, and pasted in the code. This time it didn't work. So I'm guessing there must be some setting I need to change in the oGame object...

I tried all of this on another computer and experienced the same results. Could anyone assist me??

Thanks a bunch!
Logged
Glyph
Level 10
*****


Relax! It's all a dream! It HAS to be!


View Profile
« Reply #170 on: March 13, 2013, 06:36:33 PM »

It might be because you have the view set to follow an object -- most likely the player. Under the View tab in the room editor, you can switch off view following so that you can move it however you like.
Logged


HaydenDavenport
Level 0
**


View Profile WWW
« Reply #171 on: March 13, 2013, 07:21:04 PM »

It might be because you have the view set to follow an object -- most likely the player. Under the View tab in the room editor, you can switch off view following so that you can move it however you like.

Sadly, no, that's not the solution. When I delete the oGame from the source file, and recreate it, it stops working. This happens regardless of whether or not I touch rLevel1. But to be sure, I did check, and there was no associated object. Thank you though.

EDIT:
Lol.. Crap. I just had to add the instance into the room. Which I found out after reading on. The reason I didn't read on is because Derek mentioned that the code would act funky until it was edited to move with the ship. (But in reality, it just wouldn't have done anything at that point.)
« Last Edit: March 13, 2013, 08:04:37 PM by HaydenDavenport » Logged
siskavard
Guest
« Reply #172 on: March 13, 2013, 08:49:01 PM »

[[made a thread]]
« Last Edit: March 14, 2013, 03:04:56 PM by siskavard » Logged
Reggie02
Level 0
**


View Profile
« Reply #173 on: March 17, 2013, 05:33:22 PM »

I can see my bullets if I catch up to them. How can I fix this?
Logged
TapeRecorder
Level 0
*


View Profile
« Reply #174 on: May 27, 2013, 01:48:01 PM »

Thank you so much for these, Derek. Have been plowing through the official tuts with only marginal progress - this is so much better!
Logged
tegneren
Level 0
*


View Profile
« Reply #175 on: August 13, 2013, 04:55:50 AM »

Hi.
I have been following this tutorial, and it has been working great, but I'm stuck on this code:
Code:
if (keyboard_check(vk_up))
{
    if (y > 0) y -= speedUp;
}
if (keyboard_check(vk_down))
{
    if (y + 12 < room_height) y += speedUp;
}
if (keyboard_check(vk_left))
{
    if (x > view_xview[0]) x -= speedUp;
}
if (keyboard_check(vk_right))
{
    if (x + 16 < view_xview[0] + view_wview[0]) x += speedUp;
}

I have two problems with this part. First off, I can still steer off the edge of the screen, and the second issue, is that every time I press "right" I get this error message:
Quote
FATAL ERROR in
action number 1
of  Step Event0
for object obj_game:

Push :: Execution Error - Variable Get -1.speedUp(100009, -1)
 at gml_Object_obj_game_Step_0 (line 20) -     if (x + 16 < view_xview[0] + view_wview[0]) x += speedUp;

Does anyone know what I'm doing wrong?

[UPDATE]
One of my friends found out the problem. I had written speedUp with a big "S" in the create event. So problem solved. :D
« Last Edit: August 14, 2013, 12:25:01 AM by tegneren » Logged
PogueSquadron
Level 1
*



View Profile WWW
« Reply #176 on: January 26, 2014, 11:39:31 AM »

Possibly a newb question -

Derek has outlined the use of invisible walls for his tutorial.

Let's say I have something from a top down perspective like A Link to the Past or Chrono Trigger. Ideally, I'd want my player to come to a halt every time he bumps into a house, a signpost, a tree, etc.

Would I want to just make sure that my signposts, trees, etc. all have some "wall object" as a parent, so that they all behave the same way when the player collides with them?

And in regards to something larger, like say, a house, would I want to use invisible walls there? I was asking mainly because...what if I want to move the house? Would I then have to move every single invisible wall object? Or is there an easier way to just say "When the player collides with the house, stop moving."?

I've been trying to wrap my head around when I would want to use an invisible wall, and when it would be better to have the player collide with a specific object. Is it about size? Whether or not the object is moving?
Logged
PogueSquadron
Level 1
*



View Profile WWW
« Reply #177 on: January 27, 2014, 08:59:58 AM »

Sorry for the double post.

Here's what I wound up doing, at least for now.

I made an object called "par_wall", and have in my Step event of my obj_player (where I've already defined my speedup variable as 3):

if key_left
    {
    if !place_meeting(x-speedup,y,par_wall) x -= speedup;
    };


(and so on and so forth for each direction).

It seems to do what I want it to do, at least in the early stage of learning. I can also make things like trees, signposts, and people all have a parent object of "par_wall" so that my player will stop moving when he reaches those things as well. The collision isn't the greatest, but I suppose this has maybe more to do with sprite masks and things of that nature. That's a lesson for another day I suppose.

Is this a lazy, unefficient way of doing things? Or is it an entirely usable approach for something like a top down, Chrono Trigger type of game?
Logged
JDJackson
TIGBaby
*


View Profile
« Reply #178 on: January 31, 2014, 07:24:42 AM »

Does anyone know what is causing this error? I don't get why it's saying unknown variable, since I have created this variable in the Create event of oPlayerShip. The variable is also in the step object of oPlayerShip for moving the ship around, and it worked fine in part II of the tutorial. Also in the same piece of code at line 7, the speedUp variable is there and it doesn't trigger an error.

ERROR in
action number 1
of  Step Event
for object oGame:

Error in code at line 11:
       if (y + 12 < room_height) y += speedUp;
                                      ^
at position 37: Unknown variable speedUp

Thanks for any help!   Smiley

Edit: While I was brushing my teeth this morning it suddenly came to me that it was because I had the code in oGame instead of oPlayerShip. Switched it around and it works now!  Beer!
« Last Edit: February 01, 2014, 11:28:50 AM by JDJackson » Logged
Leonardo Myst
Level 0
*


View Profile
« Reply #179 on: February 05, 2014, 02:35:58 PM »

Just wanted to give a quick "thank you" for these before I head off to Part 1.
Logged
Pages: 1 ... 7 8 [9] 10
Print
Jump to:  

Theme orange-lt created by panic