View Full Version : Game Maker Help Thread (Post your Qs here!)
|-|1Pp13
16-04-2008, 05:38 PM
could use the chr() command if you know the ASCII value of " :)
-D
http://www.asciitable.com/
its there :)
ShadowMaster
16-04-2008, 06:49 PM
Thanks for the help, will try it out and report back.
EDIT: '"' works!!!
Should add it to my GM hacks list...
Cloud_Ratha
17-04-2008, 08:59 PM
Im pretty new to this and it is loads of fun... been designing something sne 1pm... just need help with collision detection. im using a script to detect the collision detection. Thing is how do i determine the boundaries with my sprite? i can get the sprite to be level with the solid object, but when it reaches the edge it can move for a while on "nothing" then falls. I need help!
EDIT: No worries figured it out! :D
dislekcia
18-04-2008, 02:12 AM
Im pretty new to this and it is loads of fun... been designing something sne 1pm... just need help with collision detection. im using a script to detect the collision detection. Thing is how do i determine the boundaries with my sprite? i can get the sprite to be level with the solid object, but when it reaches the edge it can move for a while on "nothing" then falls. I need help!
EDIT: No worries figured it out! :D
You do realise that GM can handle collision detection for you, right? That's what the collision events are for ;)
-D
Time for a little help with my views and HUD. :)
Im busy drawing the HUD according to the view x and y positions using this code:
x = view_xview[0] + 35;
y = view_yview[0] + 35;
It works, but the HUD seems to lag a bit behind view sometimes and I can seem to get it to stay still, any suggestions?
|-|1Pp13
22-04-2008, 09:36 PM
Time for a little help with my views and HUD. :)
Im busy drawing the HUD according to the view x and y positions using this code:
x = view_xview[0] + 35;
y = view_yview[0] + 35;
It works, but the HUD seems to lag a bit behind view sometimes and I can seem to get it to stay still, any suggestions?
ive had the same problem, i used the draw() functions instead of moving the x's/y's
IE
draw_text(view_xview[0]+35,view_yview+35,'Score: ')
dislekcia
22-04-2008, 09:41 PM
ive had the same problem, i used the draw() functions instead of moving the x's/y's
IE
draw_text(view_xview[0]+35,view_yview+35,'Score: ')
Yup. That lag happens because the view co-ordinates are updated at the beginning of the draw event, so positions set during the step event (which happens before draw) are going to be one change out of date.
-D
Cloud_Ratha
23-04-2008, 12:52 PM
@Dislekcia: Hey... I still got it working... It wasn anything to do with the collision. Just had to set the sprite's boundaries up. Dont laugh me... Im still new
Gazza_N
23-04-2008, 01:01 PM
We laugh at many things here at Game.Dev, but never at newbies. It may not look like it, but many of us are newbies too. Dis was just trying to nudge you in the right direction, not mock you. Relax! :)
dislekcia
23-04-2008, 10:48 PM
@Dislekcia: Hey... I still got it working... It wasn anything to do with the collision. Just had to set the sprite's boundaries up. Dont laugh me... Im still new
No worries... But didn't GM do that for you? I've never had to do that manually unless I'm writing my own collision system for some reason.
So just to clarify: Are you using GM's built-in collision events or not? If not, have you tried them?
-D
Cloud_Ratha
24-04-2008, 01:54 AM
No i had to write the scripts for the collision myself. for some reason after i drew the sprite and compiled the steps, anything after that got ignored. Was probably a simple mistake. I know u guys aren't laughing at me. Im just messing. Im quite enjoying coding again... Its been a while. So stoked i got the sprites to change from running, walking, attacking, jumping, falling,etc. Took me ages to understand what i was doing...
Bonezmann
25-04-2008, 11:43 AM
This is going to sound stupid, but I can't Register at yoyogames to download Gamemaker, anyone know Why or where I can do this?
Bonezman: you have to register here: http://www.yoyogames.com/user/signup
It is irritating to have to register to download though :(
dislekcia
25-04-2008, 03:07 PM
This is going to sound stupid, but I can't Register at yoyogames to download Gamemaker, anyone know Why or where I can do this?
What error message does it give you?
You should be able to Google for alternate Game Maker 7 links...
-D
Aval4nche
25-04-2008, 03:55 PM
In my turn based stategy game, I use controllers for Player 1 and 2s turns. How do I create an end turn button. I tried making 2. One for each player. These would destroy the controller, create a new controller, create the second end turn button and destroy itself. Unfortunately, clicking it starts changing players every second and I have to quit. What do I do?!
cairnswm
25-04-2008, 03:56 PM
How do I get two instances of the same object to bounce away from one another - so instance 1 is moving, and hits instance 2 - instance 2 moves away from instance1 at the speed it was hit and instance 1 reverses direction....
I've got it sort of working but instance 2 in some cases goes in the same direction as instance 1 after the collision
dislekcia
25-04-2008, 06:28 PM
How do I get two instances of the same object to bounce away from one another - so instance 1 is moving, and hits instance 2 - instance 2 moves away from instance1 at the speed it was hit and instance 1 reverses direction....
I've got it sort of working but instance 2 in some cases goes in the same direction as instance 1 after the collision
Are you using GM? If you are, your best bet is to use the collision events to set up a list of collisions between objects and process your way through that list after the collision events have finished firing. That way you can prevent duplicate pairs in the list which happens sometimes when collision events fire multiple times (once for each object in the collision, for example). Also, the other keyword in the collision events is your friend ;)
The rest is GM-independent:
First, you need to understand how collisions between rigid bodies work, read this (http://chrishecker.com/Rigid_Body_Dynamics). Mr Hecker's stuff is pretty much the seminal resource for this sort of thing for game developers.
Then, implement an impulse applicator for your objects. Once you've got that, you can start using the momentum and collision response equations to create the correct impulse forces. It's not a tough problem, it just requires the right approach to get it working right :)
-D
Kensei
25-04-2008, 09:18 PM
In my turn based stategy game, I use controllers for Player 1 and 2s turns. How do I create an end turn button. I tried making 2. One for each player. These would destroy the controller, create a new controller, create the second end turn button and destroy itself. Unfortunately, clicking it starts changing players every second and I have to quit. What do I do?!
Don't take my words as law but, what if you create a simple variable that resets every time you click the End Turn button?
Sounds like it thinks you are clicking on it multiple times, so it destroys then creates, then destroys etc.
What event are you triggering the destruction of the controller?
Aval4nche
25-04-2008, 09:22 PM
Don't take my words as law but, what if you create a simple variable that resets every time you click the End Turn button?
Sounds like it thinks you are clicking on it multiple times, so it destroys then creates, then destroys etc.
What event are you triggering the destruction of the controller?
Thanks for the help. I've got it now. :D
dislekcia
26-04-2008, 12:37 AM
Thanks for the help. I've got it now. :D
GW Kensei ;)
So Avalanche, when do we get a prototype to see?
-D
Aval4nche
26-04-2008, 07:26 AM
Sorry, it might take a while. I'm trying to balance game making with schoolwork and the next couple of months are going to be a killer.
Bonezmann
26-04-2008, 10:43 AM
Disleckia, i cant find a link on the yoyo games homepage to register. :) Thanx edge, I'll check the link soon.
dislekcia
27-04-2008, 05:46 AM
Disleckia, i cant find a link on the yoyo games homepage to register. :) Thanx edge, I'll check the link soon.
Looks like the signup link has been taken down while they migrate to new servers.
-D
Aval4nche
01-05-2008, 04:24 PM
How do I make it so that one controller cannot exist while another does?
dislekcia
01-05-2008, 10:50 PM
How do I make it so that one controller cannot exist while another does?
Check the Persistent checkbox on the object, that will stop the controller being created multiple times when it's placed in a room and you switch back and forth to that particular room. Note that the controller will then exist for the rest of the game (or until explicitly destroyed) after you've been to that room in the game.
You can also use code to destroy any "extra" controllers before they do anything that might break your game, like so:
*In the controller's Create Event*
if (instance_number(<controller object type>) > 1) {
instance_destroy();
} else {
// Do everything else that the controller should do if it's the only one...
}
-D
Aval4nche
02-05-2008, 09:29 AM
Awesome, thanks a lot.
Higushi
06-05-2008, 01:39 PM
Is it possible to customize the resolution and display options of games in game maker using the GM scripting language? This would greatly help as everyone has a different PC with different display needs (and wants).
I'd like to add options to my games where people are able to customize anything display related, creating a better experience for them and allowing people with slower machines to play my games smoothly.
Squid
06-05-2008, 03:29 PM
*a.k.a. Higushi
Oh hey, its you welcome back!
Shows how little attention I pay, I only realised when I saw your face in your avatar.
Is it possible to customize the resolution and display options of games in game maker using the GM scripting language? This would greatly help as everyone has a different PC with different display needs (and wants).
You can use room and view features, pea adventures uses some of the following:
room_set_width(ind,w)
room_set_height(ind,h)
room_set_caption(ind,str)
room_set_persistent(ind,val)
room_set_code(ind,str)
room_set_background_color(ind,col,show)
room_set_view(ind,vind,vis,xview,yview,wview,hview ,xport,yport,wport,hport,hborder,vborder,hspeed,vs peed,obj)
room_set_view_enabled(ind,val)
room_duplicate(ind)
room_assign(ind,room)
room_instance_add(ind,x,y,obj)
To do resolution you could easily change views/room width's, etc
also these could also help you out:
display_get_width()
display_get_height()
display_get_colordepth()
display_get_frequency()
display_set_size(w,h)
display_set_colordepth(coldepth)
display_set_frequency(frequency)
display_set_all(w,h,frequency,coldepth)
display_test_all(w,h,frequency,coldepth)
display_reset()
Another nifty thing you could do is you could have a background or files with your sprites in different sizes (32x32,64x64, etc) and then to up quality use various sprite commands to draw it:
draw_sprite_stretched(sprite,subimg,x,y,w,h)
sprite_add(fname,imgnumb,precise,transparent,smoot h,preload,xorig,yorig)
All function lists courtesy of your Game Maker help file
dislekcia
06-05-2008, 04:12 PM
Is it possible to customize the resolution and display options of games in game maker using the GM scripting language? This would greatly help as everyone has a different PC with different display needs (and wants).
I'd like to add options to my games where people are able to customize anything display related, creating a better experience for them and allowing people with slower machines to play my games smoothly.
Yup, you can :)
The following appears when you search for "The Window" in GM's help:
The actual game happens in a window. This window has a number of properties, like whether it has a border, whether it is full screen, etc. Normally these are set in the Game Settings. But you can change then during the game. The following functions exist for this: <many fucntions>
Don't forget that you can also control the view width and height during runtime as well using view_wview[] and similar commands.
-D
Higushi
07-05-2008, 02:08 AM
Aweh, thanks for all the help guys! :) I like giving my user as much control as possible, so its a big help.
Oh hey, its you welcome back!
Shows how little attention I pay, I only realised when I saw your face in your avatar.
haha. yeah, thats mostly why I put the photo up for a while. Good to check ya again!
Bonezmann
08-05-2008, 11:41 AM
[previous problem solved]
[problem solved]
Anilihst
08-05-2008, 05:47 PM
Does all surface drawings always have random lines in them?
http://www.hostaphoto.net/uploads/a3db69a905.jpg
any suggestions to fix or overcome this problem?
Cloud_Ratha
08-05-2008, 05:53 PM
Does all surface drawings always have random lines in them?
http://www.hostaphoto.net/uploads/a3db69a905.jpg
any suggestions to fix or overcome this problem?
Dude how small is that pic? i think try uploading a bigger pic
Tigman_1
08-05-2008, 06:49 PM
Hi guys I have this problem with setting the room speed every 2 minutes. I have made two objects that look like this (object 1)
if (Time2 == 120){
room_speed = room_speed +10;}
but what would I put in object 2 to make it start counting to 120?
any suggestions?
dislekcia
08-05-2008, 07:44 PM
Hi guys I have this problem with setting the room speed every 2 minutes. I have made two objects that look like this (object 1)
if (Time2 == 120){
room_speed = room_speed +10;}
but what would I put in object 2 to make it start counting to 120?
any suggestions?
Tigman, people are trying to help you in the tetris thread. You're showing some signs that you don't understand what it is you're doing and we're all trying to sort that out, but you have to participate. We're not all going to be able to help you every time you run into a problem and we're certainly not going to be able to write every line of code for you all the time, so you need to learn a few concepts...
They're not hard, just answer the questions and follow the logic you're being given. Nothing worth doing is spoon-fed to you.
-D
Tigman_1
08-05-2008, 07:54 PM
im sorry got the wrong thread, my bad ... I appoligize....:(
SkinkLizzard
09-05-2008, 12:16 AM
Does all surface drawings always have random lines in them?
http://www.hostaphoto.net/uploads/a3db69a905.jpg
any suggestions to fix or overcome this problem?
no they don't, I haven't looked at the image but by random lines
I assume you mean when you draw the surface to the screen or make a sprite from it,
this leads me to suspect you don't ever wipe the surface with a base colour.
so when you draw the surface it doesn't know what's there so you get artefacts,
this doesn't always happen nor does it seem to happen to everyone.
I suggest finding a colour that wont be used in the image you're drawing (sickeningly bright pink) and using it as the background/transparent colour(of the surface) before drawing to your surface.
Cloud_Ratha
09-05-2008, 12:17 AM
Just a quick question about sprites. If i use ripped sprites and custom edit them is it legal, at all, to ever use them? Iv looked online and they only talk about straight ripped sprites. Dunno if this is the right place to post this, but i need the help!
Bonezmann
09-05-2008, 11:33 AM
Right, as some of you may know I'm making a trading card game. Any ideas on how to make the cards battle each other?
Anilihst
09-05-2008, 03:14 PM
thx Skink The lines are gone but for some reason I can't make a sprite of the surface.
SkinkLizzard
09-05-2008, 03:23 PM
Anihlist if you wait about 45 minutes ill be home and at my pc ill edit the post with details of surfaces and sprites.
dislekcia
09-05-2008, 04:30 PM
thx Skink The lines are gone but for some reason I can't make a sprite of the surface.
Please post what you're doing and which event it's in... Remember that you shouldn't use surface commands during a Draw event, as that messes up GM's normal drawing and the two conflict.
-D
Kensei
10-05-2008, 08:26 PM
Right, as some of you may know I'm making a trading card game. Any ideas on how to make the cards battle each other?
erm, could you be a little more specific?
If you mean storing variables - a simple array should do it :D
Anilihst
11-05-2008, 07:58 PM
Sorry for this late reply but I was away for the weekend but anyway.
No Dis I am not using it in a draw event I used it in a script which was called by a click event.
My specific problem is getting the surface to a sprite which I can use. Is it possible to make a sprite then at run time to assign all the surface sprites to it. Then tell the objects where that sprites are?
I tried this:
storesprite = sprite_create_from_surface(global.surface,0,0,48,3 2,true,0,true,1,0,0);
SkinkLizzard
11-05-2008, 08:18 PM
thats correct :)
you then use object.sprite_index = storesprite
only minor problem is if you keep creating lots and lots of sprites you might eventually lag and freeze
so say oldsprite = object.sprite_index
object.sprite_index = storesprite
sprite_delete(oldsprite); or something along those lines :)
Anilihst
11-05-2008, 08:26 PM
thx Skink all of it works now, I had a little problem with the destruction of the old sprite but I got it working.
dislekcia
12-05-2008, 01:03 AM
Sorry for this late reply but I was away for the weekend but anyway.
No Dis I am not using it in a draw event I used it in a script which was called by a click event.
My specific problem is getting the surface to a sprite which I can use. Is it possible to make a sprite then at run time to assign all the surface sprites to it. Then tell the objects where that sprites are?
I tried this:
storesprite = sprite_create_from_surface(global.surface,0,0,48,3 2,true,0,true,1,0,0);
Have you initialised the surface before you start trying to use it? You have to create the surface you want to draw on using the surface_create() function (this creates an area of video memory for you and returns a handle for it). Then you switch your rendering to that surface using the surface_set_target(handle) command. Only then can you reliably "draw" to that surface, just like in normal GM drawing...
Only after you've got yourself a surface with worthwhile graphic info in it should you try to create a sprite from it. I think you may have gotten your logic the wrong way around there ;)
Also, don't forget to use surface_reset_target() to go back to drawing in the frame buffer once you're done with your surface!
-D
Bonezmann
12-05-2008, 09:04 AM
Right, as some of you may know I'm making a trading card game. Any ideas on how to make the cards battle each other?
Nevermind guys, I had an epiphany last night. The whole game mechanic thing is going to change...
Higushi
13-05-2008, 01:59 PM
I had an epiphany last night
Love those :)
Bonezmann
16-05-2008, 04:43 PM
When my sprite hits the wall from the top, it slides against the wall to the right. and when it hits the wall from the right, it vibrates or something. It's a top-down scroller game thing.
I'll post more info if someone desires it. :)
Kensei
16-05-2008, 09:02 PM
how are you doing your collision detection?
What is meant to happen?
Sounds like it is moving to right eventhough its already there
Bonezmann
17-05-2008, 09:32 AM
In movement I'm using <LEFT> Jump to position -4 and in collision I'm using the Move to contact button I think. I'll be able to give more specific info this afternoon, but that's the buttons I'm using I know that for sure. :)
dislekcia
17-05-2008, 03:34 PM
In movement I'm using <LEFT> Jump to position -4 and in collision I'm using the Move to contact button I think. I'll be able to give more specific info this afternoon, but that's the buttons I'm using I know that for sure. :)
Yeah, code please :) Then we'll be able to see what's going on a lot easier.
-D
Anilihst
17-05-2008, 03:54 PM
sorry fixed it
Gazza_N
17-05-2008, 04:00 PM
EDIT: Bleh. Split second too late.
Guardian
29-05-2008, 05:20 PM
I'm making a top down shooter and I want my enemies to move towards me when I destroy a door but I am really confused.Please, can anyone help?
dislekcia
29-05-2008, 07:53 PM
I'm making a top down shooter and I want my enemies to move towards me when I destroy a door but I am really confused.Please, can anyone help?
There are a few things you could do. The easiest would be to have two kinds of enemy, one that stays where it is and one that moves towards the player.
You'd place the first type of enemy on the map and then in the door's Destroy event change all the instances of the first type of enemy into the second type of enemy. There's a command to do this in script and in the drag and drop code, you just have to change what it applies to using either a with (EnemyOne) { ... } block in code, or changing the "Applies to" radio button in the drag and drop.
Hope that helps provide some ideas of how to do what you want!
-D
Guardian
30-05-2008, 04:51 PM
Dislekcia - YOU ROCK! Thanks that is exactly what I wanted!
Aval4nche
03-06-2008, 05:58 PM
In my game, the character can shoot magic when a variable is set to 1. When he runs out of mana the variable turns to 0, he should not be able to shoot until he drinks a potion. How do I make him stop shooting when the variable turns to 0.
dislekcia
04-06-2008, 12:46 AM
In my game, the character can shoot magic when a variable is set to 1. When he runs out of mana the variable turns to 0, he should not be able to shoot until he drinks a potion. How do I make him stop shooting when the variable turns to 0.
You use an if statement to check what the variable is before firing the magic off... Essentially the if acts as a guard, meaning anything inside it only happens if the test comes out as true. You can add in alternative things to do using else statements and all sorts of cool things too ;)
It sounds like you're trying to overcomplicate the test though... If you're storing an amount of mana, why not just test that you have enough of that to case the spell?
if (mana >= costOfSpell) {
//fire the spell here...
} else {
//do something else, maybe even drink a potion?
}
That reads as "if the value of mana is greater than or equal to the value of costOfSpell, fire the spell, otherwise do something else...
Does that answer your question? You can get a list of comparison operators (of which >= is just one) by looking up if statements in the GM help.
-D
Aval4nche
04-06-2008, 08:14 AM
Thank you kindly :D
Guardian
05-06-2008, 02:09 PM
In my game my character has unlimited ammo but I want to have a certain amount of ammo in a clip(10 bullets) so I set the score to ten and whenever I create a bullet I -1 from score and I said if score =0 then set alarm 1 to 30 and in alarm 1 I said set score to 10 but it dosen't work.
Guardian: It sounds like you're doing it correctly, so do you have something like this in your object:
Click Event (or where its meant to be)
if score > 0 {
score = score - 1
} else if score == 0 {
alarm[1] = 30
}
and then in the alarm1 event code doing something like this:
score = 10
try making sure you have the correct events
Guardian
05-06-2008, 03:56 PM
Thanks a lot.
Bonezmann
05-06-2008, 04:05 PM
I need a character to lost an x amount of life every x amount of steps, please help :)
you could use a time for this
you could have something like a flag variable and use it like such
create event
flag = true
health_lost = 6
then when you start it, like a click event
timer[0] = time_for_deduction
and your timer0 event will be something like
if flag {
health = health - health_lost
timer[0] = time_for_deduction
}
then you can always stop it from happening if you need to, like for taking a potion to get rid of poison :)
ShadowMaster
05-06-2008, 08:22 PM
How do I similate a collision event in code, cause it's messing with my program. Just to clarify, I want to find out if my object is obstructed where it's at and I want to know by who.
Thanks in advance.
EDIT: Fixed problem, but I'd still love to know how to do it. :) (just had to make everything non solid)
dislekcia
06-06-2008, 12:27 AM
How do I similate a collision event in code, cause it's messing with my program. Just to clarify, I want to find out if my object is obstructed where it's at and I want to know by who.
Thanks in advance.
EDIT: Fixed problem, but I'd still love to know how to do it. :) (just had to make everything non solid)
You could use event_perform() to have the collision event execute (just pass the id of the collided object as the second parameter), or you could use the various collision tests in the game: instance_meeting(), place_meeting(), collision_point(), collision_lline(), etc.
-D
instance_meeting(), place_meeting(), collision_point(), collision_lline()
Im also having issues with collisions using these, as unfortunately this doesnt work:
ii = collision_line(x,y,x2,y2,all,true,true)
parent = object_get_parent(ii)
if (parent == o_enemy) {
//code
} else if (parent == o_obstruction) {
//code
} else {
//code
}
It doesnt pick up the object for some reason. It checks the collision and then exits as if there was nothing even though I have made it so that there will always be a collision to test the code...
Cyberninja
06-06-2008, 12:58 PM
Hey guys. I'm working on a simple game for the comp. I've run into a problem though. =[
1- How do I make the player go to the next room when a certain score* is reached?
*50, 100..etc.
2- How do I set up a room that shows the stats of the previous stage? Something that shows the number of kills, score, lives used in that stage etc.
Credit will be given.
check somewhere like in the step event:
if score >= 50 {
room_goto_next()
}
for the room to show stats of the previous stage you could easily use an ini file:
example ini format:
[section]
key1=0
key2=some
when leaving a room:
ini_open('my.ini')
ini_write_real('section','key1',score)
ini_write_string('section','key2','some string'
ini_close()
and then in your object for drawing the score and such (create event):
ini_open('my.ini')
got = ini_read_real('section','key1'0)
comment = ini_read_real('section','key2','none')
ini_close()
draw event example:
draw_text(x,y,'You got ' + string(got) + ' points!')
draw_text(x,y+32,'Comment: ' + comment)
EDIT: also, no need for credit
Gazza_N
06-06-2008, 02:01 PM
A simpler way to do it would be to have a persistent control object that floats invisibly in the background. Because it's persistent and will move between rooms without changing at all, you can use it to store your score AND evaluate it for room changes. Plus you don't have to write to external files. ;)
01DT!m3r
06-06-2008, 03:20 PM
I agree with gazza just use an object and store your values in its variables then just display those variables .
Oldtimer: it depends actually, if you are geared towards something like what i did with pea adventures where you need to save every level to update the file and keep track of score, my way is fine.
I agree that Gazza's method is better, but its not a competition of whose code is more efficient for every given problem, its a matter of helping people.
Cyberninja
06-06-2008, 05:45 PM
Thanks all. I appreciate the help. Will try your methods out and see how it goes. I apologise if some of my questions might seem a bit silly and obvious. I'm just really hopeless when it comes to coding. =/
Thank you all for your help. :)
ShadowMaster
06-06-2008, 05:53 PM
Thanks all. I appreciate the help. Will try your methods out and see how it goes. I apologise if some of my questions might seem a bit silly and obvious. I'm just really hopeless when it comes to coding. =/
Thank you all for your help. :)
Don't mind asking simple question we all do it (the few that have the courage to shove aside their egos that is). It shows you are willing to learn and improve your abilities. We won't ever ridicule and if someone does we'll flame him faster than you can say BBQ. ;)
ShadowMaster
06-06-2008, 06:10 PM
Is there a builtin function in GM that allows you to find the closest instance obstructing a line?
Cause collision_line finds the instance with the smallest instance ID.
I've checked using this: collision_line.gmk (http://www.gamedev.za.net/filecloset/download.php?id=487)
EDIT: or am I gonna have to write a script again?
Guardian
06-06-2008, 06:17 PM
I have objects chasing the player but I want those objects to avoid more than one object and solid dosen't
work. Here is my code that I used...
if distance_to_object(you)<200{
mp_potential_step_object(you.x,you.y,5,Obstacle);
}
if distance_to_object(you)<25{
speed=0
}
Can anyone help?
ShadowMaster
06-06-2008, 06:27 PM
I have objects chasing the player but I want those objects to avoid more than one object and solid dosen't
work.
How doesn't it work? Does it go through the objects or does it fail to maneuver around the objects correctly. Cause the latter is a lot harder.
Cyberninja
06-06-2008, 10:19 PM
Problem solved! ^_^ Thanks a lot guys. :P
dislekcia
06-06-2008, 10:47 PM
Im also having issues with collisions using these, as unfortunately this doesnt work:
ii = collision_line(x,y,x2,y2,all,true,true)
parent = object_get_parent(ii)
if (parent == o_enemy) {
//code
} else if (parent == o_obstruction) {
//code
} else {
//code
}
It doesnt pick up the object for some reason. It checks the collision and then exits as if there was nothing even though I have made it so that there will always be a collision to test the code...
Why not use multiple collision_line() statements?
ii = collision_line(x, y, x2, y2, o_enemy, true, true);
if (ii > 0) {
//enemy code...
}
ii = collision_line(x, y, x2, y2, o_obstruction, true, true);
if (ii > 0) {
//obstruction code...
}
//etc...
I can understand you wanting to have the object collided with, so that you can do things to it if you need to, but trying to find an object's parent rather than simply use a parent filtering mechanism provided by the collision test seems like a silly idea. Also, the collision test going to be much faster (even when called 3 times) if you supply an object type as it will only bother testing those objects, not every single instance as it would using all.
GL :)
-D
dislekcia
06-06-2008, 11:11 PM
Is there a builtin function in GM that allows you to find the closest instance obstructing a line?
Cause collision_line finds the instance with the smallest instance ID.
I've checked using this: collision_line.gmk (http://www.gamedev.za.net/filecloset/download.php?id=487)
EDIT: or am I gonna have to write a script again?
I would reverse the collision check: Put it in the object type you want to find the closest one of, then store any positive collisions in a priority queue according to their distance from the important object. When you're done, the first object in the priority queue should be the closest colliding one :)
You following the logic? The big problem is that collision_line() only returns 1 id and not the closest one, I know. I did this for monochrome a few times.
-D
ShadowMaster
06-06-2008, 11:21 PM
I would reverse the collision check: Put it in the object type you want to find the closest one of, then store any positive collisions in a priority queue according to their distance from the important object. When you're done, the first object in the priority queue should be the closest colliding one :)
You following the logic? The big problem is that collision_line() only returns 1 id and not the closest one, I know. I did this for monochrome a few times.
-D
Ah I see. Took me a while, but I see. :) Thanks. Only one optimization: there's no need for a priority queue as you only care about the closest one. But thanks none the less. An optimization isn't worth anything if you have no code to optimize. ;) *scurries off to code it*
dislekcia
06-06-2008, 11:31 PM
I have objects chasing the player but I want those objects to avoid more than one object and solid dosen't
work. Here is my code that I used...
if distance_to_object(you)<200{
mp_potential_step_object(you.x,you.y,5,Obstacle);
}
if distance_to_object(you)<25{
speed=0
}
Can anyone help?
If you mean more than one type of obstacle, just use Obstacle as a base class and have all the other types of thing that you want the chasing entities to avoid inherit from Obstacle by setting their Parent to Obstacle instead of <none>.
-D
dislekcia
06-06-2008, 11:38 PM
Ah I see. Took me a while, but I see. :) Thanks. Only one optimization: there's no need for a priority queue as you only care about the closest one. But thanks none the less. An optimization isn't worth anything if you have no code to optimize. ;) *scurries off to code it*
True, but you have to do the distance check per object anyway and the priority queue insertion is practically free. I think I over-eleganced the concept somehow, a pointer and closest value would work fine ;)
-D
Guardian
07-06-2008, 08:15 AM
If you mean more than one type of obstacle, just use Obstacle as a base class and have all the other types of thing that you want the chasing entities to avoid inherit from Obstacle by setting their Parent to Obstacle instead of <none>.
-D
Thanks a lot dislekcia. :D
ShadowMaster
07-06-2008, 10:57 AM
True, but you have to do the distance check per object anyway and the priority queue insertion is practically free. I think I over-eleganced the concept somehow, a pointer and closest value would work fine ;)
-D
I just realised I need to find the distance along the line, how would I go about that?
In other words I want to find the distance the object is away from the start point but along the line, then I'd also like to know at which point this collision occurs.
I would like to avoid something like traveling along the line until I find an object as that's dreadfully slow.
Thanks in advance.
01DT!m3r
07-06-2008, 11:32 AM
I just realised I need to find the distance along the line, how would I go about that?
In other words I want to find the distance the object is away from the start point but along the line, then I'd also like to know at which point this collision occurs.
I would like to avoid something like traveling along the line until I find an object as that's dreadfully slow.
Thanks in advance.
cant you use the distance formula
Squid
07-06-2008, 12:28 PM
point_distance();
Look it up in the GM help.
ShadowMaster
07-06-2008, 12:36 PM
point_distance();
Look it up in the GM help.
Thanks but it's not really what I'm looking for, I'm looking for the actual coordinates. Once I have those the rest is easy. :)
dislekcia
07-06-2008, 04:50 PM
Thanks but it's not really what I'm looking for, I'm looking for the actual coordinates. Once I have those the rest is easy. :)
Well, you can either project the centre point of your colliding object onto the line, using some maths that I'd need to look up quickly - provided you don't need the exact first point of collision.
Or, if you do need that level of accuracy (really huge and convoluted overlapping objects?) you could run a binary search long the line: Start by testing the entire line length, then if there is a collision, test the closest half of the line; If that collides, test the closest half of that line (etc) and if it doesn't, test the furthest half of your segment and repeat the process if it does collide. Within about 4 or 5 tests you'll be testing differences of about 2-3 pixels, which should be accurate enough for what you want. The nice thing about this kind of test is that you'll automatically get the closest colliding instance, no more storage of closest distance stuff.
BinaryLineCollision
//Script to find the closest colliding point along a line via binary search:
//params: (x1, y1, x2, y2, minimumThreshold, object type to collide with)
//Will return the closest colliding object of the desired type to x1, y1...
var o, x1, x2, xm, y1, y2, ym, minThreshold, objType;
x1 = argument0;
y1 = argument1;
x2 = argument2;
y2 = argument3;
minThreshold = argument4;
objType = argument5;
o = collision_line(x1, y1, x2, y2, objType, true, true);
if (o > 0) {
//Test for minimum distance:
if (point_distance(x1, y1, x2, y2) <= minThreshold) return o;
//Test the closest half of the line:
xm = (x1 + x2) / 2;
ym = (y1 + y2) / 2;
o = collision_line(x1, y1, xm, ym, objType, true, true);
if (o > 0) return BinaryLineCollision(x1, y1, xm, ym, minThreshold, objType);
//Test the other half of the line:
o = collision_line(xm, ym, x2, y2, objType, true, true);
if (o > 0) return BinaryLineCollision(xm, ym, x2, y2, minThreshold, objType);
}
return o;
Should be useful, haven't tested it though - hopefully it compiles ok ;)
-D
ShadowMaster
07-06-2008, 05:13 PM
Thanks dislecsia. Working code works, just need to modify it a bit for my needs but thanks.
EDIT: That is by renaming the script and making xm and ym persistent.
dislekcia
08-06-2008, 01:45 AM
Thanks dislecsia. Working code works, just need to modify it a bit for my needs but thanks.
EDIT: That is by renaming the script and making xm and ym persistent.
Why would you need to make those persistent? Recursion using non stack variables is a very, very bad idea...
Also I'd expect you to replace the point_distance() call with a square distance formula to save on the root ;)
-D
ShadowMaster
08-06-2008, 12:17 PM
Why would you need to make those persistent? Recursion using non stack variables is a very, very bad idea...
The script is intended to be used by bullet code, so I need to know where the collision occurred, but the way the code works it doesn't matter if those variables are persistent or not.
Also I'd expect you to replace the point_distance() call with a square distance formula to save on the root ;)
-D
Yes I thought of that, hadn't got around to doing that though. ;) Atleast it's cemented in my minds todo list now. Thanks.
dislekcia
08-06-2008, 01:52 PM
The script is intended to be used by bullet code, so I need to know where the collision occurred, but the way the code works it doesn't matter if those variables are persistent or not.
Ah, I'd simply have the script set some global return values in that case. Plus I'd use the furthest point (because then you're assured of the collision), which depending on the code-branch that returns is either xm,ym or x2,y2. global.lineCollsion_x and global.lineCollision_y would be what I'd use :)
-D
ShadowMaster
08-06-2008, 03:11 PM
Ah, I'd simply have the script set some global return values in that case. Plus I'd use the furthest point (because then you're assured of the collision), which depending on the code-branch that returns is either xm,ym or x2,y2. global.lineCollsion_x and global.lineCollision_y would be what I'd use :)
-D
This is what I did:
BinaryLineCollision
//Script to find the closest colliding point along a line via binary search:
//params: (x1, y1, x2, y2, minimumThreshold, object type to collide with)
//Will return the closest colliding object of the desired type to x1, y1...
var o, x1, x2, y1, y2, minThreshold, objType;
x1 = argument0;
y1 = argument1;
x2 = argument2;
y2 = argument3;
minThreshold = argument4;
objType = argument5;
xm = x2;
ym = y2;
o = collision_line(x1, y1, x2, y2, objType, true, true);
if (o > 0) {
//Test for minimum distance:
if (point_distance(x1, y1, x2, y2) <= minThreshold) return o;
//Test the closest half of the line:
xm = (x1 + x2) / 2;
ym = (y1 + y2) / 2;
o = collision_line(x1, y1, xm, ym, objType, true, true);
if (o > 0) return BinaryLineCollision(x1, y1, xm, ym, minThreshold, objType);
//Test the other half of the line:
o = collision_line(xm, ym, x2, y2, objType, true, true);
if (o > 0) return BinaryLineCollision(xm, ym, x2, y2, minThreshold, objType);
}
return o;
And as far as I can see it works. :)
Bonezmann
13-06-2008, 10:31 PM
Hi everyone, I'm new to the whole GM coding thing, so I have a question:
I want to save character information(as in RPG-like information) in an external file and load/save it after a match. Now I've done some searching in the GM7Pro helpfile, and it looks like I'll have to use this:
file_text_open_read(fname)
to load, and this
file_text_open_write(fname)
to save.
But because I'm new to this, I'm really going to need some help on this one.
I tried the "file_text_open_write(fname) but it gives me this error(although it does create the specified file):
___________________________________________
ERROR in
action number 1
of Mouse Event for Left Button
for object object0:
Error in code at line 1:
file_text_open_write(save1.txt)
at position 22: Unknown variable save1
Now the GM helpfile says that the "fname" is the name of the file to be opened if I'm reading this thing right. What am I doing wrong? I have tried saving it without the ".txt" too, does the same.
Also how would I go about saving info in this file? I'm not asking you to write the script for me, I just want some suggestions, same with the loading too.
I'd REALLY appreciate your help, I've been struggling with this since about 7pm.
Thanx in advance :)
dislekcia
14-06-2008, 01:23 AM
The filename has to be a string. That's why it's telling you it can't find a variable named save1 which it's trying to access a sub-property called txt on ;)
file_text_open_write("save1.txt");
-D
Bonezmann
14-06-2008, 10:08 AM
Thankx alot, I'll try that :)
Bonezmann
14-06-2008, 10:15 AM
___________________________________________
ERROR in
action number 1
of Mouse Event for Left Button
for object object0:
Error opening file for writing.
Still the same, can I save gamedata in txt files or should I use INI files?
Could someone give me an example of how the save code would work? (Just one line plz)
I've tried it my way, didn't work and I don't see it in the help file.
dislekcia
14-06-2008, 12:37 PM
Still the same, can I save gamedata in txt files or should I use INI files?
Could someone give me an example of how the save code would work? (Just one line plz)
I've tried it my way, didn't work and I don't see it in the help file.
That error means there's something else wrong... It could be as simple as the file existing but being write protected, the directory being full or write protected or even the game not having the right permissions to do file access if you're running Vista.
Otherwise, how are you doing your file writing? Remember that you need to open a file once and then use the handle it returns to keep editing it, not continuously open it every time you want to write data to it. Also, remember to close the file again ;)
As an example, in a file-logging object's creation event:
saveFile = file_text_open_write("save1.txt");
In any event after that where you want to save data:
file_text_writeln(saveFile, "Blah blah blah fishpaste");
And then in the destroy event:
file_close(saveFile);
Also, you might want to use ini files (despite them being very easy for a user to edit) if you're saving a lot of numbers, in a text file you'd have to pull any string you read apart, which can get a little complicated if you're not used to doing that...
-D
Bonezmann
14-06-2008, 07:37 PM
Thanx Dis, I'll check it out :)
FuzzYspo0N
16-06-2008, 12:08 PM
gosh. i cant get my game maker to work. i have a pro licence, any one have any special tricks about installing it on my "other pc" . i have two desktops. one will not work for game maker (it just crashes at startup with no feedback or anythin) and the other desktop says (after trying to reinstall the licnce) that i have already activated this product. then wtf call it RE-install if its not gonna let me REdo it. :P lol. any ideas?
dislekcia
16-06-2008, 01:52 PM
gosh. i cant get my game maker to work. i have a pro licence, any one have any special tricks about installing it on my "other pc" . i have two desktops. one will not work for game maker (it just crashes at startup with no feedback or anythin) and the other desktop says (after trying to reinstall the licnce) that i have already activated this product. then wtf call it RE-install if its not gonna let me REdo it. :P lol. any ideas?
Go to the YoyoGames site and use their error reporting system... They're supposed to give you more activations if you need them. I hate how GM7 is crippled by that these days.
-D
FuzzYspo0N
16-06-2008, 02:14 PM
its kinda fail , cos i contacted supprt at softwrap twice now no reply, and i have at least 3 tickets going on the error system. its just unresponsive, kinda frustrating. i wanna wotk with game maker for this 19 : entry im working on but i cant do jack.
Anyone got any physics engines for Gm to suggest? other than GMPhysics and what not?
Im looking for ragdolls :)
i remember recently seeing a game with it on this forum yes?
01DT!m3r
16-06-2008, 03:48 PM
How about the verlet physics . I think it was used in one of dis's prototypes .
FuzzYspo0N
16-06-2008, 04:04 PM
yea although without pro im kinda screwed, i have verlet physics here too, tho thanks for the suggestion there oldtimer
SkinkLizzard
16-06-2008, 06:21 PM
I have a similar problem Fuzzy
my pc had to be formatted, so reinstall gamemaker,
try to reinstall the license and it says my purchase ref number is not recognized.
ask for them to email me my details and on the email the place where the
license ref should be theres blank white space.
so I got it working through less honest methods until such time as
I can get the reinstall to work.
FuzzYspo0N
17-06-2008, 05:19 PM
well softwrap replied, and gave me more activations i will try just now, but by now iv written my framework in flash lol. so yea. kinda frustrating :D tho i dont own flash , so i am thinking i will rather head for gm.
SkinkLizzard
21-06-2008, 05:29 PM
Right I have me a question.
I wish to know the most effective way of changing an objects mode,
by mode I mean changing from physical being mode with its respective abilities and
hindrance's to spirit mode and back. I thought of making both character modes two separate objects both persistent and then just change from one to the other.
my other idea was to have all actions specific to a mode in a separate object and then just make the respective object the player objects parent and hoping it will inherit the necessary events and actions.
Oh yea this is in gm7
SkinkLizzard: In pea adventures I handled it all with one object as not much changes when I switch modes, but I think that if your aim is to have different controls and everything, have 2 objects (dont make them persistent) and then when you become a ghost destroy the original object and put the ghost where it should be and vice versa. Only thing is that you would need to handle score and similar things in a seperate object.
Kensei
15-08-2008, 11:31 PM
Ok, newbie question.
I realized that I need a bit more precise movement for my character in my game
And I feel like a newbie for asking this :(
What kind of code do I need to use in Game Maker for the avatar to move exactly to the grid?
At the moment, my code for each Key is:
1. Check if there is a collision 4 pixels to the direction I need to move
2. Jump to that position
I have experimented with Snap to Grid after, but it means I have to up the numbers (i.e. Jump to position 16 pixels) But then the avatar moves too quickly. :(
The reason I need this is otherwise it takes too long to fit between the trees.
dislekcia
16-08-2008, 12:22 AM
Ok, newbie question.
I realized that I need a bit more precise movement for my character in my game
And I feel like a newbie for asking this :(
What kind of code do I need to use in Game Maker for the avatar to move exactly to the grid?
At the moment, my code for each Key is:
1. Check if there is a collision 4 pixels to the direction I need to move
2. Jump to that position
I have experimented with Snap to Grid after, but it means I have to up the numbers (i.e. Jump to position 16 pixels) But then the avatar moves too quickly. :(
The reason I need this is otherwise it takes too long to fit between the trees.
Do you want your character to move smoothly?
Do you want the character to only move in a direction when in line with a grid?
Do you want your character to jump to a grid position but then stay there for a while?
What's wrong with what you've got now? It seems like it would move 16 pixels in 4 frames?
You could do something like this for smooth movement:
if (allowpresses) {
lcount = 4;
allowpresses = false;
}
if (allowpresses = false) {
if (lcount > 0) {
lcount -= 1;
x -= 4;
}
if (lcount == 0) {
allowpresses = true;
}
}
This will pretty much keep you moving on a 16x16 grid if you place the character on the grid to start with. As for collision you can then just use collision_rectangle() to make sure you can always find if there is something on the block of the grid that you are moving to, which would change the code for the if statement slightly to check if objects are there. (If you are going to have a grass object there is a small change to this that you could use which is not too difficult and will allow you to distinguish between floor and collideable objects)
if (allowpresses) and (!collision_rectangle(x+16,y,x+32,y+16,all,true,tr ue)) {
Its roughly how I was doing it when I played arounf with RPG movement, but I no longer have the prototypes, will keep looking.
SplaT
20-08-2008, 10:34 PM
Sorry to pop in so rudely like I just did.
Can someone please help me with some GM logic?
I have two objects. Now what I want to have happen is if you click on object B, object A should move towards object B until the distance between them is about eg. 50.
This is top-down, so object A could come from any direction.
I tried all sorts of noobish tricks:
distance_from_object
collision_circle
draw_arrow
just_do_it_already_and_stop_complaining_about_unkn own_function_or_script();
And each time I ended up with such a mess, GameMaker disabled my undo button until further notice.
I beg of anyone, on my bended knees. Halp!
Squid
20-08-2008, 11:01 PM
Try something like this:
while (point_distance(object1x,object1y,object2x,object2 y)>50){
motion_set(point_direction(object1x,object1y,objec t2x,object2y),5);
}
SplaT
21-08-2008, 07:01 AM
Try something like this:
Thanks, Squid. First time I saw the motion_set code. I seriously can't imagine how you are able to remember all this.
Anyway, this code seems to bring the game to a halt, forcing me to Ctrl+Alt+Delete out of it.
Not sure why. Maybe it stuck in some kind of endless loop or something. (Not that I would know what that means.)
Kensei
21-08-2008, 01:04 PM
Could create an instance of object A that is moving and use the 'move towards' function?
Then, create a collision circle that when object A enters this area, it stops?
make sense?
(I know its a lot less elegant than Squids one)
Edit: Looking at Squid's solution I can see why it might be an endless loop, because if you look at it, the distance decreases until its 50 then, it remains at 50 but it is likely still moving?
Perhaps add a command that stops the object... i.e. motion_set(0,0) ?
SplaT
21-08-2008, 03:49 PM
Basically what I'm trying to do is; If the player clicks on an NPC, the player's character should be within a certain range to be able to interact with this NPC, ie. Not being able to talk to a character who is on the other side of the room. If the character is out of range, he moves closer before a dialogue can begin.
Kensei: Thanks, will try something like that as well. I'm at work right now, so I'll only be able to work on it again late tonight. (Makes me sad). I didn't pay collision_circle much attention, as it seems to be a lil complicated for my tiny little anti-coding brain.
Maybe Squid's example code didn't work because it's conflicting with other movement codes. Figuring it out is the hardest part for me. (Might I add; also the best part if I finally get it to work.)
Kensei
21-08-2008, 04:24 PM
Basically what I'm trying to do is; If the player clicks on an NPC, the player's character should be within a certain range to be able to interact with this NPC, ie. Not being able to talk to a character who is on the other side of the room. If the character is out of range, he moves closer before a dialogue can begin.
:D Funny that. I have the same concept in my game, but I don't force the user to move closer, I just make the icon above the NPC change to denote that the player is close enough for conversation - you could try that kind of idea if you want, have a exclamation point above the NPC that turns yellow when the player is close enough.
SplaT
22-08-2008, 10:24 AM
Thanks, Kensei. ^_^ I guess that it is actually a really good and valid workaround.
It actually bothers me not to be able to solve the problem. It seems to be a really simple concept.
Kensei
22-08-2008, 11:51 AM
I know the feeling.
::remembers shouting at the screen saying 'Just give him the DAMN item!' ::
dislekcia
22-08-2008, 02:15 PM
Thanks, Kensei. ^_^ I guess that it is actually a really good and valid workaround.
It actually bothers me not to be able to solve the problem. It seems to be a really simple concept.
It sounds like your problem is coming from having player movement overpower what you're trying to do to get the player close to the NPC in question.
The way to prevent this is to use states in your movement:
If movementMode is normal, the player moves normally
else if movementMode is get closer to NPC, the player moves towards the target NPC.
Any states that aren't the normal one need to have checks in them to make them stop when their desired position has been reached and send the player back to normal mode.
Does that make sense?
SplaT
22-08-2008, 03:13 PM
Yes, that does make sense. I believe I'll be able to pull that off given enough alcohol.
The thing is, I really didn't expect to have to go that far and complicated just to get one object act in that way.
Thanks Dis.
=D
Edit: Actually, now it makes perfect sense that it would do what it did. Most of my attempts ended up with the character spinning, dancing and sliding all over the place. One script was telling it to stop, while another script was telling it (in the Step event) to move to a certain point that theoretically shouldn't be valid anymore.
*slaps forehead*
Kensei
22-08-2008, 10:06 PM
Fairly silly question :(
How do I make a splash screen in Game Maker?
SkinkLizzard
22-08-2008, 10:54 PM
splash_show_video(fname,loop) Shows a video splash screen. fname is the name of the video file. Whether a particular movie file is supported depends on the drivers on the machine. Typically you can use .avi, .mpg, and .wmv files but avoid special codecs. You best put this file in the folder of the game yourself or in a subfolder. loop indicates whether to loop the video.
splash_show_text(fname,delay) Shows a text splash screen. fname is the name of the text file. You can either display standard text files (.txt) or rich text files (.rtf). Rich text files can e.g. contain images. delay indicates the delay in milliseconds before returning to the game. use 0 to wait until the player presses the escape key or clicks with the mouse in the window.
splash_show_image(fname,delay) Shows an image splash screen. fname is the name of the image file. Many image types are supported (for example .bmp, .jpg, .tif, and .wmf) but no animated images. delay is the delay in milli seconds before returning to the game.
:)
dislekcia
23-08-2008, 12:28 AM
Thanks Skinklizzard, I had no idea those commands existed :)
Sweet!
SkinkLizzard
24-08-2008, 04:39 PM
heh no prob :) only reason I know of them is because I used them in my entry for the last comp,
well sort of anyway. I definitely love that tome of knowledge the gm help file though :) tis awesome.
now if only there where a way of making easy pop up menu/dialogue things for stuff like level up
and inventory.. also a decent method of pausing background action, if any one has some tips it'd be much appreciated :)
dislekcia
25-08-2008, 01:00 PM
heh no prob :) only reason I know of them is because I used them in my entry for the last comp,
well sort of anyway. I definitely love that tome of knowledge the gm help file though :) tis awesome.
now if only there where a way of making easy pop up menu/dialogue things for stuff like level up
and inventory.. also a decent method of pausing background action, if any one has some tips it'd be much appreciated :)
I tend to build pop up menus and inventories by creating a parent popup object which I then subclass and stick all the other objects it needs for interaction in it's creation event. The interaction objects are subclasses of things like PopupButton or PopupTextfield which all use their parentPopup as a positioning device. Their parentPopup value is set when they're created by said parent popup ;)
Interface programming is one of the nastier parts of game development.
The most flexibile pause method I've found so far in GM is to use a global pause level. Essentially we give each type of object a value called pauseLevel and set global.pauseLevel to whatever "depth" of pausing we want and then stick one extra line of code at the beginning of all events on objects that cause things to happen - typically keypresses, step events, etc:
if (global.pauseLevel >= pauseLevel) return;
This will not execute the code in the rest of the event if global.pauseLevel is higher or the same as our object's pauseLevel. Meaning you can have a room populated by normal objects that have pause levels of 1 and as soon as you pop up a menu you can set global.pauseLevel to 1 and have everything but the menu stop reacting because the menu's pause level is 2.
With some clever parenting you could even create a Pauseable object type and have that stop progress if it needs to on child types.
At the moment we're using something similar in effect in XNA but rather different in execution ;) Our objects are all stored in scenes which exist in a stack. Only the scene on top of the stack is updated, the rest are all rendered every frame. This means that when we shove our interface scene on top of the stack, that's the only one that responds to input.
Chippit
25-08-2008, 03:52 PM
At the moment we're using something similar in effect in XNA but rather different in execution ;) Our objects are all stored in scenes which exist in a stack. Only the scene on top of the stack is updated, the rest are all rendered every frame. This means that when we shove our interface scene on top of the stack, that's the only one that responds to input.
I have a system something like that myself and it's working for me rather adequately. I thought it was rather elegant in execution. :P
SkinkLizzard
25-08-2008, 06:04 PM
Thank you dis very helpful :)
Ok, I have run into a problem, and I cant think of anything that will work nicely offhand, but Im sure I'll get help from the forum ;)
I have to write a script that looks for a chain of blocks next to a certain block, and then remove them IF there is 4 or more touching (colour based). just a basic efficient method of making a chain to find if its four or more and then im set and can get to work on graphics for it.
ShadowMaster
26-08-2008, 02:52 PM
edg3: Well if only the last block added can cause a chain, just check it's neighbours and their's if the neighbours are the right colour and so on, kinda like a flood fill. Should be fast enough if the grid is 5x5 as you mentioned.
Then if you can cause chain reactions, check the blocks that fell and remove their chains.
Ask if you need the actual implementation :)
Well, what if there is a chain of 10 or more blocks?
(implementation of the 5x5 would be easy, thanks :) )
ShadowMaster
26-08-2008, 07:33 PM
The algorithm I have in mind is basically this: http://en.wikipedia.org/wiki/Flood_fill
1. Create a 2D array containing the game board("virtual board").
2. Create an array to hold the queue to process("queue") and the tiles to pop("pop-array") and note its colour.
3. Add the last tile that dropped to the queue.
4. Make that tile on the virtual board equal to an empty tile(don't change the game board just yet).
5. Now loop through the following until the queue is empty:
-Remove the first tile from the queue
-Add the tile to the end of the pop-array.
-Check which of its four neighbours are the same colour on the virtual board.
-Change the their values of the tiles on the virtual board to empty.
-Add the tiles that are valid to the end of the queue.
-Repeat
6. Check if the pop-array is of the correct length and pop the tiles from the true board if it is.
If you want to create a wave effect (ie. the tiles popping from the first tile outwards) do the following:
Mark each tile in the pop-array with its depth.
Firstly you need to mark the depth of the tile in the queue as well.
Set the first tile to a depth of 0.
Then when you add new tiles to the queue make their depth equal to the tile whose neighbours they are(the one you pop from the queue) plus one.
Then just carry the value from the queue over to the pop-array.
The tiles will be sorted according to depth if you use the flood fill algorithm I told you to. So you can just pop until the depth changes, wait for the animation to finish and then pop again and so on.
Ok, I have throw it together roughly in game maker, but Im getting issues, like it doesnt delete both block in a chain of 2, and throws up fuss about the variable "delflag" even though its present in every object in the game. Im hoping someone can ind the error in it, as I have been working on it all afternoon.
fd = false;
if (l) {
if (l.colour == testing_colour) {
fl = true;
} else {
fl = false;
}
}
if (r) {
if (r.colour == testing_colour) {
fr = true;
} else {
fr = false;
}
}
if (u) {
if (u.colour == testing_colour) {
fu = true;
} else {
fu = false;
}
}
if (d) {
if (d.colour == testing_colour) {
fd = true;
} else {
fd = false;
}
}
o = instance_position(_x,_y,o_parent);
if (fl) or (fd) or (fu) or (fr) {
o.delflag = true;
}
if (fl) then if not (l.delflag) then scr_deleter(testing_colour,_x-32,_y);
if (fr) then if not (r.delflag) then scr_deleter(testing_colour,_x+32,_y);
if (fu) then if not (u.delflag) then scr_deleter(testing_colour,_x,_y-32);
if (fd) then if not (d.delflag) then scr_deleter(testing_colour,_x,_y+32);
if (o.delflag) {
with (o)
{
instance_destroy();
}
}
return 0;
dislekcia
28-08-2008, 06:36 PM
I always use an object-based approach to the problem: First I make sure all my objects origins are central, then I create an invisible object on the recently moved/clicked/dropped/whatever element which does the following...
Checks to see if it there is another of its type at it's current position, if true it destroys itself.
Checks to see if there's an object of the "match three" type at the current position, if not it destroys itself.
Checks to see if the match object has the same attribute that we're checking for (colour, size, hairdo, etc), if not it destroys itself.
Creates new instances of itself in all the directions that matching elements might exist in, be they a hex, a grid, whatever.
Then it sets alarm[0] to 1.
In alarm[0] it kills itself and the underlying match object.
All you need to do to use this type of logic is put a check around your game logic to make sure that no instance of the "clearer" object exist, if they do you have to wait until you can resume interaction. Simple. Plus it's a nice way to have launching points for effects on the blocks that die :)
ShadowMaster
28-08-2008, 08:10 PM
Ok here is the full code (note the top section):
var testing_colour,_x,_y;
testing_colour = argument0;
_x = argument1;
_y = argument2;
effect_create_above(ef_ring,_x+16,_y+16,0.1,c_whit e);
var l,r,u,d,fl, fr, fu, fd, o;
l = collision_point(_x-32,_y,o_parent,true,true);
r = collision_point(_x+32,_y,o_parent,true,true);
u = collision_point(_x,_y-32,o_parent,true,true);
d = collision_point(_x,_y+32,o_parent,true,true);
fl = false;
fr = false;
fu = false;
fd = false;
if (l) {
if (l.colour == testing_colour) {
fl = true;
} else {
fl = false;
}
}
if (r) {
if (r.colour == testing_colour) {
fr = true;
} else {
fr = false;
}
}
if (u) {
if (u.colour == testing_colour) {
fu = true;
} else {
fu = false;
}
}
if (d) {
if (d.colour == testing_colour) {
fd = true;
} else {
fd = false;
}
}
o = instance_position(_x,_y,o_parent);
if ((fl) or (fd) or (fu) or (fr)) {
o.delflag = true;
}
if (fl) then if not (l.delflag) then scr_deleter(testing_colour,_x-32,_y);
if (fr) then if not (r.delflag) then scr_deleter(testing_colour,_x+32,_y);
if (fu) then if not (u.delflag) then scr_deleter(testing_colour,_x,_y-32);
if (fd) then if not (d.delflag) then scr_deleter(testing_colour,_x,_y+32);
if (o)
{
if (o.delflag)
{
with (o)
{
instance_destroy();
}
}
}
return 0;
The fix for the delflag error is simple, replace the recursing code with the following:
if (fl && instance_exists(l)) then if not (l.delflag) then scr_deleter(testing_colour,_x-32,_y);
if (fr && instance_exists(r)) then if not (r.delflag) then scr_deleter(testing_colour,_x+32,_y);
if (fu && instance_exists(u)) then if not (u.delflag) then scr_deleter(testing_colour,_x,_y-32);
if (fd && instance_exists(d)) then if not (d.delflag) then scr_deleter(testing_colour,_x,_y+32);
Why it doesn't work:
Sometimes when the recursion exists you may have already deleted the object you are checking so you just have to check again.
The fix for the all tiles in the chain not getting deleted, replace the definition of u, d, l, r with:
l = instance_position(_x-32,_y,o_parent);
r = instance_position(_x+32,_y,o_parent);
u = instance_position(_x,_y-32,o_parent);
d = instance_position(_x,_y+32,o_parent);
Why it doesn't work:
For some reason the old code didn't detect the first object in the chain from it's adjacent objects. Causing all the objects adjacent to only the starting object not to be deleted. Problem is don't know why collision point would cause this. Anyone have any possible reasons?
[EDIT]: Slight bug in the second fix, forgot to change first function to instance_position.
Kensei
30-08-2008, 02:06 PM
Okay, silly question time:
How do I use arguments in scripts in Game maker?
i.e. if I want a script to run that changes the object's sprite to blue and plays a sound then respawns the player at the beginning?
At the moment, without any declarations, it doesn't change the object's sprite index, but it does play the sound and, by using x =xstart, it does place the object back at the beginning.
Thus I am wondering if its a case of it not knowing what object to change its sprite index.
I know how to put the values for the variable, just not how to declare them in the actual script code
|-|1Pp13
30-08-2008, 02:23 PM
Okay, silly question time:
How do I use arguments in scripts in Game maker?
i.e. if I want a script to run that changes the object's sprite to blue and plays a sound then respawns the player at the beginning?
At the moment, without any declarations, it doesn't change the object's sprite index, but it does play the sound and, by using x =xstart, it does place the object back at the beginning.
Thus I am wondering if its a case of it not knowing what object to change its sprite index.
I know how to put the values for the variable, just not how to declare them in the actual script code
hmmm. if i understand correctly, you can use (in the script)
argument0.sprite_index=new_sprite_index
when you call the script put the object name in argument0
ie
Script_name(Your_objects_name,argument1,argument2. ..)
(correct me if im wrong Dis)
ShadowMaster
30-08-2008, 05:59 PM
Say you call your script: MyScript
Where you call your script in your objects, you do it like you would call any function with parameters:
MyScript(*param1*, *param2*, ...)
When writing the script you ignore the arguments in the declaration and only write the name.
The arguments are implicitly set to the variable argument0 to argument15, that is the first parameter passed to the script is automatically set to argument0, the second to argument1 and so on. So if you want to get first parameter you type argument0.
For example in script code:
//MyScript
name = argument0;
something_else = argument1;
Or if you prefer accessing them in an array context:
//MyScript
name = argument[0];
something_else = argument[1];
Note: if you try to access parameters not set in the script call, then those parameters will be set to 0. You won't get an error, which can be good or bad depending on the situation.
For instance, you call my script with:
MyScript(1)
then argument0 will be equal to 1 and argument1 to 0 in the script code.
EDIT: I've read your question again and saw I missed a bit.
When using the keyword self, or other for that matter, you cannot access the variables of that instance like you normally would, you need to use the with construct.
So instead of:
self.sprite_index = spr_something;
You have to do:
with (self)
{
sprite_index = spr_something;
}
The with construct basically causes everything enclosed in the block to act as if they were in the instance you gave the with construct (self in this case).
This is why passing the self keyword to a script is pointless.
This is because self isn't the instance ID of the object you call it in but rather some constant number, which makes it useless for most cases (I can't actually think of one where it is useful).
To get the instance ID you have to access the built in variable in all objects: id
That is the ID you will have to pass to scripts or other objects if you want them to access that object.
However this is all pointless (but good to know) because a script can access all the variables of the instance it's called from directly, without need of the instance's ID. This is useful so to change the sprite_index of the calling instance, just go in the script:
sprite_index = spr_something;
Kensei
30-08-2008, 10:33 PM
However this is all pointless (but good to know) because a script can access all the variables of the instance it's called from directly, without need of the instance's ID. This is useful so to change the sprite_index of the calling instance, just go in the script:
sprite_index = spr_something;
Thanks, it still does not display the sprite though :(
I have this:
objFocus = argument0;
with(objFocus)
{
sound_play(moan);
sprite_index = spr_rip;
sleep(2500);
sprite_index = spr_avatar;
x = xstart;
y = ystart;
}
it is incredibly confusing as it does everything else BUT change the sprite :( And I know the sprite exists because this all works when I create this entire process via the drag and drop objects... I'll keep looking at it
ShadowMaster
30-08-2008, 10:54 PM
Does it change the sprite to spr_avatar? If so I know what the problem is.
Thing is GameMaker isn't multithreaded. So when you tell it to sleep nothing happens, it stays in the script, the screen isn't even redraw! Then only after when you've changed the sprite back to normal does it get drawn.
A better way would be to use an alarm or a variable, switch_back, that decrements each step until it gets to zero and turns the sprite back. Then in the script you would set the variable to how ever many steps you want it to stay with the new sprite.
The alarm requires less code from you and if I'm not mistaken I think this is how you do it (this is the first time I ever use one;) ). It is basically the same as the method I described above, but with less annoying management code:
Create an alarm 0 event and put the following code in it:
sprite_index = spr_avatar;
x = xstart;
y = ystart;
Replace the script with:
objFocus = argument0;
with(objFocus)
{
sound_play(moan);
sprite_index = spr_rip;
alarm[0] = 50; // or however many frames you want the thing to stay the way it is.
}
Also another suggestion I would give you, that is of no bearing on any questions you have asked, is to declare your variables that are only gonna be used in script or a certain event with the var keyword, that way the variables will be deleted after the script or event ends and save memory. And more importantly if the user of a script has a variable in his instance with the same name as the one you use in the script the changes you make in the script to that variable won't affect the variable in the instance.
Kensei
31-08-2008, 12:42 AM
Awesome, it works :D
Thanks
kolle_hond
01-09-2008, 02:14 PM
*EDIT*
No problem I figured it out
dislekcia
01-09-2008, 06:34 PM
*EDIT*
No problem I figured it out
Nice... I waited too long to reply, apparently ;)
kolle_hond
07-09-2008, 03:07 PM
Ok, what I am trying to accomplish is to get all instances of one of my objects to check right beneath it for another object and if there are none its vspeed should become 5 (just for that specific instance, not all instances of the object). I have tried a few diffrent ways but none give the desired effect. Plz help.
dislekcia
07-09-2008, 04:05 PM
Ok, what I am trying to accomplish is to get all instances of one of my objects to check right beneath it for another object and if there are none its vspeed should become 5 (just for that specific instance, not all instances of the object). I have tried a few diffrent ways but none give the desired effect. Plz help.
If you tell us what you've tried we can help you figure out the logic problems and set you straight :)
The platformer tutorial from the Yoyogames site does something very similar, BTW.
kolle_hond
07-09-2008, 04:27 PM
The platformer tutorial from the Yoyogames site does something very similar, BTW.
thanks, that helped me to get it right :D
01DT!m3r
07-09-2008, 05:07 PM
Hi everyone . I need some help with starting in 3d i have been using 2d for a long time and i would like to start programming in 3d . I am currently trying out various 3d libraries such as panda3d and irrlicht. Please can someone link me to a neat beginners tutorial on either of the above . Or does anyone have any suggestions of where i should start in 3d programming . Thanks
Higushi
07-09-2008, 05:18 PM
Erm.... This is the Game Maker help thread...
I saw a 3D engine thingy here, on the forums: delta3d (http://forums.tidemedia.co.za/nag/showthread.php?t=7386)
Maybe post a new thread to get more help on this.
Just to point out: Game Maker also offer 3D, and honestly, getting into 3D can be a bit tedious from 2D game development.
One suggestion I do have is that once you have chosen what you are going to use for your 3D game you should stick to that.
Some stuff about GM 3D that came up on the forums (might be helpful to you)
http://forums.tidemedia.co.za/nag/showthread.php?t=496
As for a suggestion of what to use, I found XNA quite easy to start off with and get into, and perhaps you want to look at that? Theres tons of resource now, and if you want help, various game.dev people are using it currently (Dream Build Play times). If you would like an example of what you could expect to write to get 3D in XNA heres a working (albeit buggy) pong: thread (http://forums.tidemedia.co.za/nag/showthread.php?t=6289) | source (http://realdev.co.za/node/10832)
Gazza_N
07-09-2008, 06:44 PM
Just to point out: Game Maker also offer 3D, and honestly, getting into 3D can be a bit tedious from 2D game development.
Be warned: Game Maker's 3D is... finicky compared to standard 2D. However, check out the GMC forums (http://gmc.yoyogames.com/), which has a subforum dedicated to 3D stuff. It's been invaluable to me over the course of Deathbringer's development.
Otherwise, you really can't go wrong with XNA, although you'll need to delve a little deeper into the technical side of 3D if you choose to go that route.
|-|1Pp13
07-09-2008, 06:54 PM
I need to set a variable of an object to the id of the object that created it
IE-
objectCreator creates objectChild
objectChild.variable=objectCreator.id
(i have multiple objectCreator's)
I need to set a variable of an object to the id of the object that created it
IE-
objectCreator creates objectChild
objectChild.variable=objectCreator.id
(i have multiple objectCreator's)
you can try this to create the object:
var _o,_id;
_o = instance_create(x,y,objectChild);
_id = instance_id;
with (_o) {
creatorID = _id;
}
or just like you said:
_o.Variable = value;
(unless I am failing at rememberance right now)
|-|1Pp13
07-09-2008, 07:48 PM
well, the exact code i have is:
vNoOfChildren=round(random(3))+1
if vNoOfChildren>gvMaxLineCreate then vNoOfChildren=gvMaxLineCreate
vCreatorID=id
for (i=1;i<=vNoOfChildren;i+=1)
{
ID=instance_create(x,y,oLine)
ID.vParent=vCreatorID
vChildren[i]=ID
}
using Run game in debug mode, i check what vParent is and its the objects id
IE
Expression Value
100084.vParent 100084
dislekcia
07-09-2008, 10:50 PM
Could your variable naming be causing problems? I know GM is case-sensitive, but I wouldn't call a variable "ID" ... try naming it something else.
|-|1Pp13
08-09-2008, 08:02 PM
Could your variable naming be causing problems? I know GM is case-sensitive, but I wouldn't call a variable "ID" ... try naming it something else.
Changed it to vID, also included
var vID at the begining
still not working
dislekcia
08-09-2008, 10:48 PM
Changed it to vID, also included
var vID at the begining
still not working
Ok, next thing to check is to make sure that your code is actually running... Make sure that gvMaxLineCreate isn't 0. Also, try sticking a show_message(string(vID) + " " + string(vCreatorID)) after your array assignment line, but still inside the loop. That'll pop up a message box with the values of both those variables in it. If it doesn't pop up, you're not reaching that code...
|-|1Pp13
09-09-2008, 08:43 PM
Ok, next thing to check is to make sure that your code is actually running... Make sure that gvMaxLineCreate isn't 0. Also, try sticking a show_message(string(vID) + " " + string(vCreatorID)) after your array assignment line, but still inside the loop. That'll pop up a message box with the values of both those variables in it. If it doesn't pop up, you're not reaching that code...
hmmm, since i added the message code it seems to work fine =? my GM does strange things sometimes =P
Did find a problem with an infinite loop somewhere else in my code =P
Ill upload a demo with the source probably tomorrow or the day after
Thanks for the help :)
Pietersielie
05-10-2008, 09:42 PM
Hello everyone in the game I'm creating your character can talk to other char. I know how to do the dialog but does anyone know how to disable the characters during the time the dialogs appear?
FuzzYspo0N
06-10-2008, 09:30 AM
That depends on how your characters are being created and used. But by disable im assuming you mean you dont want the player to be able to walk around while talking to the other character?
For example a variable under the player object :
inDialog = false;
Then, when your character starts talking to someone,
player.inDialog = true;
Then, in your movement code (or using the block begin and end statements in the draggy list thing)
If player.inDialog = false
//make the player move here.
This basically means, when player is talking, the movement code will not run, and or the statements to move will not get there.
_joejoe_
07-10-2008, 08:49 PM
Hello! I'm trying to create a 2d platforming game, but I'm having some problems.
How does one code multiple jumps?
Well, in Pea Adventures I used two variables, one for initial jump (which you can only activate on a solid surface) and then the other can only be initiated when in a jump. I basically use vspeed to make the jump. I set it to negative 12 each time, and add one each step to give a smooth jump. When it hits 0 Im no longer jumping and my fall code takes place, increasing vspeed till I find a collision, then I just set my y value to the collision y - sprite height. Its not overly difficult to implement. If you want I can give you a code example in the morning?
_joejoe_
07-10-2008, 09:29 PM
Well, in Pea Adventures I used two variables, one for initial jump (which you can only activate on a solid surface) and then the other can only be initiated when in a jump. I basically use vspeed to make the jump. I set it to negative 12 each time, and add one each step to give a smooth jump. When it hits 0 Im no longer jumping and my fall code takes place, increasing vspeed till I find a collision, then I just set my y value to the collision y - sprite height. Its not overly difficult to implement. If you want I can give you a code example in the morning?
*brain implodes*
Erm... please do. XD
Sorry, I'm kinda new to this.
With pleasure! :)
Here is my simplified code, using descriptive variable names :) if it doesnt work I'll have made a mistake somewhere while writing it from scratch, but you can compare it to my original code at the bottom:
jumping = false;
doubeljumping = false;
//check if there is something below us 32x32 sprite with origin in the center
are_we_on_something = collision_line(x-16,y+19,x+16,y+19,o_block,true,true);
if not jumping and are_we_on_something {
jumping = true;
vspeed = -12;
} else if not doublejumping {
doublejumping = true;
vspeed = -12;
}
//check if there is something below us 32x32 sprite with origin in the center as far down as we are falling
check_for_a_block_below = collision_line(x-16,y+18+vspeed+1,x+16,y+18+vspeed+1,o_block,true,t rue);
if jumping and vspeed < 0 {
//increase vspeed by 1 if its smaller then zero
vspeed += 1;
jumping = false;
doublejumping = false;
} if not check_for_a_block_below {
vspeed += 1;
} else {
our_floor_block = collision_line(x-16,y+18+vspeed+1,x+16,y+18+vspeed+1,o_block,true,t rue);
y = our_floor_block.y - 16;
vspeed = 0;
}
Note that this code is messy and can be rewritten a lot better then it is... ;)
Original code from Pea Adventures:
STEP EVENT:
//check to see if we are on something
//this makes sure that we do not fall through stuff unnecesarily with the fall code
if (collision_line(x-16,y+18,x+16,y+18,o_block,true,true)) && (j != 1) {
vspeed = 0;
//check to see if we are jumping as we arent on something
} else if (j == 1) {
//double jump check
if (j_ == 1) {
jcount = min_v;
j_ = 0;
}
//normal jump start
if (jcount == 0) {
jcount = min_v;
//main jump code
} else {
jcount += 1;
if (jcount == 0) {
j = 0;
j_double = 0;
j_ = 0;
}
}
//check if there is a collision where we move up to
if (!collision_line(x-16,y-18+vspeed-1,x+16,y-18+vspeed-1,o_block,true,true)) {
vspeed = jcount;
//if there is a ceiling, end the jump and
} else {
vspeed = 0;
j = 0;
jcount = 0;
j_ = 0;
j_double = 0;
}
//fall very nicely
} else if (cr == 0) and (cl == 0) {
//while there is no collision increase vspeed (increasing fall speed)
if (! collision_line(x-16,y+18+vspeed+1,x+16,y+18+vspeed+1,o_block,true,t rue) ) {
if (vspeed < max_v) { vspeed += 1; }
//as soon as there is a collision, we move to the designated height that we should stop at
//we also stop moving
} else {
ii = collision_line(x-16,y+18+vspeed+1,x+16,y+18+vspeed+1,o_block,true,t rue);
y = ii.y - 1 - 18;
vspeed = 0;
}
}
CREATE EVENT
//jump variables
j = 0; //jump
jcount = 0; //jump count
j_double = 0; //double jump
j_ = 0; //init var for double jump
UP KEY PRESSED EVENT
if (j_double == 0) && (j == 1) {
j_double = 1;
j_ = 1;
sound_play(s_boing);
}
if (j == 0) and (collision_line(x-16,y+19,x+16,y+19,o_block,true,true)) {
j = 1;
sound_play(s_boing);
}
_joejoe_
09-10-2008, 08:17 PM
With pleasure! :)
Here is my simplified code, using descriptive variable names :) if it doesnt work I'll have made a mistake somewhere while writing it from scratch, but you can compare it to my original code at the bottom:
Note that this code is messy and can be rewritten a lot better then it is... ;)
Original code from Pea Adventures:
STEP EVENT:
//check to see if we are on something
//this makes sure that we do not fall through stuff unnecesarily with the fall code
if (collision_line(x-16,y+18,x+16,y+18,o_block,true,true)) && (j != 1) {
vspeed = 0;
//check to see if we are jumping as we arent on something
} else if (j == 1) {
//double jump check
if (j_ == 1) {
jcount = min_v;
j_ = 0;
}
//normal jump start
if (jcount == 0) {
jcount = min_v;
//main jump code
} else {
jcount += 1;
if (jcount == 0) {
j = 0;
j_double = 0;
j_ = 0;
}
}
//check if there is a collision where we move up to
if (!collision_line(x-16,y-18+vspeed-1,x+16,y-18+vspeed-1,o_block,true,true)) {
vspeed = jcount;
//if there is a ceiling, end the jump and
} else {
vspeed = 0;
j = 0;
jcount = 0;
j_ = 0;
j_double = 0;
}
//fall very nicely
} else if (cr == 0) and (cl == 0) {
//while there is no collision increase vspeed (increasing fall speed)
if (! collision_line(x-16,y+18+vspeed+1,x+16,y+18+vspeed+1,o_block,true,t rue) ) {
if (vspeed < max_v) { vspeed += 1; }
//as soon as there is a collision, we move to the designated height that we should stop at
//we also stop moving
} else {
ii = collision_line(x-16,y+18+vspeed+1,x+16,y+18+vspeed+1,o_block,true,t rue);
y = ii.y - 1 - 18;
vspeed = 0;
}
}
CREATE EVENT
//jump variables
j = 0; //jump
jcount = 0; //jump count
j_double = 0; //double jump
j_ = 0; //init var for double jump
UP KEY PRESSED EVENT
if (j_double == 0) && (j == 1) {
j_double = 1;
j_ = 1;
sound_play(s_boing);
}
if (j == 0) and (collision_line(x-16,y+19,x+16,y+19,o_block,true,true)) {
j = 1;
sound_play(s_boing);
}
Ooh...
Thanks! I'll give it a shot!
Thanks, I owe you one!
The Dash
11-10-2008, 12:06 PM
Hi guys, im having a little DLL trouble, i've created a dl in delphi and am using it in one of my games, the dll basically takes a string and converts it to the asci values, and vice versa, EG: aaa becomes 065065065.
i keep getting an access violation error when i try run my program, ive copied the code into a separate program, into a new unit and changed one or two things so it runs, and the code itself is fine, so the only thing i can find is wrong must be in gamemaker.
the problem seems to be in the
external_call(id,arg1,arg2,...)
piece of code, but when i comment that out, the program runs, but when i end the program i still get the access violation error (and yes, i do call external_free(dll) in the Game End event )
so any help would be greatly appriciated thanx
EDIT: i have tried using the Extention maker, but get the same error when i call the function
Actualy, here is the code for the string to integer conversion:
var
OutputNumber:real;
function Encrypt(Input:ShortString):real; cdecl;
var
i:integer;
iOrd:integer;
sOrd:string;
sFinalString:string;
begin
for i := 1 to length(input) do //how naby characters to do
begin
iOrd:=Ord(Input[i]);
sOrd:=IntToStr(iOrd); //getting the asci values and converting them to string
if length(sOrd)<3 then
sOrd:='0'+sOrd; //making sure they are three digits (EG a only = 65, and i want 065)
sFinalString:=sFinalString+sOrd; //building up the final string
end;
OutputNumber:=StrToFloat(sFinalString); //returning the result
result:=OutputNumber;
end;
exports Encrypt;
EDIT2: im not sure if this is the right code, i seem to remember making a change somewhere and it worked, not sure what or where though =P
PS: wow long post for my first one :P
EDIT3: i did this using gamemaker scripts and it worked, i just want to get it working using a dll =P
01DT!m3r
11-10-2008, 12:23 PM
Hi guys, im having a little DLL trouble, i've created a dl in delphi and am using it in one of my games, the dll basically takes a string and converts it to the asci values, and vice versa, EG: aaa becomes 065065065.
i keep getting an access violation error when i try run my program, ive copied the code into a separate program, into a new unit and changed one or two things so it runs, and the code itself is fine, so the only thing i can find is wrong must be in gamemaker.
the problem seems to be in the
external_call(id,arg1,arg2,...)
piece of code, but when i comment that out, the program runs, but when i end the program i still get the access violation error (and yes, i do call external_free(dll) in the Game End event )
so any help would be greatly appriciated thanx
EDIT: i have tried using the Extention maker, but get the same error when i call the function
Actualy, here is the code for the string to integer conversion:
var
OutputNumber:real;
function Encrypt(Input:ShortString):real; cdecl;
var
i:integer;
iOrd:integer;
sOrd:string;
sFinalString:string;
begin
for i := 1 to length(input) do //how naby characters to do
begin
iOrd:=Ord(Input[i]);
sOrd:=IntToStr(iOrd); //getting the asci values and converting them to string
if length(sOrd)<3 then
sOrd:='0'+sOrd; //making sure they are three digits (EG a only = 65, and i want 065)
sFinalString:=sFinalString+sOrd; //building up the final string
end;
OutputNumber:=:=StrToFloat(sFinalString); //returning the result
result:=OutputNumber;
end;
exports Encrypt;
EDIT2: im not sure if this is the right code, i seem to remember making a change somewhere and it worked, not sure what or where though =P
PS: wow long post for my first one :P
EDIT3: i did this using gamemaker scripts and it worked, i just want to get it working using a dll =P
you have two := by outputnumber,thats what I could pick up
The Dash
11-10-2008, 12:26 PM
oh, copy past error :P
EDIT: fixed :P
dislekcia
11-10-2008, 02:30 PM
Well, my first reaction was "But you can do this internally inside GM without the DLL" but if you're determined to do it and the code works when you call it from somewhere else, then it means something rather specific: Take a look at your input format that you're using for the function in the DLL. It could well be that GM is giving you a differently formatted string, GM's DLL help should tell you how the strings it uses are defined, they might not wrap to Delphi's shortstring format (which I've never heard of, to be honest).
The Dash
11-10-2008, 02:40 PM
Take a look at your input format that you're using for the function in the DLL. It could well be that GM is giving you a differently formatted string, GM's DLL help should tell you how the strings it uses are defined, they might not wrap to Delphi's shortstring format (which I've never heard of, to be honest).
Shortstring is just a string thats restricted to 255 places, i used it to avoid having to distribute another dll, delphi explains it here:
Type* Maximum length* Memory required* Used for*
ShortString* 255 characters* 2 to 256 bytes* backward compatibility*
{ Important note about DLL memory management: ShareMem must be the
first unit in your library's USES clause AND your project's (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }
i changed it to string, added sharemem and added the dll to the same folder as everything, i get the same error
the exact error is:
Unexpected error occured when running the game.
then
The instruction at "0x00000000" referenced memory at "0x00000000". The memory could not be "read".
Click on OK to terminate the program
Click on CANCEL to debug the program
dislekcia
11-10-2008, 03:44 PM
It actually says "0x00000000000"? That means that there's something wrong with the way your DLL is being exported.
The Dash
11-10-2008, 03:51 PM
It actually says "0x00000000000"? That means that there's something wrong with the way your DLL is being exported.
any idea how to fix this? because in delphi i attach the game as a host program and it returns the same error but from within delphi this time
The Dash
11-10-2008, 04:02 PM
On another note, i have a problem with a multiplayer game,
im using messages to communicate between the games, and it seems the first game isn't sending messages, it is receiving and processing messages fine, just doesn't seem to send them.
its actually hard to explain, ill just upload the source code quickly
Here's the .gmk file (http://www.gamedev.za.net/filecloset/data/files/656/My_Game.gmk)
clicking or right clicking on the square changes the colour, arrow keys move around, d activates a primative little debug thing, s saves the debug info
Kensei
14-10-2008, 11:29 PM
Ok, silly question time:
I want to stop my following NPC from walking through my damn walls :p
The game mechanism is as follows, the NPC follows my main character until I tell him to stop - unfortunately I cannot think of an easy way for the NPC to be halt by things such as walls.
In fact, I think I have problems in general with collision detection :(
I fear that if I create a mask for the characters they might get stuck in the corners of the level (it is a top down design, like I did for * ) Would a circular mask with a slightly larger diameter than the sprite, ie with 34 pixels (for a 32x32 pixel character) work? This means that it will be difficult to implement narrow passage ways though.
Er, help?
Kensei
14-10-2008, 11:31 PM
On another note, i have a problem with a multiplayer game,
im using messages to communicate between the games, and it seems the first game isn't sending messages, it is receiving and processing messages fine, just doesn't seem to send them.
its actually hard to explain, ill just upload the source code quickly
Here's the .gmk file (http://www.gamedev.za.net/filecloset/data/files/656/My_Game.gmk)
clicking or right clicking on the square changes the colour, arrow keys move around, d activates a primative little debug thing, s saves the debug info
This sounds familiar... was it this forum or on the Game Maker forums that someone had this hassle. Try doing a search on just the Game.Dev forum, The_Dash, this sounds familiar but I cannot think of the solution
dislekcia
15-10-2008, 12:05 AM
Ok, silly question time:
I want to stop my following NPC from walking through my damn walls :p
The game mechanism is as follows, the NPC follows my main character until I tell him to stop - unfortunately I cannot think of an easy way for the NPC to be halt by things such as walls.
In fact, I think I have problems in general with collision detection :(
I fear that if I create a mask for the characters they might get stuck in the corners of the level (it is a top down design, like I did for * ) Would a circular mask with a slightly larger diameter than the sprite, ie with 34 pixels (for a 32x32 pixel character) work? This means that it will be difficult to implement narrow passage ways though.
Er, help?
Read up on on Motion Planning in the GM help. That should set you right.
Essentially you'd have the motion planning tools give your NPC a path to your player that avoids obstacles. GM can do it on a step-by-step basis, a look-ahead method or even a complete A* pathing system that has to register colliding objects in grid squares :)
Kensei
15-10-2008, 12:46 AM
Awesome, I will take a look :D
Looks like what I need it to do... I'll have Harry running after Susan in no time
The Dash
03-11-2008, 08:20 PM
I suspect that GM doesn't do everything event at once, IE, not all step events happen at exactly the same time.
Is there a way to get around this? IE I want several things to be destroyed at once, but its important that they all are destroyed at the exact same time.
dislekcia
03-11-2008, 10:18 PM
I suspect that GM doesn't do everything event at once, IE, not all step events happen at exactly the same time.
Is there a way to get around this? IE I want several things to be destroyed at once, but its important that they all are destroyed at the exact same time.
Well... Nothing on a computer ever happens at the same time, that's not how they work. Your CPU executes one instruction at a time, it's just very, very fast ;)
What GM does is execute all events in a specific order, all step events happen before all draw events, etc. The exact order is in the helpfile somewhere. Within a particular event, specific objects have their events happen according to depth ("deeper" depth's first) and within each depth order depends on time created, with the oldest objects being serviced first.
So, what do you want to have happen and why exactly does it have to all happen "instantenously" when nothing on a PC ever does? I'm certain that if you explain your goal we can figure out a way to do it.
The Dash
04-11-2008, 07:03 PM
Well... Nothing on a computer ever happens at the same time, that's not how they work. Your CPU executes one instruction at a time, it's just very, very fast ;)
So, what do you want to have happen and why exactly does it have to all happen "instantenously" when nothing on a PC ever does? I'm certain that if you explain your goal we can figure out a way to do it.
Uhm, difficult to explain, but i did manage to get it to work in the end
ill just let you see for yourself, and since i cant create a new thread yet, ill just have to post it here for now
Ha! can create threads now, so moved everything to here (http://forums.tidemedia.co.za/nag/showthread.php?p=164640#post164640)
ShadowMaster
04-11-2008, 07:16 PM
Well... Nothing on a computer ever happens at the same time, that's not how they work. Your CPU executes one instruction at a time, it's just very, very fast ;)
Unless you have multiple cores ;)
But yes dislekcia is right and be very thankful what you said isn't true because having multiple pieces of code run at once is a pain, just ask him.
Chippit
04-11-2008, 07:50 PM
Unless you have multiple cores ;)
But yes dislekcia is right and be very thankful what you said isn't true because having multiple pieces of code run at once is a pain, just ask him.
Yes, multithreading and the resultant concurrency issues are a gigantic ****ing headache.
dINGLE
18-11-2008, 10:35 PM
Hi all, need some help in GM if you don't mind.
I want the edges of sprites to blend with backgrounds and other sprites,
I tried ticking the 'smooth edges' box on the object, but it doesn't quite give the effect I'm looking for, it looks all washed out.
Is there any way I can define the transparency of some pixels in another application, like photoshop, and then import it in?
or some other way...?
Cyberninja
18-11-2008, 10:40 PM
Hi all, need some help in GM if you don't mind.
I want the edges of sprites to blend with backgrounds and other sprites,
I tried ticking the 'smooth edges' box on the object, but it doesn't quite give the effect I'm looking for, it looks all washed out.
Is there any way I can define the transparency of some pixels in another application, like photoshop, and then import it in?
or some other way...?
http://gmc.yoyogames.com/lofiversion/index.php/t252411.html
This might help.
dINGLE
18-11-2008, 11:07 PM
Thanks Cyberninja!
Thats exactly the kind of thing I was looking for
Now I just have to find a tutorial on making the alpha mask images
dislekcia
19-11-2008, 01:25 AM
Thanks Cyberninja!
Thats exactly the kind of thing I was looking for
Now I just have to find a tutorial on making the alpha mask images
Alpha mask images are just a black and white grayscale image that is white where you want something to be visible and black where it's invisible. If something is gray it'll be transparent, depending on how bright the gray is.
That said, GM7 can import images with alpha settings. I use PNG images with transparent backgrounds all the time in GM7. TGAs also work pretty well.
dINGLE
19-11-2008, 09:22 PM
Is there any function in GM to enable this?
Or is it in the drawing program, a mode I have to turn on?
SkinkLizzard
19-11-2008, 11:58 PM
GM help works wonders, its a function to load or replace sprites that you're looking for.
I think its sprite_replace_alpha or sprite_add_alpha
I don't know the details off hand but they should be adequately documented in the help file.
:)
dislekcia
20-11-2008, 01:10 AM
Is there any function in GM to enable this?
Or is it in the drawing program, a mode I have to turn on?
There are two ways of getting a transparent image in GM7:
You can either load a non-transparent image format (JPG, BMP, etc) and load a second image as it's alpha mask, then set the sprite's alpha channel using sprite_set_alpha_from_sprite(<sprite>, <alpha sprite>) (As explained in the linked tutorial)
Or you can load an image with that you've created in a graphics package with transparency data. I use either the PNG or TGA formats for their transparency settings. Sprites that are transparent when loaded in a graphics package will be transparent when loaded into GM7.
If you're using GM6, then only the first option is available to you... Have I understood your question correctly?
dINGLE
20-11-2008, 09:59 AM
I know how to do it now, thanks for the help guys.
its only available in the pro version though
(curses exchange rate!)
herman.tulleken
24-11-2008, 11:05 AM
Hi all
Seems you cannot pass arrays around as parameters or return values in functions... This got me writing some very confusing code that I will never be able to understand in a few days (using arrays as variables as part of the object instance). Is there something I am missing? Is there a good way to handle arrays in functions? (PS - I am trying to do it without the pro-edition - it is for code for my blog, so I don't the pro-edition to be required for the code to work).
you can return values.
return 0;
return var_something;
As for passing arrays, if you call the script you can automatically use the array from the object that called it. So if say you have named it some_array and it has 10 element all the time you could just in your script that you call from the object that has the array:
for (i = 1; i < 10; i += 1) {
//some code here, eg:
some_array[i] += 1;
}
herman.tulleken
24-11-2008, 11:23 AM
Sorry, I was not clear.
Here is what I want to do (using a simple example to illustrate the point):
EDIT: sorry - I initially swapped the code blocks around).
//Script 1 Called from action in bot
// ...
var my_ar, i;
for(i = 0; i < 100; i += 1)
{
my_arr[i] = random(1);
}
sorted_ar = sort(my_ar)
//---------------------------------------------------------
//Script 2, called 'sort', called from the script above
var old_ar, new_ar;
old_ar = argument[0];
//load old_ar values in new_ar
//sort new_ar
return new_ar;
//---------------------------------------------------------
The problem is, neither passing in an array as function argument, nor returning the array works. So instead I did this:
//Script 1 Called from action in bot
// ...
var i;
for(i = 0; i < 100; i += 1)
{
my_arr[i] = random(1); //my arr is now an instance var or whatever you call it.
}
sort(my_ar)
//access new_ar which contains the sorted values.
//---------------------------------------------------------
//Script 2, called 'sort', called from the script above
//load my_ar values in new_ar
//sort new_ar
//do not return anything - new_var is an instance var.
//---------------------------------------------------------
In this example, it is still OK, but my actual code is much more complicated, and I get terribly confused, and it is hard to debug, and it is hard to remember the flow of things and where what variable contains correct data. So I am looking for an improvement of the above scheme.
SkinkLizzard
24-11-2008, 11:42 AM
Might I suggest you use lists, I believe they are available in the light edition as well,
and they do all the sorting and stuff for you, and they can be passed to and from scripts using their id.
herman.tulleken
24-11-2008, 12:54 PM
Thanks SkinkLizzard,
Unfortunately, it is not available in the lite edition...
ht
dislekcia
24-11-2008, 01:36 PM
Herman, you've got two options for encapsulation of arrays as variables in GM:
1. Use the variable_local_array_get(name,ind) and related commands to pass the array you're looking to edit by name. This is probably non-optimal as you still need to dedicate storage to them and then make sure you've got the correct array per script operation, so I'd imagine that it would be roughly as complicated as the on-instance array stuff you're running now.
2. Create data-objects that act as pointers and store the computational arrays on them. Then you can simply pass around the reference to your objects and have scripts run on the arrays they contain... Think of it as a higher-cost struct implementation. Just make sure you clean up after yourself :)
herman.tulleken
24-11-2008, 02:14 PM
Thanks Danny,
I suppose your second suggestion is the best option. I was actually hoping that I was doing something wrong and that what I want is possible... O well...
Just out of curiosity, could you explain the other option a bit? (Do you send to local variable name, and how does the function know which variable you are talking about (if you have duplicate names in different objects) - does it work it out from the calling object?) This is kind of a bizarre feature!
Thanks again!
ht
dislekcia
24-11-2008, 03:12 PM
Thanks Danny,
I suppose your second suggestion is the best option. I was actually hoping that I was doing something wrong and that what I want is possible... O well...
Just out of curiosity, could you explain the other option a bit? (Do you send to local variable name, and how does the function know which variable you are talking about (if you have duplicate names in different objects) - does it work it out from the calling object?) This is kind of a bizarre feature!
Thanks again!
ht
I think it stems from the way that GM handles arrays... The lexical style of GML indicates that there's probably a table for arrays somewhere, which makes passing them around by identifier a little difficult: You're not talking about heap space and pointers, Overmars made the decision to take those out of the picture to prevent confusing race conditions.
Hence the global and local flavors of array access functions: I think GM tags an array with the object identifier it's slated for access by and then keeps the actual data all safe and snug in a completely different part of the heap.
Also, yes, you need to be aware of local vs global in terms of which object the script is executing on.
herman.tulleken
24-11-2008, 03:37 PM
Cool, thanks for the info!
ht
ShadowMaster
24-11-2008, 04:21 PM
Stuff like this just reminds me how much I hate Game Maker Script :/
dislekcia
24-11-2008, 05:22 PM
Stuff like this just reminds me how much I hate Game Maker Script :/
Why? You'd have to do a lot more mind-bending just to get a scripting system built on something like Lua to play nicely with any third-party engine out there right now... It's even more fun if you're writing your own hooks :)
Everyone has their own pet peeves in the programming world.
ShadowMaster
24-11-2008, 06:34 PM
Why? You'd have to do a lot more mind-bending just to get a scripting system built on something like Lua to play nicely with any third-party engine out there right now... It's even more fun if you're writing your own hooks :)
Everyone has their own pet peeves in the programming world.
Lol I'm actually planning on making a Lua based game maker and compared to something like Python embedding Lua is a dream. I'll post a prototype once I finally have one.
Well I think my pet peeves are justified for instance self != instance_id is one stupid fact of Game Maker Script, passing around built in arrays is another, there is no logical reason why that shouldn't work as expected considering Game Maker is for "beginners".
dislekcia
24-11-2008, 06:48 PM
Lol I'm actually planning on making a Lua based game maker and compared to something like Python embedding Lua is a dream. I'll post a prototype once I finally have one.
Well I think my pet peeves are justified for instance self != instance_id is one stupid fact of Game Maker Script, passing around built in arrays is another, there is no logical reason why that shouldn't work as expected considering Game Maker is for "beginners".
Yeah, good luck finishing the whole scripting thing... What's it for?
In GM self is a keyword for a specific identifier that means the current execution object. Try evaluating self by putting brackets around it. Self and other are different concepts to your OO expectation of the self keyword, I just replace all instances of it with id when it comes up and life is happy again. Expecting language text conventions to be to your liking isn't such a great thing to do... By the same token I could say that for loops in C are stupid, which they are, we're just used to them.
If you've got the full version of GM, passing around arrays isn't an issue: Just pass around a list or whatever index and life is happy. I get where you're coming from, but there really are far worse issues out there to be peeved about. Like why we get practically no games made with Python here ;)
ShadowMaster
24-11-2008, 07:00 PM
Yeah, good luck finishing the whole scripting thing... What's it for?
Well I'm planning on making an open source and free Game Maker type thing I'll post an example later when I have the basics done (basic minimal engine with image loading and blitting, minimal editor and simple compiler - wow it's a lot now that I think about it).
Instead of just complaining about Game Maker I'm gonna take a more proactive stance about it.
Though I'm just wondering what this clause in the Game Maker license means:
1.2. You must not:
j. create data or executable programs which mimic data or functionality in the Software;
If it means I may not make software that's similar to Game Maker, what is the legality of such a clause?
dislekcia
24-11-2008, 08:47 PM
Though I'm just wondering what this clause in the Game Maker license means:
If it means I may not make software that's similar to Game Maker, what is the legality of such a clause?
That means you can't use GM to make GM and re-sell it.
ShadowMaster
24-11-2008, 09:06 PM
That means you can't use GM to make GM and re-sell it.
OK cool, then I'm set, well sort of, have a metric ton of code to write :/
The Dash
25-11-2008, 10:36 PM
Help please: This is a script i've created because of the way GM handles transitions with rooms of different sizes
//smooths the difference between room sizes when using transitions
var trans_speed; //sets how fast the screen will change
trans_speed=argument0
while (view_wview[view_current]<room_width) or (view_hview[view_current]<room_height)
{
if view_wview[view_current]<room_width then //sets the width
{
screen_wait_vsync()
view_wview[view_current]+=trans_speed
view_wport[view_current]+=trans_speed
window_set_size(view_wview[view_current],view_hview[view_current])
window_set_region_size(view_wview[view_current],view_hview[view_current],true)
screen_refresh()
}
if view_hview[view_current]<room_height then //sets the height
{
screen_wait_vsync()
view_hview[view_current]+=trans_speed
view_hport[view_current]+=trans_speed
window_set_size(view_wview[view_current],view_hview[view_current])
window_set_region_size(view_wview[view_current],view_hview[view_current],true)
screen_refresh()
}
Waiting for the v-sync and screen refresh make the transition smooth
The resulting view doesn't look right though, i've checked the port size etc and its all right,
rather than making the view bigger to show the entire room, it appears to be stretching whats currently visible to the new size.
http://i472.photobucket.com/albums/rr90/ALumberjack/Before.jpg
http://i472.photobucket.com/albums/rr90/ALumberjack/After.jpg
dislekcia
25-11-2008, 10:51 PM
Are you sure you've enabled the use of views? You need to do that per room.
The Dash
26-11-2008, 09:39 AM
Are you sure you've enabled the use of views? You need to do that per room.
yup, every room has views enables and a view set
dINGLE
04-12-2008, 10:55 AM
Hi all
I'm still having problems with adding sprites with alpha channels
I'm doing this:
sprite_replace_alpha(sprite0,'Untitled.png',1,true ,true,0,0)
in a separate object at the start of the game.
I have uploaded the .gmk and .png files here (http://www.gamedev.za.net/filecloset/download.php?id=664) [100KB]
It would be great if someone could get them and let me know what I'm doing wrong
Thanks!
SkinkLizzard
04-12-2008, 12:18 PM
as far as I can see the problem probably lies with your .png image
I loaded it into photoshop and it doesnt have any alpha information
it might as well be a .bmp or .jpg
If you use layers to create the sprite remember to remove the background before saving to .png
I changed the .png and it works
http://www.gamedev.za.net/filecloset/data/files/665/Sprite_ProblemA.rar
dislekcia
04-12-2008, 12:31 PM
Hi all
I'm still having problems with adding sprites with alpha channels
I'm doing this:
sprite_replace_alpha(sprite0,'Untitled.png',1,true ,true,0,0)
in a separate object at the start of the game.
I have uploaded the .gmk and .png files here (http://www.gamedev.za.net/filecloset/download.php?id=664) [100KB]
It would be great if someone could get them and let me know what I'm doing wrong
Thanks!
Your PNG file has no alpha. Which means it isn't transparent... I edited the PNG to remove the white background and your loading code worked fine.
You may also want to make sure that sprites don't have the "transparent" checkbox clicked in GM, that makes them use chroma-key transparency, not alpha channel transparency.
What are you making your PNGs in?
dINGLE
04-12-2008, 01:57 PM
Im making them in Paint.NET...
I would have thought that it would support alpha channels... is there some setting for it or must i use something else?
dINGLE
04-12-2008, 03:28 PM
I left out the white background and now it works!
That was a bit silly of me wasnt it
Thanks guys! Ive been trying to get this for a while
dislekcia
05-12-2008, 03:21 PM
Im making them in Paint.NET...
I would have thought that it would support alpha channels... is there some setting for it or must i use something else?
I left out the white background and now it works!
That was a bit silly of me wasnt it
Thanks guys! Ive been trying to get this for a while
No worries :)
The approach to getting alpha to work in GM6 was to manually supply an alpha channel for each sprite. In GM7 you can simply load an image that contains alpha information, making it more WYSIWIG - GM6 would pull out the colour info and use that.
The Dash
06-12-2008, 08:23 PM
Neeeeeevermind, got it :D
Pietersielie
07-12-2008, 02:51 PM
Hey
I'm making a game in GM7 where you have to catch the guys dropped by the helicopter but I can make the sound of the helicopter fade out and in I use:
sound_fade(snHeli,0,100)
I have tried to set the value to 0.5 but it still instantly stops the sound.
I have tried to make it fade in but it instantly plays the sound loud.
dislekcia
07-12-2008, 06:07 PM
Hey
I'm making a game in GM7 where you have to catch the guys dropped by the helicopter but I can make the sound of the helicopter fade out and in I use:
sound_fade(snHeli,0,100)
I have tried to set the value to 0.5 but it still instantly stops the sound.
I have tried to make it fade in but it instantly plays the sound loud.
sound_fade(index,value,time) Changes the volume for the indicated sound to the new value(0 = low, 1 = high) during the indicated time (in milliseconds). This can be used to fade out or fade in music.
You're telling it to fade to 0 over 100 milliseconds. That's 0.1 of a second, not a very long time at all. Try setting it to 5000 (5 seconds * 1000) and seeing if it still cuts off the sound. If it does, the format of your sound is the issue.
Bonezmann
10-12-2008, 09:25 PM
Hi there, I'm struggling with a tiny little thing here.
I need an egg to check a file if the creature has already hatched, and if it hatched the creature should be there and not the egg. This is due to room switching.
Here is the code I'm using:
{
ini_open('tamaloc');
ini_read_string('tama','open','');
if ini_read_string('tama','open','')=ini_read_string( 'tama','open','yes');
alarm(1.0);
}
and my error:
__________________________________________
FATAL ERROR in
action number 1
of Create Event
for object egg:
COMPILATION ERROR in code action
Error in code at line 7:
alarm(1.0);
at position 2: Unknown function or script: alarm
The alarm even destroys the egg and creates the creature, if you can help me by doing that without the alarm I'd be VERY greatful.
Help plz, I suck at this :(
edit:
Tried the following:
{
ini_open(tamaloc);
ini_read_string('tama','open','');
if ini_read_string('tama','open','')=ini_read_string( 'tama','open','yes')
object_add(tama1);
object_delete(egg);
}
and got this:
___________________________________________
FATAL ERROR in
action number 1
of Create Event
for object egg:
COMPILATION ERROR in code action
Error in code at line 7:
object_add(tama1);
at position 18: Wrong number of arguments to function or script.
Jeronkey
10-12-2008, 09:41 PM
Your problem with the alarm is just from it being typed slightly wrong.
Instead of
alarm(1.0) try something like
alarm[x] = y
x being the number of the alarm and y being the time you want to set it for.
As to your second problem.. instance_create() and instance_delete() might be the better option to use.
Bonezmann
10-12-2008, 09:47 PM
Your problem with the alarm is just from it being typed slightly wrong.
Instead of try something like
x being the number of the alarm and y being the time you want to set it for.
As to your second problem.. instance_create() and instance_delete() might be the better option to use.
Tried it, did some further research and it seems to work.
Thanx alot :)
dislekcia
11-12-2008, 12:19 AM
Your problem with the alarm is just from it being typed slightly wrong.
Instead of try something like
x being the number of the alarm and y being the time you want to set it for.
As to your second problem.. instance_create() and instance_delete() might be the better option to use.
You rock :)
Entering the comp?
Jeronkey
11-12-2008, 07:20 PM
Aye! I rather want to. I just need to sit down and think of a decent idea.. :P - My imagination never works when I want it to...
digi5
12-12-2008, 11:00 AM
Hey Guys!
I'm trying to make my first "big" GameMaker game, and it's a brand new invention called Pac Man.
I've got a script where if PacMan is close along the same row or column of the maze, the ghosts change direction and follow him.
with (self)
{
if distance_to_object(PacMan) < 100
{
switch point_direction(self.x, self.y, PacMan.x, PacMan.y)
{
case (0): motion_set(0,3);break;
case (90): motion_set(90,3);break;
case (180): motion_set(180,3);break;
case (270): motion_set(270,3);break;
}
}
}
Problem is.. I don't want them to chase him if there's a wall up ahead. How do I do it.
Jeronkey
12-12-2008, 12:02 PM
Not entirely sure this is what your wanting, but.. I say give collision_line a try, you can use it to check if there is a wall or such between the ghosts and Pac Man.
digi5
12-12-2008, 02:50 PM
Looks like it should do the job. I'll give it a try.
Elyaradine
13-12-2008, 02:41 AM
What's the name of the variable for "vertical speed"? I'm working around it using the point-click ui, but it's failing me with something really simple.
Thanks.
Agrajag
13-12-2008, 05:15 AM
What's the name of the variable for "vertical speed"? I'm working around it using the point-click ui, but it's failing me with something really simple.
Thanks.
I believe it is called vspeed.
Elyaradine
13-12-2008, 08:42 AM
Thanks, I'll try that. :)
SkinkLizzard
13-12-2008, 12:27 PM
just a question to bonezmann
why are you using a file to store the egg hatching info ?
if its just to do with room switching, I believe that global variables are persistent.
dislekcia
13-12-2008, 12:39 PM
What's the name of the variable for "vertical speed"? I'm working around it using the point-click ui, but it's failing me with something really simple.
Thanks.
GM has several different methods of changing the same information. You can access an object's movement info via direction and speed, or via hspeed and vspeed. Changing one set of variables affects the other.
Bonezmann
13-12-2008, 12:57 PM
just a question to bonezmann
why are you using a file to store the egg hatching info ?
if its just to do with room switching, I believe that global variables are persistent.
It has not only to do with room switching actually, it's also to continue where you left off if you exited the game and you run it again. :)
SkinkLizzard
13-12-2008, 01:00 PM
ah yes sorry stupid me I forgot about that.
saving progress, probably something I should remember to add
to my own games lol :)
Elyaradine
13-12-2008, 10:40 PM
GM has several different methods of changing the same information. You can access an object's movement info via direction and speed, or via hspeed and vspeed. Changing one set of variables affects the other.
Thanks.
edit: Erk. I've got two solid objects (the player's car, and a truck). The truck's moving down the screen, and has a collision event that makes it bounce off of the car (it's a light truck, okay? :P), and then get destroyed.
My problem is that if you're approaching the truck from the side, the car refuses to move into the truck. So things work fine if the truck moves downward, hits the car from the top, and bounces back up. But if the car is on the side, and I wish for it to drive sideways into the truck (and bounce it sideways), the car refuses to move.
What might be a problem is that I've created an invisible dummy car as the "real" marker for where the player is. The visible ("fake") car simply moves toward where the dummy car is all of the time, to allow for a smoother change-lane animation. So when I'm moving the marker sideways into where the truck is, the visible car doesn't seem to execute its move action, and I don't know why.
It's only an issue when the collision event exists; the car correctly moves into where the truck is when the collision event doesn't exist.
edit: Seems that it's because the bounce action just reverses the truck's direction of movement. Since it only has vertical velocity, it doesn't bounce. Which doesn't quite make sense to me, but it seems that working around it by forcing the truck to move in a certain direction (as opposed to bouncing) seems to fix things.
Insomniac
16-12-2008, 10:13 PM
I've been jumping back into GM lately but am a bit rusty.
I have a series of sounds I want to play that will be updating all the time, so in my object I have variables for sounds that need to be managed with the value of each being the name of the sound to be played. Then a script updates these variables.
My problem is then when I use sound_play(varName) it only ever plays one sound no matter what the value is in varName, even if it's value "completeRubbish"
I'm not to sure about GM's dynamic binding for variables and if that's causing a hiccup somewhere. When I change varName to something else random I get an error so it is picking it up as a variable and not just trying to play the sound of the variables name.
Does anyone know if there's a logical reason on why it's not playing the sound given by the contents of the variable and how to fix it?
Thanks.
Jeronkey
16-12-2008, 10:31 PM
My problem is then when I use sound_play(varName) it only ever plays one sound no matter what the value is in varName, even if it's value "completeRubbish"
Hmm... not entirely sure whats going wrong here.
Firstly. What are the values in the variables? I noticed that GM ignores the value if its a string and just plays the first sound it finds instead. Example:
// The wrong way
varName = "sound0"
// The right way
varName = sound0
Insomniac
16-12-2008, 10:46 PM
Firstly. What are the values in the variables? I noticed that GM ignores the value if its a string and just plays the first sound it finds instead. Example:
WIN! Thanks so much that's fixed it up now :)
And that's why I'm not a fan of dynamic typing ;)
Aval4nche
28-12-2008, 12:50 PM
I have these enemies that move along a path. When they are destroyed I want them to respawn about a minute later at their original start position. How would I do this without creating an individual spawn object for every enemy?
Jeronkey
28-12-2008, 03:20 PM
I have these enemies that move along a path. When they are destroyed I want them to respawn about a minute later at their original start position. How would I do this without creating an individual spawn object for every enemy?
My solutions to things are usually quite messy, so dislekcia or someone might have a better way to do this, but... =P
You could try storing the start position in a variable.
Create Event :
start_x = x
start_y = y
When the enemy dies, have it create a placeholder object at the start position
Destroy Event:
instance_create(start_x,start_y,obj_placeholder)
All you need to do in the placeholder object, is have it create the enemy after the time has passed, then destroy itself.
Hope this helps?
Aval4nche
28-12-2008, 06:18 PM
Thanks Jeronkey, I was tearing my hair out.
The Dash
28-12-2008, 11:04 PM
You could try storing the start position in a variable.
Create Event :
There are already two variables GM uses for the start position
xstart
ystart
Aval4nche
29-12-2008, 09:04 AM
There are already two variables GM uses for the start position
Quote:
xstart
ystart
Yip, I saw that.
Jeronkey
29-12-2008, 11:03 AM
There are already two variables GM uses for the start position
Ooh, awesome. *makes a note to remember that* Thanks!
The Dash
04-01-2009, 09:36 PM
Quick question.
Can you pass arrays as arguments in scripts? (because mines not working for some reason, although i recall being able to do it at some point)
dislekcia
04-01-2009, 11:34 PM
Quick question.
Can you pass arrays as arguments in scripts? (because mines not working for some reason, although i recall being able to do it at some point)
No, you can't. There are workarounds where you either pass an object reference and the object contains the array you want to pass, or you could pass the name of the array and access it using GM's variable access commands to pull off something similar :)
The Dash
09-01-2009, 05:46 PM
How would i make a flashlight for a top down game?
Powered by vBulletin® Version 4.2.4 Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.