View Full Version : Game Maker Help Thread (Post your Qs here!)
CiNiMoDZA
03-08-2007, 12:42 PM
Ok, I know this isnt the place to do this, but I dont have ten posts yet so I cant start a thread!!! I have an object that I want to move to a random position, once at this random position, it must then move to another random position! So basically, it must carry on moving! But not like a mad thing!!! Now while its doing this, it needs to be avoiding all solid objects!?! Can anyone help!!!
Hey Miktar, how come I cant post a reply?!? I can only edit my comment?
Miktar
03-08-2007, 12:58 PM
I made this its own thread, so people who can't make new threads can come ask their questions here, and Dislekcia can move them out to their own threads if needed.
dislekcia
03-08-2007, 01:48 PM
mp_potential_step(x,y,stepsize,checkall) Like the previous function, this function lets the instance take a step towards a particular position. But in this case it tries to avoid obstacles. When the instance would run into a solid instance (or any instance when checkall is true) it will change the direction of motion to try to avoid the instance and move around it. The approach is not guaranteed to work but in most easy cases it will effectively move the instance towards the goal. The function returns whether or not the goal was reached.
That's the function you want to use, look it up in the help to see what else is related to it that you might be able to use...
As for randomly assigning points to move to, all you need to do is have two variables targetX and targetY that you set up in your create event. Then, you can test your current x and y positions against them to see if the object has reached the point - if it has you just pick a new random spot to move to (warning, if that spot is inside an object or otherwise blocked off, you'll never be able to move onto that exact spot, so you might want to set up a failsafe alarm or something). Or you could just use an alarm with a random time to pick a new spot to move to, irrespective if the original point was reached or not.
-D
CiNiMoDZA
04-08-2007, 10:56 PM
Ok, I dont know how to do the alarm thing! Basically I ve got it moving to a random position! But now I dont know how to make my random position variable(or whatever it is), which are posx and posy, become a new random number, and then move to that new random place!!! If that makes sense?
Gazza_N
04-08-2007, 11:01 PM
Alarms are events that you can set to go off after a certain number of game cycles (the number of game cycles per second is set as your room speed). Each object that you create can have up to 12 of them, which is more than enough if your code is good. I suggest looking them up in the GM help file, since they're incredibly useful.
CiNiMoDZA
04-08-2007, 11:30 PM
No, lol, miss understanding!!! I know how to use alarms!!! What I cant do is get my object to, once its reached its random x and y points, generate a new one and move to it!!! It must continue doing this until it is caught!!!
dislekcia
05-08-2007, 01:40 AM
Well... How are you generating the first random point?
Theoretically, all you need to do is figure out a way to test if the object has reached its target position and if it has, do whatever you did to get a random point again. If (....) blah.
And yes, I could just give you code to do that, but then you're not learning how to do it properly ;)
-D
CiNiMoDZA
05-08-2007, 07:11 AM
ok to get random points:
{Create Event}
posx = random(800)
posy = random(600)
to check if its at the point:
{Step event}
if (instance_position(posx, posy, ball) ?????
what do I do now to get the new random position!
I tried making random position a script, and then run it whenever it reached the random position, but once its reached its point, it stops!!! Yo dont have to give me the code...just tell me what I have to do? :D
Thanks dis!
CiNiMoDZA:
what you would want to do is get a new random xpos and ypos to move to.
//create event
xpos = random(800);
ypos = random(600);
//step event
if (instance_position(xpos,ypos,all)) {
xpos = random(800);
ypos = random(600);
} else {
x = xpos;
y = ypos;
}
that would make sure you arent landing on another object, but not properly.
what all does the object have to do?
dislekcia
05-08-2007, 12:45 PM
edg3: There's a few problems with your script, read the whole thread to see what Cinimod wants to do.
Cinimod:
{Create Event}
posx = random(800)
posy = random(600)
to check if its at the point:
{Step event}
if (instance_position(posx, posy, ball))
{
posx = random(800)
posy = random(600)
} - my additions in bold (really just copy-paste)
I'm curious, what was making you think you couldn't do that?
-D
CiNiMoDZA
05-08-2007, 02:07 PM
Thanks guys, its working now!!! But dont get too comfortable!!! Will probably need some help soon!!!
CiNiMoDZA
05-08-2007, 09:07 PM
Told you I was coming back!!! Ok, so u finally collide with the ball!!! Yay, now when I push spacebar I want the ball to shoot out in the direction Im traveling!!!
Ive got it to move in the direction Im traveling, however, I want it to create the ball infront of my player!!! What can I do?
dislekcia
06-08-2007, 12:24 AM
If you know the direction, all you need to do is move the ball a certain distance along that direction away from the player:
spawnPosX = x + lengthdir_x(distance, direction);
spawnPosY = y + lengthdir_y(distance, direction);
Sorted. The lengthdir commands are actually just wrappers around sin and cos, trig is awesome :)
-D
CiNiMoDZA
06-08-2007, 10:35 AM
thanks, got it working!!! :D
Cyberninja
07-08-2007, 09:11 AM
Hey guys. I need some help with my game. Sorry if my questions might seem silly, this is my first game...(blushes) This is for Marble Mania.
1- How do I create a vertical health bar? (Using the drawing function)
2- How do I make my game go into bullet-time (slow-mo) then have it return to the normal speed after a few seconds?
3- How do I make the game zoom in on the cannon ball before it destroys it's last target? (Like in Peggle)
4- Should I store my sound fx files as wav or mp3s? Is there a better format?
5- Will adding movies/cutscenes to the game, greatly increase loading time?
6- I've read that external loading will solve these problems. How do I implement it in my game?
Edit: Missed out the word "help" sigh....my bad.
RedNax
07-08-2007, 12:02 PM
@Cyberninja
I also just started so I can't help much, only with point number 1 =P
I'll give you an example from my game;
1) I created an object which I called 'controller_health'
2) In the Create event I set a new variable: 'global.health', value = 128 (This would be the length of the bar and global so that you can use it in other objects too)
3) In the Draw event I set a color and created a rectangle (Note, I use a view of 800x600 in my game)
http://i126.photobucket.com/albums/p110/ReddNaxx/untitled-1.jpg
The bar I created depletes upwards. If you want it to deplete downwards it should look like this (Not sure, I didn't test it).
http://i126.photobucket.com/albums/p110/ReddNaxx/untitled2.jpg
4) Now you just create a statement to check whether the health has depleted. In my case: if global.health smaller-than 1.
5) For damage taken, I just decrease the variable global.health by say 2, etc, and the bar changes with it. ( If your bar depletes downwards you'll have too add, not subtract)
I feel like I said too much here. I don't want to take away your chance to learn it yourself. I just hope you understand what I did here, i.e, don't just type it down ^^. If there is an easier way, then I hope someone posts it. Like I said, I'm also a noob to Game Maker.
Cyberninja
07-08-2007, 12:19 PM
Thanks man. I'll try it out. Muchos gracious :-)
dislekcia
07-08-2007, 12:36 PM
draw_healthbar(x1,y1,x2,y2,amount,backcol,mincol,m axcol,direction,showback,showborder)
With this function you can draw a healthbar (or any other bar that indicates some value, like e.g. the damage). The arguments x1, y1, x2 and y2 indicate the total area for the bar. amount indicates the percentage of the bar that must be filled (must lie between 0 and 100). backcol is the color of the background for the bar. mincol and maxcol indicate the color when the amount is 0 and 100 respectively. For an amount in between the color is interpolated. So you can easily make a bar that goes e.g. from green to red. The direction is the direction in which the bar is drawn. 0 indicates that the bar is anchored at the left, 1 at the right, 2 at the top and 3 at the bottom. Finally showback indicates whether a background box must be shown and showborder indicated whether the box and bar should have a black border line.
Of course, it pretty much does what RedNax did manually. Although I'd recommend using a pointer to the object the healthbar is monitoring instead of a global variable: targetObj.health instead of global.health, then all you do is set targetObj to the id of the object the healthbar should track.
As for your other questions Cyberninja:
2: You need to make all your movement relative to a factor, so if something moves or does anything over time it has to be multiplied by that global factor. That way all you need to do is change the factor (from 1 to 0.2 for instance) and you get a slow-mo effect. You can even smoothly scale the factor as you go for smooth transitions... Resist the temptation to simply change your room_speed, that will only change the number of frames per second that the room runs at - it would kinda give you a slow-mo effect, but it would be jerky like you'd simply slowed down a video instead of true slow-motion.
Nandrew would be the guy to help you on this, he's implemented slowdown in LineWars very nicely!
3: Use views. Read up on how they work in the GM help... The pertinent variables are view_target, view_hview and view_wview.
4: Wavs tend to have less issues... Some soundcards have an audible *click* when playing mp3s in GM, there are also looping problems with short sounds.
5: You'd have to experiment... Initial loading time shouldn't be too affected if you check the "load only on use" box. Otherwise you can use script commands to load external files, but that's pretty much the same as using "load only on use". Movies and audio will greatly increase your filesize though, beware not to go too huge ;)
6: By using sound_add(), look it up in the help index and you'll get a whole bunch of other useful commands :)
-D
Cyberninja
07-08-2007, 12:58 PM
Thanks for the help Dis. I appreciate it man. And yes, I will pay closer attention the GM help file from now on. ;-) Thanks guys.
dislekcia
07-08-2007, 01:05 PM
No worries, and I really don't mind directing people where to look in the helpfile, something that big and detailed takes a while to get to grips with.
In general it's more about approach and implementation of what you want to get done than knowing some nifty command or algorithm.
-D
RedNax
07-08-2007, 01:09 PM
Of course, it pretty much does what RedNax did manually. Although I'd recommend using a pointer to the object the healthbar is monitoring instead of a global variable: targetObj.health instead of global.health, then all you do is set targetObj to the id of the object the healthbar should track.
Thanx for that Dislekcia. And so the learning experience continues! =D
Cyberninja
07-08-2007, 01:19 PM
No worries, and I really don't mind directing people where to look in the helpfile, something that big and detailed takes a while to get to grips with.
In general it's more about approach and implementation of what you want to get done than knowing some nifty command or algorithm.
-D
Yep! So true. I have to say though, I'm really impressed with Game Maker's capabilities. I honestly didn't think that one could create a professional looking game in this program. But it has really suprised me over this past month. I really love this program. :-)
dislekcia
07-08-2007, 03:04 PM
Yep! So true. I have to say though, I'm really impressed with Game Maker's capabilities. I honestly didn't think that one could create a professional looking game in this program. But it has really suprised me over this past month. I really love this program. :-)
Don't worry, everyone comes around eventually ;) Now all I need to do is get GM on TV.
-D
Gazza_N
07-08-2007, 08:48 PM
This is quite a nasty one, but here goes!
Is there any way to create dynamic collision masks in Game Maker? I'm working with a complex object for which I want precise collision checking, but this involves having a different collision sprite for each step in its rotation, as well as masks for moving components (large turrets). Rather than manually creating 360+ bitmaps, is there any way that I can create and assign the mask dynamically?
Thanks in advance for any advice!
dislekcia
07-08-2007, 08:56 PM
Is this registered or unregistered?
Unregistered I'd simply use a bunch of invisible collision only objects tied to the complex object, each repositioning itself according to current rotation and animation data. Any collision with one of those "shadow collision" objects would be a collision normally.
Actually, re-reading your description, why can't you simply use precise collision checking on the object and each turret? Precise will always check against the current frame, transparency and all. Then all you do is have the collision event set a flag variable that you check in your step (or end-step) event on the main object. Easy.
If I misread you and there's some other reason why you can't simply spread the collision across multiple tester objects and you're using registered GM, then you could draw the object to a surface and create a sprite from that surface and assign it as a mask/sprite to the core object each frame, although it would probably be a tad inefficient.
-D
Gazza_N
07-08-2007, 09:07 PM
Registered.
Thanks Dis. I'll try drawing to an offscreen surface (first time I work with them). Fortunately I'm only looking at tracking two main components at the moment, so I doubt there'll be any major slowdowns. As for precisely why I need to do it this way... Well, hopefully you'll be seeing soon enough ;).
ok i have a weird problem.
I want to create the basic ground for my game.
So i made it in Photoshop.
http://www.pixilive.com/viewbig.php?image=http://www.pixilive.com/uploads/20070807/Untitled.jpg
Then i made a Sprite and a object but when i create a room and want to place my ground i does this.
http://www.pixilive.com/viewbig.php?image=http://www.pixilive.com/uploads/20070807/Untdfitled.jpg
some weird green stuff above.
Please help
Gazza_N
07-08-2007, 09:27 PM
EDIT: Never mind. Better answer given by ninja master in next post ;). "Advice" removed to protect innocents from harm.
dislekcia
07-08-2007, 09:29 PM
Vexo, that's happening because you're leaving an area transparent in the image when you save it. JPG doesn't support transparency, so it's using any old colour there, that's where the green is coming from.
In GM you can make a sprite have a transparent colour by checking the "Transparent" box in the sprite's properties. That will treat the colour in the bottom left pixel as transparent and not draw it at all... Be warned though, this is only that EXACT colour! Anything else will appear, so I suggest using bmp as your format for now, it doesn't compress colours at all. Otherwise use tga, which saves transparency information that GM can load.
-D
ok tanx allot.
My master piece continues 1 step at a time :)
RedNax
08-08-2007, 05:33 AM
Uhh, its me again =P
How do I get GM to check whether there is no object relative to my object's current position? I might just be messing up with my if statements here so I'm just wondering. Do I use Check Object?
EDIT: Nvm that, I got it =)
dislekcia
08-08-2007, 05:04 PM
EDIT: Nvm that, I got it =)
Grats! Now you can answer that question when someone else asks it :)
-D
Gazza_N
08-08-2007, 07:44 PM
Dynamic surface-drawn mask failed, sadly, because I'm working in 3D. 3D mode doesn't support surfaces without me turning it on and off all the time. Looks like I'll just have to stick to my functional but inelegant collision cylinder.
dislekcia
08-08-2007, 07:54 PM
What's wrong with turning it on and off? Technically all that's doing is setting up a different projection/view matrix combo, which isn't exactly an expensive operation... Provided you do it during a step and not a draw cycle, you should be happypants.
-D
Gazza_N
08-08-2007, 08:26 PM
It... er... seemed inefficient.
Please don't hurt me?
dislekcia
08-08-2007, 09:58 PM
It... er... seemed inefficient.
Please don't hurt me?
Alright, I won't... For now...
-D
P.S. Most modern games have several render-mode/context switches per frame. Essentially all you're doing is setting up the graphics card with slightly different values for the next stream of vertices it gets squirted. See it as a tool waiting to be used, not a heavy mode-dependant dinosaur ;)
CiNiMoDZA
14-08-2007, 09:57 PM
Hmm, stupid problem! Trying to make a timer, this is what I've got:
Create:
time = 0
Alarm 0:
time +=1
Step:
Set alarm 0 to 2
Draw:
draw_text(10, 10, time)
Im not getting any errors, but all my text is saying is 0? Dont know what to do!!!
Please help!!!
Thanks guys!!!
cairnswm
15-08-2007, 11:48 AM
Create
Time = 0
Step
Time +=1
Draw
draw_text(10,10,time)
(That should give you a count of 30 per second)
cairnswm
15-08-2007, 12:04 PM
Create
StartTime = current_time;
Draw
draw_text(10,10,(current_time-StartTime)/1000);
Shows you for how many seconds the game has been running.
dislekcia
15-08-2007, 01:26 PM
cairnswm is made of win.
Also, the reason your alarm was never firing is because you were constantly setting it to 2 frames every frame... It would decrease to 1 frame and then get set back to 2 all the time.
-D
CiNiMoDZA
15-08-2007, 01:29 PM
Lol, got it to work now, thanks cairnswm! Ja, I see why it wasnt working now!!!
Cyberninja
15-08-2007, 03:04 PM
Heya guys. I have another question. :-) After I complete Marble Mania I want to create a traditional scrolling space shooter. Something along the lines of Deimos Rising, where I'll be using 2D sprites of 3D models and terrain. Since I'll be using alot of sprites in this game, I would like to know:
Which with be the best method to create the stages? Should I create one large room and have my jet gradually scroll over it? Or should I create a normal sized room and have my sprite objects and background objects appear at specific times (by making them instances)?
Which would work best as it relates to loading time and file size?
cairnswm
15-08-2007, 03:45 PM
Which would work best as it relates to loading time and file size?
I dont know :)
However the Scrolling Shooter Tutorial (1942) for Game Maker discusses both these approaches and gives advice on which to use.
Cyberninja
15-08-2007, 05:12 PM
I dont know :)
However the Scrolling Shooter Tutorial (1942) for Game Maker discusses both these approaches and gives advice on which to use.
Aha! I just downloaded the tutorial from the yoyo site, All the documentation is there. Thank's Cairnswm. http://img110.imageshack.us/img110/3766/bowingvl9.gif (http://imageshack.us)
CiNiMoDZA
15-08-2007, 09:30 PM
Ok, I've got a total noob question here! Ive got a variable, ring_score(found in the ring object), now this variable is going to affect the player object(user_obj) later on! The problem is when I try use the ring_score variable in my player object, it says that the object does not exist! Do I have to put .global in front of the variable for it to affect other objects?
My next problem is that I want to draw this variable, so this is what I have:
Ring Object:
Create:
ring_score = 0 //(I find that if I dont do this it says no variable exists!!!)
ringx = random(800)
ringy = random(600)
Collision:
ring_score +=1
instance_create(ringx, ringy, ring)
Destroy self
Timer Code:
Create:
time = 15
Step
time -=0.033333333333333333333333333333333
Draw:
draw_text(10, 10, time)
draw_text(10, 40, global.ringnum) //I put it in here because when I put it in the ring object it doesnt draw the sprite of the ring!!!
Sorry its so long!!! The problem I have is, when I draw global.ringnum, it stays as 0 the whole time!! Please help!!!
cairnswm
15-08-2007, 10:45 PM
Every object in Game Maker has an Id. The easiest thing about Ids is that they are the same as the names. Now global is just a special object that always exists called global.
So what I think you want in the timer code is
draw_text(10, 40, RingObjectName.ring_score);
But you'll have to test it.
CiNiMoDZA
15-08-2007, 11:04 PM
Its still not working, the number still stays at 0! Lol, never mind!!! Stupid mistake, got it now!!! I made ringnum = 0 in the create event of the ring object, forgetting that every time I collided with a ring, it created a new one, thus always setting the variable ringnum to 0!!! :P
dislekcia
16-08-2007, 10:25 AM
Glad you spotted that, I saw it last night but couldn't reply for some reason :)
-D
CiNiMoDZA
16-08-2007, 12:16 PM
Ok, me again :P I want to get the time that I collided with the object, so what I have is:
In the ball object:
Collision:(With the player object)
catch_time = timer.time
room_goto(room6)
Then in the object to draw the score:
Draw:
draw_text(10, 10, practice_ball.catch_time)
But it says there's no such variable, am I doing something wrong that Im missing here?
Nvm, got it! I just made the ball persistent! Is this the right way to do it though!?!
Tr00jg
16-08-2007, 04:14 PM
It most certainly is. It depends though. When a room ends, it deletes all the objects (unless they or the room is persistent).
RedNax
17-08-2007, 10:14 PM
Time to show my noob-ness again... but at least I'm improving a bit ^^
I'm kinda stuck with a little (and probably simple) problem. I want pinball-like physics but I'm not completely sure about the collisions.
First of all, how would I change the weight of objects? For example, a steel ball in comparison to a wooden ball. For this I'm sure I just have to play around with the Vertical Speed and Gravity?
Secondly, when the ball hits the floor, I want it to bounce, slow down, and eventually stop. I figured out how to make it bounce and stop after doing the Platformer Tutorial but, I'm stuck at getting it to stop when its moving horizontally and vertically at the same time.
Truthfully, I didn't really know what I was doing, so I need help. For the whole bounce-to-stop thing, my code looked like this:
obj_Ball:
Step:
Bounce Against Objects;
IF position (relative to) is collision free (0, 1, Only Solid)
Gravity(270, 1);
ELSE
Gravity(270, 0);
End Step:
IF vspeed = 0;
Move Contact in Direction(270, 1);
I don't know exactly how correct that is but it does seem to work, vertically. I tried replacing the IF in my End Step with "IF vspeed = 0 && hspeed = 0", but it didn't work. Not even sure if its &&(and) or ||(or). I usually get the two mixed up =/ (Though I did try both)
EDIT: Got it figured out now.
CiNiMoDZA
21-08-2007, 12:44 AM
Ok, so Ive got this person! Now behind the person I want to make little sparkle dust stuff!!! How would I do this using GM 6.1!!!
Nvm, got it :P
CiNiMoDZA
22-08-2007, 10:12 PM
Ok guys, I got the problem!!!
Here goes! I need my Mr AI man to get the ball, now when he's under pressure I want him to pass it! So this is what I got! In the AI's step event:
oppPosX = center_chaser_ut.x
oppPosY = center_chaser_ut.y
shootPosX = x + lengthdir_x(50, direction);
shootPosY = y + lengthdir_y(50, direction);
if (x - oppPosX < 80 and y - oppPosY < 20 and Caught = 1) instance_create(shootPosX, shootPosY, Quaffle)
Quaffle.pass = 1
Quaffle.passPosx = right_chaser_cpu.passPosX
Quaffle.passPosY = right_chaser_cpu.passPosY
Caught = 0
And in the Quaffle step event:
if (pass = 1) move_towards_point(passPosX, passPosY, 7)
The problem I have is, as soon as I run the game, the Quaffle is moving towards 0,0! I understand that its moving to this because in the create event I have:
shot = 0
pass = 0
passPosX = 0
passPosY = 0
But still, it shouldn't because pass = 0 and its only supposed to move there when pass = 1?
Please feel free to tell me easier ways to do things that I've coded, Im still pretty new to GML so ja! Thanks guys!
Link:http://gamedev.openhazel.co.za/filecloset/data/files/162/AI_Main.gm6 (16k) GM 6.1 Reg
Please just look through and give me pointers as Im new to the whole AI thing!
cairnswm
23-08-2007, 09:47 AM
Passs is always 1
Try useing coding blocks:
if (x - oppPosX < 80 and y - oppPosY < 20 and Caught = 1) then
{
instance_create(shootPosX, shootPosY, Quaffle)
Quaffle.pass = 1
...
}
CiNiMoDZA
23-08-2007, 10:27 AM
Thanks carnswm, its working now!
T_Kill3r
27-08-2007, 04:38 PM
I want to make the sprite rotate in direction with the mouse? How do I do this?
(excuse me, but i'm a complete noob to game development and i'm only 14..)
And where can I buy THE GAME MAKER APPRENTISE (book) the cheapest? Is it worth buying?
dislekcia
27-08-2007, 05:26 PM
I want to make the sprite rotate in direction with the mouse? How do I do this?
(excuse me, but i'm a complete noob to game development and i'm only 14..)
And where can I buy THE GAME MAKER APPRENTISE (book) the cheapest? Is it worth buying?
The rotation thing was covered in NAG a while ago. It's now up on the Game.Dev website (http://www.gamedotdev.co.za/index.php?option=com_content&task=view&id=15&Itemid=29) :)
To make an object always point towards the mouse cursor, simply get the relative direction using something like:
facingDirection = point_direction(x, y, mouse_x, mouse_y);
And then use the facingDirection variable you've just created in the rotation logic.
I'm not sure about the book, I think you can get it from Take2.co.za AFAIK. I'd recommend it if you don't have any programming experience at all and have the commitment to work through the whole book. Good luck and welcome :)
-D
Fengol
27-08-2007, 05:29 PM
@Dislekcia, if I write an article for GM can you put it on the game.dev website?
T_Kill3r
27-08-2007, 05:35 PM
Ok. Thanks fo the help dislekcia
cairnswm
27-08-2007, 06:30 PM
@Dislekcia, if I write an article for GM can you put it on the game.dev website?
Put it in DevMag!!
CiNiMoDZA
27-08-2007, 10:28 PM
Im trying to test out my multiplayer game! Ive got GM to connect via TCP/IP but I dont know how to get my IP address so I can tell my friend what IP to enter? How do I check what my IP address is so that my friend cam connect over the internet?
Chippit
27-08-2007, 10:36 PM
If you're connecting over the internet, you can retrieve your internet address from this website (http://www.whatismyip.com/)
If you're testing it on LAN, you can see your IP in Window's network connection properties.
CiNiMoDZA
27-08-2007, 11:10 PM
Thanks, I needed to get it for the net!
CiNiMoDZA
28-08-2007, 02:17 PM
Hey guys, Im trying to have my game connect over the net! Now I was about to try connect to his PC but his net has just gone down!!! Please tell me if Im missing something in my code! All its supposed to do is check if I am connected to a session!
In the connection app:
Left released:
mplay_init_tcpip(his IP)
sesname = get_string('What is your session name?', '')
name = get_string('What is your name?', '')
mplay_session_create(sesname, 0, name)
room_goto(Game)
In the joining app:
Left released:
mplay_init_tcpip(his IP)
if (mplay_session_find() = true)
{
room_goto(Game)
}
else
{
show_message('Nothing')
}
Should this work or is it missing something! I have a button that tells me if Im connected or not!
dislekcia
28-08-2007, 02:23 PM
Seems like that would work. I'd suggest doing a call to mplay_connect_status() to figure out if the connection resolved or not before you test the session stuff.
Remember that if you have firewalls and the like things are probably not going to work. GM uses the DirectPlay default network ports, so it often gets blocked.
-D
CiNiMoDZA
28-08-2007, 02:47 PM
Like I said above, the button I was talking about does use mplay_connect_status(), and I have disabled my firewall, and my friend is disabling his!
dislekcia
28-08-2007, 04:03 PM
Ah, I'd suggest using
if (mplay_session_find() > 0) instead of if (mplay_session_find() = true), mplay_session_find() returns the number of sessions, not a boolean value.
-D
CiNiMoDZA
28-08-2007, 04:07 PM
Ok thanks!!!
CiNiMoDZA
28-08-2007, 10:24 PM
Hey, when Im creating a session do I have to call 'mplay_init_tcpip(hosts IP)' ?
Squid
29-08-2007, 11:51 AM
Alrighty, I'm busy drawing a primitive like so:
draw_set_alpha(1);
draw_set_color(c_white);
draw_primitive_begin(pr_linestrip);
draw_primitive_begin(pr_linestrip);
for (i=0;i<num_points;i+=1)
{
dx = vx[i]-origin_x;
dy = vy[i]-origin_y;
r = sqrt(dx*dx + dy*dy);
theta = arctan2(dy, dx);
vert_x = x+r*cos(theta+degtorad(image_angle));
vert_y = y-r*sin(theta+degtorad(image_angle));
draw_vertex(vert_x,vert_y);
}
dx = vx[0]-origin_x;
dy = vy[0]-origin_y;
r = sqrt(dx*dx + dy*dy);
theta = arctan2(dy, dx);
vert_x = x+r*cos(theta+degtorad(image_angle));
vert_y = y-r*sin(theta+degtorad(image_angle));
draw_vertex(vert_x,vert_y);
draw_primitive_end();
draw_set_color(c_white);
What I want to know is how can I fill this primitive with a colour?
dislekcia
29-08-2007, 12:31 PM
@Cinimod: Monochrome supplies the host machine's IP address. GM's helpfile says that you don't need to do this on a LAN, but I just did it anyway. Monochrome has reportedly worked over the intertubes, so it might make a difference there :)
@Squid: You're going to need to change the type of primitive that you're drawing, lines don't have any area that can be filled, so you're going to need to draw triangles. That means using pr_trianglelist (list of triangles, three vertices at a time), pr_trianglestrip (three vertices initially, then 1 vertex for each triangle after that, the two "latest" vertices of the previous triangle are used) or pr_trianglefan (three vertices initially, then 1 for each triangle thereafter, the first vertex and the last vertex you supplied create the resulting triangle).
Obviously this has mathematical changes in your code, but I'm sure you can figure that out. I'd suggest starting with pr_trianglestrip and making sure you're always passing three vertices. You might also want to use a different vertex format, such as draw_vertex_color().
-D
CiNiMoDZA
29-08-2007, 12:44 PM
Hey dis, Im doing it over the net! So TCP/IP, or can i use an IPX conection?
CiNiMoDZA
29-08-2007, 02:34 PM
Hey, I want to try mess around with GM 3D functions! Is it possible to use blender or poser to make a model, and then import it into GM?
herman.tulleken
29-08-2007, 02:38 PM
I have a question or two:
In a game where the art goes through lots of iterations, reloading sprites becomes a chore, and a production bottleneck.
So is there some way of linking (instead of embedding) resources in GM? Of course objects can be made to reload their own sprites - but this needs manual setup in every object and will be error prone, especially since you cannot browse for a file to make sure you reload the correct one.
You can also setup objects automatically, but how do you refer to them in your scripts then? Normally you would just use the object name, but now all you have is an ID (which changes every step or something?)
Finally, what is the best way check whether two objects are touching? In heaven there would be two events "onTouchStarted" and "onTouchStopped"; what do we have here on earth? Using collisions and step events or performing proximity calculations seem a little clumsy...[Just to be clear - I have certain objects that should behave differently depending on whether other objects are over them or not, and I have lots of them...and I want even more! All objects are mostly stationary - some just appear and disappear depending on user input.]
Be gentle if I miss something obvious...I am still growing out of my noob phase!
thx
ht
Gazza_N
29-08-2007, 02:53 PM
@Cinimod: There's an answer to your question in the Deathbringer thread. :)
dislekcia
29-08-2007, 05:57 PM
Hey dis, Im doing it over the net! So TCP/IP, or can i use an IPX conection?
TCP/IP. Very few people still have IPX drivers for their network cards. The internet is TCP/IP-based, so IPX is LAN-only.
-D
dislekcia
30-08-2007, 01:23 AM
I have a question or two:
In a game where the art goes through lots of iterations, reloading sprites becomes a chore, and a production bottleneck.
So is there some way of linking (instead of embedding) resources in GM? Of course objects can be made to reload their own sprites - but this needs manual setup in every object and will be error prone, especially since you cannot browse for a file to make sure you reload the correct one.
Not that I know of per se. I do know that you can load in sprites dynamically. So you might be able to use placeholder sprites for most of the development and then have an initialiser script on an object at depth 10000 which goes through all the sprites and pulls in the latest versions of their files (you'd probably have to have sprite names and filenames be exactly the same, or use some other identification system). You could also parent all your objects to a SpriteReloader object, although that wouldn't be optimal if you're creating tons of objects on the fly.
I know this can be a big headache. It's the main reason that I don't tend to colour sprites outside GM: I'll leave them white and colour them at the object level. Also I'm a big fan of minimalist graphics up until final release ;)
You can also setup objects automatically, but how do you refer to them in your scripts then? Normally you would just use the object name, but now all you have is an ID (which changes every step or something?)
Not quite sure what you mean here. There are two types of object handles: ids and indexes. An id is a by-value pointer to a specific object, obtainable using object.id. Each instance in GM is assigned a unique id (starting from 10001 and going up from there) when you use that id in dot notation - variable.property or (number).property - GM looks up the object with that id and does things to it. An index is an object type name, object.object_index. When you create a new object in GM's editor, that's an object index. If you refer to an index in a scope that expects a type, it will act as a type - examples are in parenting settings, with statements or collision functions. If you refer to an index in a scope that expects an id, it will resolve to the id of the oldest object of that particular type. This is not guaranteed and can sometimes shuffle around if the list of objects is re-sorted due to memory management or excessive culling. This is probably the main cause of your "ids randomly change each frame" misconception.
Be careful how you use index to id resolution! Dot notation will change a specific value on the entire collection of instances of that type if used directly on an index... That means that
ObjectType.value = 0
and
oldestInstance = ObjectType;
oldestInstance.value = 0;
are different. The first will set value to 0 on ALL current instances of ObjectType. The second will only set value to 0 on the oldest instance of ObjectType.
Whenever you create an object in GM that object's unique id is returned. Whenever you create an object type that type's unique index is returned. Both are numbers, used in GM's internal object registries. An index is never above 10000, an id is never below 10000.
Finally, what is the best way check whether two objects are touching? In heaven there would be two events "onTouchStarted" and "onTouchStopped"; what do we have here on earth? Using collisions and step events or performing proximity calculations seem a little clumsy...[Just to be clear - I have certain objects that should behave differently depending on whether other objects are over them or not, and I have lots of them...and I want even more! All objects are mostly stationary - some just appear and disappear depending on user input.
The event handler that generated onTouchStarted and onTouchStopped would be doing collision detection against flags every frame anyway ;). Logically it makes more sense, but go with simple collision setting a flag, step testing the flag, end-step clearing the flag. If you can get away with it, instance_position() is much cheaper than position_meeting() or other object-object collision testing methods.
-D
dislekcia
30-08-2007, 01:26 AM
@Herman: Only read the "mostly stationary, dis/appear on user input" line now. In that case I'd suggest doing manual collision tests on creation and queueing up tests on collided objects with flags set on them during deletion. That would lower your calculation burden per frame quite substantially... Make sense?
-D
CiNiMoDZA
30-08-2007, 08:02 AM
Hey, Im having a bit of a problem here! I want to store just one string in a text file, the text file is called check, and I want the string its storing to be check, so this is what I have:
Create:
if (file_exists('Check.txt')){
file_text_open_read('Check.txt')
check = file_text_read_string('Check.txt')
}
But it brings up an error saying the file is not open for reading!?!
Gazza_N
30-08-2007, 09:46 AM
I see your problem. You're trying to use the file name as a handle in your file_text_read_string(blah) function. Unfortunately, GM won't allow that. You need to create a handle variable for the file a-like-a so:
MyFile=file_text_open_read('Check.txt')
check = file_text_read_string(MyFile)
Also don't forget to close the file when you're done reading from it (can't remember the relevant command now. It's in the help). Just remember, all the file read and write functions use the handle you specify in your file open/create function.
CiNiMoDZA
30-08-2007, 09:54 AM
Pk, cool, thanks Gazza!!!
dislekcia
30-08-2007, 01:41 PM
I had an idea this morning regarding this:
I have a question or two:
In a game where the art goes through lots of iterations, reloading sprites becomes a chore, and a production bottleneck.
So is there some way of linking (instead of embedding) resources in GM? Of course objects can be made to reload their own sprites - but this needs manual setup in every object and will be error prone, especially since you cannot browse for a file to make sure you reload the correct one.
Sprite strips! That's the answer. Put your graphics into sprite strips for similarly sized sprites and then just set the relevant frame for specific objects. That way if the graphics change you only need to reload the single image of the sprite strip... I know this will give Chris a couple of headaches, but it's a compromise to minimise the amount of work going on.
-D
herman.tulleken
30-08-2007, 06:42 PM
@Dislekcia
Thanks for all your answers.
This is probably the main cause of your "ids randomly change each frame" misconception.
Indeed (I was not aware of that object indices were something else than IDs). So if I manage IDs of objects once they are created in an array or with some other scheme I should always be able to get hold of an object or instance, right?
The event handler that generated onTouchStarted and onTouchStopped would be doing collision detection against flags every frame anyway .
Yes. Even so I always like the machine to do the grunt work and not me ;-)
In that case I'd suggest doing manual collision tests on creation and queueing up tests on collided objects with flags set on them during deletion. That would lower your calculation burden per frame quite substantially... Make sense?
Yes, this sounds very cool (I could even wrap it up in a nice extension that will reduce the work to a few clicks).
Put your graphics into sprite strips for similarly sized sprites and then just set the relevant frame for specific objects. That way if the graphics change you only need to reload the single image of the sprite strip... I know this will give Chris a couple of headaches, but it's a compromise to minimise the amount of work going on.
Hmmmm... We would need to think a little bit about this. Creating the individual images is already complex because of the viewpoint, we also use sprite heights to calculate offsets (to generate the city from buildings, for instance), and we use frames in some cases to randomly choose "equivalent" images for more variety or for button states... Even so, we would be able to use it in at least some places - maybe we also need to restructure a little bit...
I know this can be a big headache. It's the main reason that I don't tend to colour sprites outside GM: I'll leave them white and colour them at the object level. Also I'm a big fan of minimalist graphics up until final release.
That is a good way to work, and will surely reduce our headaches and development time. We don't, so that we can work in safely parallel (without one guy having to do lots of stuff because of unforseen glitches), and art "mistakes" and "problems" can be spotted a lot earlier. In this game it is important because the solution might be either programatic or artistic (because of the procedures that generate the world). Many of the small things that cropped up in Epidemic required both art and programming changes. Maybe experience will allow us to take the approach you suggest - we might even adopt it regardless.
Thanks again for the answers; you have been a great help.
ht
Fengol
31-08-2007, 07:57 AM
Fonts in GM
Is there a tutorial somewhere on using fonts in GM? How do I ensure that the fonts I want to use in GM will be available for other players who might not have the font loaded? Can I load a sprite strip with a more elaborate font into the font section?
herman.tulleken
31-08-2007, 10:57 AM
If you use an installer to install the game, you could install the font with the game. InnoSetup (http://www.jrsoftware.org/isinfo.php) is an attractive and powerful free solution - better than many commercial installers.
For more elaborate fonts, IMHO, it might be better to make a new font instead any bitmap scheme (I am not sure whether there is a bitmap scheme for GM). Although it is a lot more work, it means you don't have to worry about bad kerning and line spacing, and you will have a font ready for manuals, web sites and other stuff.
I don't know of any good, free font editing tools, though... Fontographer (http://www.fontlab.com/font-editor/fontographer/), I hear, is a good commercial one, but quite expensive.
Hope it helps.
ht
dislekcia
31-08-2007, 01:26 PM
Fonts in GM
Is there a tutorial somewhere on using fonts in GM? How do I ensure that the fonts I want to use in GM will be available for other players who might not have the font loaded? Can I load a sprite strip with a more elaborate font into the font section?
GM automatically bitmaps fonts that you give it, that's why you have to create a font and specify which sections of it you'll be using. It does that to ensure font portability across machines.
I'm not sure if you can load your own custom bitmapped fonts without first creating an actual font from the images, but I'll look into it.
-D
Fengol
31-08-2007, 05:28 PM
So what you're saying is, is that I could use a custom font on my machine and people use the compiled EXE will see what I see, but if people play with the GM file they might not get it. I can live with that
dislekcia
31-08-2007, 05:42 PM
So what you're saying is, is that I could use a custom font on my machine and people use the compiled EXE will see what I see, but if people play with the GM file they might not get it. I can live with that
Nope. People will get it if they play with the GM file too. Remember, GM stuffs all the resources you add to the project in the gmk.
-D
Fengol
31-08-2007, 07:17 PM
duh! of course! *alternate personality laughs at Fengol*
CiNiMoDZA
03-09-2007, 09:26 PM
Ok, so Im about to shoot something!!! AHHHHHHH!!! This be my problem! I want to randomly generate a list of stats for a character, so in my characters create event I have something like this:
Create:
char_type = random(4)
if (char_type = 0)
{
Speed = 20
Strength = 50
Blah blah blah!!!
}
if (char_type = 1)
{
Speed = 50
Strength = 20
Blah blah blah!!!
}
and so on! When I try get it to draw Speed for example, its says variable does not exist :( Please help!!!
ShadowMaster
03-09-2007, 09:46 PM
Is Speed declared outside the if statements? If not there is your problem.
Because the ifs create their own scopes and all variables not declared outside it get deleted after end bracket of the if.
Else the problem might be that you should use this.Speed if that is a member of the object.(I am not so sure about this, because I don't know gamemaker all that well)
Here is my own question, Is GM based on JavaScript?
CiNiMoDZA
03-09-2007, 09:59 PM
No, my variables are not declared outside the if statements but when I do declare them (Speed = 0 what ever blah blah blah) when I draw it, it always get drawn as 0!?!
Nandrew
03-09-2007, 11:01 PM
If you're talking about the application itself, GM was built with Delphi.
If you're talking about the code, GML is syntactically open.
dislekcia
03-09-2007, 11:25 PM
Is Speed declared outside the if statements? If not there is your problem.
Because the ifs create their own scopes and all variables not declared outside it get deleted after end bracket of the if.
Else the problem might be that you should use this.Speed if that is a member of the object.(I am not so sure about this, because I don't know gamemaker all that well)
Here is my own question, Is GM based on JavaScript?
Nope. GM's scope is object-dependant. That means that creating a variable inside braces creates that variable on the current object that code is executing on. The only time a variable's scope is limited in the way you describe is when you declare it using the var keyword, that is mainly used in scripts to prevent variables inadvertently overwriting each other in things like recursion.
As Nandrew has said: GM is written in Delphi and GML is a lexically scoped scripting system built strictly for GM. GML can parse C-style, Pascal-style and sometimes even BASIC-style code, in the same structure.
-D
dislekcia
03-09-2007, 11:31 PM
Ok, so Im about to shoot something!!! AHHHHHHH!!! This be my problem! I want to randomly generate a list of stats for a character, so in my characters create event I have something like this:
Create:
char_type = random(4)
if (char_type = 0)
{
Speed = 20
Strength = 50
Blah blah blah!!!
}
if (char_type = 1)
{
Speed = 50
Strength = 20
Blah blah blah!!!
}
and so on! When I try get it to draw Speed for example, its says variable does not exist :( Please help!!!
Your problem is that random() returns a float. So it can be anything between 0 and 4, including things like 0.782324 and 2.80909, etc. The chances char_type actually being exactly 0, 1 or the like are vanishingly tiny... Although it would happen at least once given enough attempts.
The solution is to round the value returned by random() to an integer using either round() or floor(). The former rounds a real number the same way you were taught at school, the latter simply drops anything after the floating point: round(0.7) is 1; floor(0.7) is 0. Floor() is the better choice, because it reduces possibilities equally. Round() has a bias against the numbers at the end of the range. Floor() will never give you the highest number possible...
Or you could simply use the choose() command... value = choose(0, 1, 2, 3, 4); Works with any values.
-D
CiNiMoDZA
03-09-2007, 11:54 PM
Thanks Dis, now hurry up and put up the new comp :D
CiNiMoDZA
03-09-2007, 11:56 PM
Hm, ok, so I used the choose(0, 1,), but when I tell it to draw one of my variables, its still blank, it doesn't bring up an error though so it must be there!!!
dislekcia
04-09-2007, 12:41 AM
Hm, ok, so I used the choose(0, 1,), but when I tell it to draw one of my variables, its still blank, it doesn't bring up an error though so it must be there!!!
Is the value a number or a string? The draw text commands only accept strings, so you need to convert numbers to strings...
Hence the handy string(value) command.
-D
CiNiMoDZA
04-09-2007, 08:38 AM
Here's a link,
http://gamedev.openhazel.co.za/filecloset/data/files/174/Random_Stas.zip
maybe you can see whats wrong!?!
CiNiMoDZA
04-09-2007, 10:48 AM
Ok, two problems! First, is there anyway to set the verticle speed of an object to the verticle speed of a room? Then also, how can I destroy an object in the GML from another object? When I say instance_destroy() I cant put anything in the brackets else it brings up an error! Is there any code that I can put in that destroys an object at a certain position! So for example, my current note is done like this:
Step:
current = instance_nearest(x, y, F1)
Now I want to destroy the object that is current!!!
cairnswm
04-09-2007, 11:06 AM
Wont this do?
position_destroy(x,y) Destroys all instances whose sprite contains position (x,y).
My trick might be to move the 'current' to an off screen location like 10000,10000 and then use Position Destroy.
CiNiMoDZA
04-09-2007, 11:11 AM
Now how would I move it to an off screen position?
CiNiMoDZA
04-09-2007, 11:32 AM
Nvm, got it!!!
CiNiMoDZA
04-09-2007, 11:45 AM
Ok, new problem :P I think I should get my own thread!!! Ok, so I want to create my button at 5 seconds! So I have a timer going up, and the a floor() to round it off! Now my creator of the button is told that when it is 5 seconds it must create the button, but it stays 5 seconds for the whole second because I use the floor command! This causes it to create a whole bunch of buttons! To make the problem worse, I cant limit the creator to only create if there are no instances, this is because I may need to have multiple instances later on!!!
Fengol
04-09-2007, 01:21 PM
Why don't you just have a counter in the in Step event? if you're running at the standard 30 fps you need toc ount to 30*5 frames. Granted it's not perfect but GM does a pretty good job of maintaining the framerate.
dislekcia
04-09-2007, 01:43 PM
Ok, two problems! First, is there anyway to set the verticle speed of an object to the verticle speed of a room? Then also, how can I destroy an object in the GML from another object? When I say instance_destroy() I cant put anything in the brackets else it brings up an error! Is there any code that I can put in that destroys an object at a certain position! So for example, my current note is done like this:
Step:
current = instance_nearest(x, y, F1)
Now I want to destroy the object that is current!!!
And...
Wont this do?
position_destroy(x,y) Destroys all instances whose sprite contains position (x,y).
My trick might be to move the 'current' to an off screen location like 10000,10000 and then use Position Destroy.
Ack no! Bleh! HAX! That's terrible... position_destroy() is very unreliable, especially if you have a lot of objects in play at the same time. You could easily kill something that you don't want to. If you have an object handle to enable you to move it already, rather do this:
with (objectHandle) instance_destroy();
100% reliable, swaps scope to the target object for the instance_destroy() call, kills the target object, exits and carries on running.
-D
CiNiMoDZA
04-09-2007, 01:49 PM
Ja, but remember, Im going to have many of one instance!!! Sorry Fengol, I dont understand what you trying to do! Can you explain a little more?
heres the link so you can see what Im trying to do!!!
http://gamedev.openhazel.co.za/filecloset/data/files/175/Comp_16_Entry.zip
Nvm guys, I realize that Im being stupid! I dont know why I wanted to make it increase in seconds, it makes no difference!!
Fengol
04-09-2007, 02:19 PM
D is saying you must use the object ID not the object type.
Remember that instance_create() returns the id of the object created so you can target it directly.
objh = instance_create(x, y, object1);
with (objh) { instance_destroy(); }
You'll find objh will be a number which'll be unique for each object (even of the same type) in the room.
CiNiMoDZA
05-09-2007, 10:28 AM
Please someone tell me why this isn't working :'(
In my F1 button thing, I have this:
Create:
get_time = 0
F1_rec = file_text_open_append('F1.txt')
F1 Pressed:
get_time = timer.time
time = string(get_time) I wasn't doing this!!!!
file_text_write_string(F1_rec, get_time)
file_text_writeln(F1_rec)
Ok then I have it that when I press space bar it closes the F1.txt file!!! Now if I make get_time something like 'Dom', it works, but it doesnt when its timer.time ??? Why isn't this working?!?
---EDIT---
Nvm, I got it!!!!!! :D :D :D :D
CiNiMoDZA
06-09-2007, 07:48 AM
Ok, so I got a new question now!!! I want to add effects to one of my sounds playing in the game!!! How would I achieve this!!! So far I tried this:
Shift Key:
sound_effect_set(Slide_guitar, se_compressor) Wasn't doing this!!! Should have read the help :P
sound_effect_compressor(Slide_guitar, 20, 60, 70, -10, 10, 0)
Nvm, got it!!!
CiNiMoDZA
07-09-2007, 12:26 PM
Is there any way in GM to drop the volume of a certain sound in-game!!! I know that there's sound_volume() but that only allows you to set it as 1 or 0, so it's either on or off!!! Anyone know?
dislekcia
07-09-2007, 01:20 PM
sound_volume(index,value) Changes the volume for the indicated sound (0 = low, 1 = high).
Have you tried using 0.5 as your value? I think you'll be surprised.
-D
CiNiMoDZA
07-09-2007, 01:38 PM
I have tried putting 0.5, but it didnt help! The poblem is, Im trying to use it to lower the level of the sound once my effect has kicked in, so Ive got this:
Glob Left Pressed:
sound_effect_set(Slide_guitar, se_compressor)
sound_effect_compressor(Slide_guitar, 20, 0, 5, 40, -10, 0)
Now the problem is, to get a distorted sound I push up the gain, but I want the gain to go up, but drop the volume!!! Is that possible!!
Cyberninja
07-09-2007, 02:41 PM
Hey guys. I have a question. How do I make my enemy sprite always face my character?
For example, I jump over the enemy sprite (with my character) and land behind it. How do I make the enemy turn around and face my character. Like in the Metal Slug games. Anyone know how I could do this?
dislekcia
07-09-2007, 02:52 PM
I have tried putting 0.5, but it didnt help! The poblem is, Im trying to use it to lower the level of the sound once my effect has kicked in, so Ive got this:
Glob Left Pressed:
sound_effect_set(Slide_guitar, se_compressor)
sound_effect_compressor(Slide_guitar, 20, 0, 5, 40, -10, 0)
Now the problem is, to get a distorted sound I push up the gain, but I want the gain to go up, but drop the volume!!! Is that possible!!
sound_volume() works just fine with values between 0 and 1. Have you tried doing the volume change AFTER you apply the effect? The helpfile says that effects have default values that they apply, maybe one of them is volume.
-D
Nandrew
07-09-2007, 09:49 PM
Hey guys. I have a question. How do I make my enemy sprite always face my character?
For example, I jump over the enemy sprite (with my character) and land behind it. How do I make the enemy turn around and face my character. Like in the Metal Slug games. Anyone know how I could do this?
The logic behind this would be to check the x value of your character against the x value of the enemy.
charx > : enemy faces right
charx < : enemy faces left
Cyberninja
08-09-2007, 10:36 AM
Thanks Nandrew. I'll try that. =)
Nandrew
09-09-2007, 02:51 PM
With regards to your question about x values (please post queries here from now on, that way more people can see them ;) ), let's say you have your enemy object, you've gone into the code and you want to use the Step event to update its facing to look at the character (which we'll call the Hero object).
Basically, you'll want an IF control and an ELSE control. With IF, you'll be saying
IF x < Hero.x
facing = "right"
Then beneath that, the ELSE statement
ELSE
facing = "left"
I'm not too sure how to explain it more clearly than that.
Cyberninja
09-09-2007, 10:55 PM
Aaah. Thanks Nandrew. Will do! ;)
CiNiMoDZA
09-09-2007, 11:01 PM
Ok, so in my game I have this problem!!! i want lots and lots of songs! So what I want to do is make a controller object that has which song is currently playing!!! How Im doing this is in the songs initializing object, I have this:
Create:
Controller.song = MySongsName
Now in the event that I want this song to stop playing, I have this
Step:
if (keyboard_check_pressed(vk_enter))
{
sound_volume(Controller.song, 0)
}
However, it says that there is no such sound!?! Hmm..
Cyberninja
10-09-2007, 02:24 AM
Mwahahahah!! I got it to work! ^_^ Thanks Nandrew.
CiNiMoDZA
11-09-2007, 10:10 AM
Ok, so in my game I have this problem!!! i want lots and lots of songs! So what I want to do is make a controller object that has which song is currently playing!!! How Im doing this is in the songs initializing object, I have this:
Create:
Controller.song = MySongsName
Now in the event that I want this song to stop playing, I have this
Step:
if (keyboard_check_pressed(vk_enter))
{
sound_volume(Controller.song, 0)
}
However, it says that there is no such sound!?! Hmm.
Tr00jg
11-09-2007, 12:36 PM
Well. Is this exactly like your syntax looks like? You are missing terminations, ie ";". But I dont think that is your problem.
The only thing that I can think of that is sound_volume only works on midi's. That, and perhaps you have to absolutely link to the song, ie
sound_volume(MySongsName, 0);
Hope that helped.
dislekcia
11-09-2007, 02:34 PM
Ok, so in my game I have this problem!!! i want lots and lots of songs! So what I want to do is make a controller object that has which song is currently playing!!! How Im doing this is in the songs initializing object, I have this:
Create:
Controller.song = MySongsName
Now in the event that I want this song to stop playing, I have this
Step:
if (keyboard_check_pressed(vk_enter))
{
sound_volume(Controller.song, 0)
}
However, it says that there is no such sound!?! Hmm.
First step would be to find out what Controller.song actually is when you call it. I'd add in something like:
room_caption = string(MySongsName) + " " + string(Controller.song);
before the sound_volume call. That would make the header for the room (the window title) display a specific value, I tend to use this for debugging on the fly because I don't enjoy having message windows pop up all the time... You could always just use the debug mode and supply the right context tho ;) Chances are you're messing with the value of Controller.song at some point or in another object. Otherwise it's a typo somewhere that's causing an incorrect value to be passed around. Which object is this running on? Controller? How many Controller objects do you have in the game at any one point?
-D
James Donaldson
15-09-2007, 11:25 PM
Okay -my problem is more in the learning process. (I want to make a fighting game but I can't seem to complete a simple scroll-shooter)
Tutorials are set up to either cover the absolute basics -or tend to skip steps when covering more advantages stages.
Simply put -can you recommend an idiot-proof tutorial that starts at the beginning (baby steps), slowly builds up and ends with some sort of advanced working game (This IS Game Maker I'm talking about)
CiNiMoDZA
16-09-2007, 10:06 AM
When you say you were attempting to make a scrolling shooter, I assume you got your tutorials from the yoyo games site! If you didnt, they are probably the best, and you can find them here:
http://www.yoyogames.com/make/tutorials
dislekcia
16-09-2007, 06:21 PM
Okay -my problem is more in the learning process. (I want to make a fighting game but I can't seem to complete a simple scroll-shooter)
Tutorials are set up to either cover the absolute basics -or tend to skip steps when covering more advantages stages.
Simply put -can you recommend an idiot-proof tutorial that starts at the beginning (baby steps), slowly builds up and ends with some sort of advanced working game (This IS Game Maker I'm talking about)
I'd suggest reading through cairnswm's beginners guides in the recent Dev.Mags (http://www.devmag.org.za).
-D
Cyberninja
17-09-2007, 08:40 AM
Hey guys. I've decided to change the game to keyboard only. (instead of mouse and keyboard). It's gonna play alot like Contra/Metal Slug. I've run into a snag though.
When I press the up arrow + right arrow + C-key , I need the object to:
- Change the sprite into a 45 degree facing sprite (I've created a 45 degree sprite for this)
- Create a bullet that travels in a 45 degree angle.
How do I create this using scripts?
dislekcia
17-09-2007, 06:23 PM
Hey guys. I've decided to change the game to keyboard only. (instead of mouse and keyboard). It's gonna play alot like Contra/Metal Slug. I've run into a snag though.
When I press the up arrow + right arrow + C-key , I need the object to:
- Change the sprite into a 45 degree facing sprite (I've created a 45 degree sprite for this)
- Create a bullet that travels in a 45 degree angle.
How do I create this using scripts?
Right. State machines. Know anything about them?
Essentially you need to define various states for your player character to be in. That's reasonably easy. Then you change states based on the inputs you receive: Every step you check to see which directional arrow was last pressed and if up and C were pressed too.
Then you set your sprite to display the correct frame for the state your character is in. Finally you create a bullet in the player is firing (which I assume is what C is for). Making a bullet travel at 45 degrees isn't hard, simply create it - using something like bulletInstance = instance_create(x, y, Bullet); - and then set it's direction - bulletInstance.direction = 135 or 45, depending. That should actually be pretty similar to your normal firing code, actually.
I'd have the firing direction be a variable that was changed when the state changed. So facing right = 0, up+right = 45, up = 90, up+left = 135, left = 180. Then, when it's ok to fire (ie button pressed + cooldown timer above a specific threshold) simply create a bullet and set it's direction to the firing direction. Easy ;)
-D
Hey i had exams and stoped my game for a while but i can continue now :)
I am still pretty new to gamemaker.
Ok so i made a .gif and the speed between the pics is 0.5 s but when i create a sprite and make a object with the sprite and insert it in the room it moves at a very high speed i went edit sprite and changed the speed to what i want it but when i hit play it is the same super speed.
please help
dislekcia
17-09-2007, 07:45 PM
Hey i had exams and stoped my game for a while but i can continue now :)
I am still pretty new to gamemaker.
Ok so i made a .gif and the speed between the pics is 0.5 s but when i create a sprite and make a object with the sprite and insert it in the room it moves at a very high speed i went edit sprite and changed the speed to what i want it but when i hit play it is the same super speed.
please help
The speed of the images in the gif file has no impact on the sprite animation speed in Game Maker. When you change the speed of the animation in the sprite editor, you're not actually setting how fast the sprite animates on an individual object, you're seeing what it looks like at a specific number of frames per second (the default is 30 fps), we'll get back to that later.
Each object can have its own sprite animation speed, I'm sure you can see why that would be useful ;). The variable you're after is image_speed, from the help:
image_speed The speed with which we cycle through the subimages. A value of 1 indicates that each step we get the next image. Smaller values will switch subimages slower, drawing each subimage multiple times. Larger values will skip subimages to make the motion faster. Sometimes you want a particular subimage to be visible and don't want the program to cycle through all of them. This can be achieved by setting the speed to 0 and choosing the correct subimage. For example, assume you have an object that can rotate and you create a sprite that has subimages for a number of orientations (counter-clockwise). Then, in the step event of the object you can set
So in your object's create event you simply need to set the image_speed to a value less than 1 and that'll slow the animation down. If you want the animation to run at a specific speed, simply go into the sprite editor and tweak the speed there until you get the right effect, then remember that speed. Your value for image_speed is then calculated like this:
image_speed = <desired speed> / <room speed>
The desired speed is the speed that you remembered from the sprite editor. The room speed is how fast the room runs, usually 30 steps or frames per second. So if you want the animation to run at 15 fps your image_speed setting would be 15 / 30 = 0.5
Hope that explains it all.
-D
CiNiMoDZA
21-09-2007, 12:19 PM
Hey guys, got a wee little a problem here! I want to check to see if a car is approaching my car and Im not to sure how to do this, my theory is when I create the instance of the other car, it will get its distance, then 5 steps later it will get the distance again, and then subtract them! If its a positive number, its approaching, if its a negative, its not approaching! Here's what my code is:
if(instance_number(other_car) > 1)
{
dist1 = dist
calc_time +=1
if(calc_time = 5)
{
dist2 = dist
}
}
But when I check to see the two values, its always 0, but the dist value is never 0? Am I missing something?
dislekcia
21-09-2007, 02:14 PM
Your logic is always assigning the value of "dist" to both dist1 and dist2.
When the calc_time is less than five, you only assign dist1. BUT, when the calc_time is 5, you assign dist1 and dist2, so they get the same value which means your subtraction will always be 0.
-D
CiNiMoDZA
21-09-2007, 02:59 PM
No, I have an event for when I push enter it shows me dist1 and dist2, it shows them both as zero!!!
dislekcia
21-09-2007, 03:39 PM
No, I have an event for when I push enter it shows me dist1 and dist2, it shows them both as zero!!!
How many other_cars do you have? if(instance_number(other_car) > 1) will only return true if you've got more than 1 of them...
-D
CiNiMoDZA
21-09-2007, 04:06 PM
Ahh crap, Im such a dumbass :P Late nights and game dev!?!
Cyberninja
22-09-2007, 06:20 PM
Okay, a silly problem I can't seem to solve. I'm changing the jump button from the "up" key to the 'M' key using script. But when I try to change the key it doesn't work.
I'm currently using : keyboard_check(vk_up) Which works fine.
But when I change it to: keyboard_check(m) It doesn't work. Any ideas why? :/
Gazza_N
22-09-2007, 06:29 PM
Your problem here is that the keyboard check commands don't check letters - they check ASCII key codes. Instead of putting "M" in your keyboard_check(), you have to put the ASCII code corresponding to "M", which can be obtained through the ord() function. So, what you really want to do is use keyboard_check(ord('M')) (captial letter in single quotes). That should sort you out. :)
Cyberninja
22-09-2007, 06:37 PM
Your problem here is that the keyboard check commands don't check letters - they check ASCII key codes. Instead of putting "M" in your keyboard_check(), you have to put the ASCII code corresponding to "M", which can be obtained through the ord() function. So, what you really want to do is use keyboard_check(ord('M')) (captial letter in single quotes). That should sort you out. :)
Thanks Gazza. Works perfectly. Welcome to my credits list. :)
CiNiMoDZA
24-09-2007, 09:18 PM
Hey, I know this might be a nOOb question but, Im trying to get this free play done, the problem is when I push F4 its speeding up the tempo of all my sounds?
CiNiMoDZA
02-10-2007, 02:04 PM
Is it possible to to change those stupid Grey boxes that get your integers and strings!!! It really ruins it when you trying to keep a theme in your game!!
dislekcia
02-10-2007, 05:03 PM
Is it possible to to change those stupid Grey boxes that get your integers and strings!!! It really ruins it when you trying to keep a theme in your game!!
Yes. There are a bunch of functions that allow you to load custom colours and images that get used in those message boxes. Dig around in the help to find them.
Otherwise you could simply write your own "input box" objects and use keyboard_string to get the data that the player types. Of course you'd have to display everything yourself, but that's not too hard.
-D
CiNiMoDZA
02-10-2007, 10:12 PM
Any clues on where to start!! I tried typing in text box but nothing! Also, how would I get it to show the text with the keyboard_string command?
CiNiMoDZA
02-10-2007, 10:24 PM
NVM, got it :P
CiNiMoDZA
03-10-2007, 10:08 PM
Ok, another problem :P I have a menu that looks like this:
Start
Load
Quit
Now what I want it to do is highlight the selected menu! I show this using alpha blending whatever thats not important! In the code I have this:
Start Button:
Down Pressed:
selected = 0
load.selected = 1
[CODE]
Load Button:
Down Pressed:
selected = 0
quit.selected = 1
Up Pressed:
selected = 0
Start.selected = 1
Quit Button:
selected = 0
Load.selected = 1
But when I press down it goes straight to the quit button! I can see the load button start fading in but then stops straight away? How can I make it only go down once per push?
dislekcia
04-10-2007, 02:16 AM
Put your up and down logic in a seperate object. At the moment each time you push down all your buttons are firing their down events and the last one to execute (the last one you placed in the room) will "win".
To avoid that either make sure that a button will only do the up/down movement if it's currently selected, or move your logic to a single other object.
-D
CiNiMoDZA
04-10-2007, 11:03 AM
Ahh, ok. Makes sense! Thanks Dis :D Now another problem! In PRG's when people are talking, and the text type's its self out at the bottom! Like in Roach Toaster, how do you do this in GM?
T_Kill3r
10-10-2007, 07:23 PM
Hey. How do i make an object create another object at random intervals between 2 and 5 seconds?
to create an object in a script just use
instance_create(x,y,objectname);
and for your random timing, I can do it in a certain number of steps, which Im sure can be converted to seconds:
create:
counter = 0;
min_steps = 200;
max_steps = 500;
current = max_steps - round(((max_steps - min_steps)*(random(10)/100)));
step:
counter += 1;
if (counter == current) {
instance_create(x,y,objectname);
current = max_steps - round(((max_steps - min_steps)*(random(10)/100)));
counter = 0;
}
I hope this helps for now, Ive never worked with seconds in game maker to be honest :)
timespawner.gmk (http://www.gamedev.za.net/filecloset/data/files/244/timespawner.gmk)
dislekcia
10-10-2007, 08:50 PM
Use alarms. They're counters that GM automatically keeps track of for you, except they count down to 0 instead of up. To find out how many steps in a second of game time, you simply look at your room speed, that will try to run that many steps per second. The default is 30, so 2 seconds is 60 steps. That means that to get a random number of steps between 2 and 5 seconds you set an alarm to 60 + random(90) steps. Then create the object in that alarm event's actions and reset the alarm to another random time.
-D
T_Kill3r
11-10-2007, 05:48 PM
Thx alot guys :)
T_Kill3r
12-10-2007, 05:10 PM
ok.
Now i want to make a beam... it must be headin to the mouse from the cannon (its 2d).
And you should only have three beams available, and each should last only 15 seconds. I only know how to do half of all this, so any help will be appreciated :)
CiNiMoDZA
12-10-2007, 11:53 PM
Here you go, dont just use the code, read the comments so you know how to do it next time yourself!!!
http://gamedev.openhazel.co.za/filecloset/data/files/247/Shooter.gm6 (7k)
Just left click to shoot! Hope this helps ;)
T_Kill3r
13-10-2007, 12:47 PM
thx. I see how to do the ammo thing now.
But how do i make a 'beam' now?
CiNiMoDZA
13-10-2007, 02:11 PM
Use the instance_create code! Have a look in the shooter object under the global left pressed event. It has all the code there!!! Then to see how to make the beam move to where your mouse was, just check in the bullet object!!! Its all there ;)
T_Kill3r
13-10-2007, 03:27 PM
But you see, thats only to make ONE instance of the sprite. I want to make one continuous beam, like a laser. And to do this i probably need to make a a string of the sprite.
How can i upload my game so that it'll be easier for people to help me?
CiNiMoDZA
13-10-2007, 06:44 PM
Just go here:
http://gamedev.openhazel.co.za/filecloset/
You can upload files here!
T_Kill3r
14-10-2007, 12:28 PM
Ok. Its on. The 'beam' i have there at the objects is just to test out the ammo thing.
(and please excuse how much the game sucks. its only my 1st real one)
CiNiMoDZA
16-10-2007, 10:14 PM
Hmm, not bad T Kill3r, just first thing to note. You need to name your download correctly in File Closet!!! Otherwise it just downloads it as a file!! It took me a couple of tries before I realized that its a GM file!!! You need to add the file extension!! So, for example, you should have had .gm6 at the end of your file ;)
CiNiMoDZA
18-10-2007, 08:56 PM
Hmm, ok!! So now I want to try something that I haven't done before, so I've decided to try make an A.I! All I have at the moment is a check to see if the enemy can see me! Now if he cant, I want him to move to kind of search for me, but I dont know how to do this!!! When I use random(room_height) and stuff, he just vibrates! I want him to kinda look like he knows where he's going!!! One of the problems is that he doesnt try avoid walls!!! I see there is a command: mp_potential_path_object. Unless Im miss interpreting this, does this create a path that avoids a specific object? If so, how do I use this!!! Also, what is the purpose of creating a grid??
ShadowMaster
19-10-2007, 06:42 AM
Hmm, ok!! So now I want to try something that I haven't done before, so I've decided to try make an A.I! All I have at the moment is a check to see if the enemy can see me! Now if he cant, I want him to move to kind of search for me, but I dont know how to do this!!! When I use random(room_height) and stuff, he just vibrates! I want him to kinda look like he knows where he's going!!! One of the problems is that he doesnt try avoid walls!!! I see there is a command: mp_potential_path_object. Unless Im miss interpreting this, does this create a path that avoids a specific object? If so, how do I use this!!! Also, what is the purpose of creating a grid??
He just vibrates because he is only moving one random pixel at a time. You should make that he moves a tile width at a time.
You can script a patrol root for the char and make him follow that until he sees the player after which he constantly follow the player. But then you are still left with path finding issues... Which I don't know if GM has built in.
T_Kill3r
21-10-2007, 12:26 PM
Hmm, not bad T Kill3r, just first thing to note. You need to name your download correctly in File Closet!!! Otherwise it just downloads it as a file!! It took me a couple of tries before I realized that its a GM file!!! You need to add the file extension!! So, for example, you should have had .gm6 at the end of your file ;)
Sorry. my bad
CiNiMoDZA
21-10-2007, 10:04 PM
I want to draw a line tha must always be in the direction of my person! How do I make this line rotate with the person??
dislekcia
22-10-2007, 12:14 AM
I want to draw a line tha must always be in the direction of my person! How do I make this line rotate with the person??
You're really going to need to explain that a little more... What is your line pointing from and to? Is it limited in length? What have you tried so far?
-D
CiNiMoDZA
22-10-2007, 09:03 PM
Ok, so I have a Pacman dude, out of his mouth he draws a line, say 50 pixels long, but now im using image_angle = direction, so while he's moving around he's changing direction, so basically the line needs to rotate along with the person object, what I need basically is, the origin of the line must be my current x and y values, and the second x and y values must be +50 pixels in the direction Im facing!!!
Squid
22-10-2007, 09:12 PM
What you need is some trig!
Luckily GM does all the maths for you. The functions you want are lengthdir_x(len,dir) and lengthdir_y(len,dir). These do your based sin and cos functions to work out the co-ordinates of the point where the line must stop.
draw_line(x,y,lengthdir_x(linelength,direction),le ngthdir_y(linelength,direction));
That will draw a line from x,y to a point that is 'linelength' long in the direction 'direction'.
CiNiMoDZA
22-10-2007, 09:57 PM
Lol, I saw that but didnt think it was that easy :P My bad!!
EDIT --
So simple, yet no seeming to work?? Am I doing this right?
draw_line(Enemy.x, Enemy.y, lengthdir_x(5, Enemy.direction), lengthdir_y(5, Enemy.direction))
I dont know what its busy doing??
dislekcia
23-10-2007, 12:33 AM
Lol, I saw that but didnt think it was that easy :P My bad!!
EDIT --
So simple, yet no seeming to work?? Am I doing this right?
draw_line(Enemy.x, Enemy.y, lengthdir_x(5, Enemy.direction), lengthdir_y(5, Enemy.direction))
I dont know what its busy doing??
Which event is that in? If you read up on draw calls, you'll see that you can only call them and have them appear on screen during Draw events.
-D
CiNiMoDZA
23-10-2007, 10:00 AM
Its in my draw event!!!!
ShadowMaster
23-10-2007, 02:43 PM
Surely, this
draw_line(Enemy.x, Enemy.y, lengthdir_x(5, Enemy.direction), lengthdir_y(5, Enemy.direction))
must be this?
draw_line(Enemy.x, Enemy.y, Enemy.x+lengthdir_x(5, Enemy.direction), Enemy.y+lengthdir_y(5, Enemy.direction))
dislekcia
23-10-2007, 02:57 PM
Its in my draw event!!!!
I which object?
It seems like you're doing this from a logical object instead of the pacman object itself. If so, make sure that your logical object is visible and not being draw over by the pacman object...
-D
Squid
23-10-2007, 03:36 PM
Also ShadowMaster is right. lengthdir will give co-ordinates that are relative to 0,0. To make them relative to an object just add the x and y values.
Make sense?
CiNiMoDZA
23-10-2007, 06:23 PM
:D WAHEE, it does but now work :D
EDIT--
But it does but also dampen my spirits :( Im trying to make an arc, if the person colides with this arc, and there is no wall in the way, he is then visible to the enemy! So I can draw a collision line, Yay, but I need a collision arc, so I drew a triangle, took me a while to get the x and y values, but now it works, Yay, but now I see there is no collision_triangle command?!? Here is a link to the file!!! Please help!!!
http://gamedev.openhazel.co.za/filecloset/data/files/250/AI.gm6 (12kb)
P.S, the code is a bit messy but you can kinda see whats going on!! Im too lazy to add comments :P
EDIT EDIT-- :P
Lol, NVM! I just used a triangle object and made it transparent!! :P
cairnswm
28-10-2007, 08:00 PM
Why not make a shape that you can use as a collision check - in each step create an instance of the collision shape object, if there is a collision with the player then make the creating object chase the player.... At the end of the step, delete the collision object.
Does that make sense?
CiNiMoDZA
29-10-2007, 04:13 PM
Lol, thats what I ended up doing? Thanks anyways cairnswm!!!
Gazza_N
05-11-2007, 07:05 PM
Here's a fun one for those who have worked with 3D games.
As noted in my Deathbringer thread, I've needed to switch the perspective from first-person to isometric for speed reasons. As a result, I've needed to convert the weapons targeting to a cursor-based system. The problem is, of course, that since I am still using perspective projection for my graphics, the mech's targeting direction doesn't correlate with the position of the mouse cursor.
This would all be fixed if I just used orthographic projection, but perspective gives better results. What I need is a way to "project" my 2D cursor's position into 3D space. I've tried quick hacks using trig with miserable results, and quick searches at gamedev.net and SAgamedev turned up nothing except "just invert your projection matrix", which would be great if (a) I could access it or (b) knew the maths behind it so that I could derive something. Would anyone be so kind as to provide me with links or a quick lecture that could help me sort this out?
Thanks in advance.
Squid
06-11-2007, 11:47 AM
GLU.glunproject()
Just not sure how one would do it in GM...
dislekcia
06-11-2007, 02:14 PM
Here's a fun one for those who have worked with 3D games.
As noted in my Deathbringer thread, I've needed to switch the perspective from first-person to isometric for speed reasons. As a result, I've needed to convert the weapons targeting to a cursor-based system. The problem is, of course, that since I am still using perspective projection for my graphics, the mech's targeting direction doesn't correlate with the position of the mouse cursor.
This would all be fixed if I just used orthographic projection, but perspective gives better results. What I need is a way to "project" my 2D cursor's position into 3D space. I've tried quick hacks using trig with miserable results, and quick searches at gamedev.net and SAgamedev turned up nothing except "just invert your projection matrix", which would be great if (a) I could access it or (b) knew the maths behind it so that I could derive something. Would anyone be so kind as to provide me with links or a quick lecture that could help me sort this out?
Thanks in advance.
Okely dokely, it's time to bring out the maths.
The terminology you're looking for is vector projection and unprojection. Your view/projection matrix is a bunch of shorthand equations that convert points in 3D space to 2D points in screen space (except they're not really 2D points, you get a 4th term too which is what goes into your depth buffer, but that's not important as yet). Unprojection is the art of taking a point in screen space and projecting that into a ray that's perpendicular to the camera in 3D space. I'm not 100% sure of the actual mathematics behind that, it might be as simple as generating an inverse matrix from your projection matrix and multiplying vectors. I'll look into it...
The other problem comes in with not having direct access to matrix maths. You're going to need to look for a script library that does matrix maths for you in GM, or you're going to be stuck re-deriving things from first principles.
And your final problem comes in with figuring out what you want your projected ray to do in the game itself. You could mathematically check for intersections, but that would probably be a little slow. I'd calculate the point of intersection of your unprojected ray with the floor of your world and then move an invisible object there in GM, using that object's 2D collisions for picking and selection, etc.
-D
Gazza_N
06-11-2007, 05:41 PM
Thanks Dis. I'll do some poking around on the net. Fortunately, I can now laugh at all those who said I was a masochist for doing basic matrix maths at college. ;)
The only problem for now seems to be that I can't access the projection matrix in GM, meaning that it may be necessary to duplicate the whole mess in GML. If that's the case, then I"ll just use ortho projection, but I can't be the first person who's tried to do this in GM. Google is my friend. :)
Tr00jg
06-11-2007, 07:34 PM
I had this problem with Roach Toaster 2 too. I eventually figured out how to circumvent it with a nifty program.
I am not sure if this is precisely your problem, but it helped for me. I made a new object (called MouseMask). This object travels on the "bottom/world" plane according to where your mouse "should" be when projected to there. Now how DO you project it to there?
Step Event:
x=Camera.x + (mouse_x-Camera.x)*CameraHeight/MousePlaneHeight;
and vice versa for x.
This will "project" MouseMask to the bottom plane. Thus now your "mouse" isn't still technically there, but this object is. So now you just have to do checks via that object.
Say you want to click on something with your mouse, you do Event Global Left Released and just check if MouseMask is at its position.
I don't know how to "get" the height of the mouse plane, you just have to play around with numbers. I think it is the "height" of the room/view though. That is what mine is.
Here is the program to help you:
>Your mouse travels on the "mouse" plane. If extended from the camera to the "world" plane, that is where you WANT your mouse (ie in this case MouseMask) to be.
Controls:
Up, down - changes height of mouse plane
Left, Right - changes "position" of the mouse.
5kb
http://www.shotbeakgames.za.net/CamTestThing.gm6
Thus, the direction for your mech should point to MouseMask.
Hope that helped!
Gazza_N
06-11-2007, 08:11 PM
Thanks Tr00jg, much appreciated. I'll take a look. The only problem that might crop up is that I'm looking at my world from an isometric perspective, not a top-down one. As a result, my view corners and my mouseplane corners probably won't correlate. Still, I'll give your method a shot.
Something else just occurred to me - in Black and White, your mouse cursor existed as an object in 3D space (the "hand of god"). Why can't I use the same idea for a targeting cursor? It's not ideal, and it may take getting used to, but it'll certainly cut out a lot of complexity!
teh_3dit: I've prototyped the 3D object cursor, and it works well. Unless any niggles come up, this is what I'll be using for now. Thanks for the advice, everyone! :D
dislekcia
06-11-2007, 10:02 PM
Tr00jg's solution is pretty much a special case: The maths decomposes down to a few easy operations based on screen x and y because the matrix is perpendicular.
I'd suggest re-deriving your projection matrix based on what you're inputting (on paper) and see if you can get a similar decomposition to happen. Chances are that you'll also get it down to a few operations with some magic numbers for sin and cos angles as long as you keep your iso angle constant.
-D
Tr00jg
07-11-2007, 10:18 AM
Tr00jg's solution is pretty much a special case: The maths decomposes down to a few easy operations based on screen x and y because the matrix is perpendicular.
-D
True...
Hey, Gazza_N did you use my method?
Gazza_N
07-11-2007, 11:45 AM
Heh, no. Sorry. ;) As Dis says, your solution is only applicable to a top-down perspective. Since mine is isometric, the view of the room isn't rectangular, it's trapezoidal. What I've done for now is create a cursor object that exists in 3D space, is controlled by the mouse, but isn't linked at all to the main Windows cursor position except to detect mouse movement. It works surprisingly well, although I'm still working on constraining it properly. I'm also going to try taking Dis up on his suggestion that I derive a special-case alg of my own for cursor placement if I have more problems. Gives me an opportunity to use some long-dormant matrix maths, if nothing else. ;)
Cyberninja
10-11-2007, 07:32 PM
Edit: Doh! >.< I uploaded the wrong version. Nevermind.
01DT!m3r
12-11-2007, 06:14 AM
a friend and I , are designing an MMO using game maker but we are having a little problem giving each player a unique id so they can write into data that the host can then read .if anyone has some code or ideas please help!
01DT!m3r
12-11-2007, 06:32 AM
oh and does anyone know any good applications that i can use to make really awesomerific looking spriter thanks :-)
What my MUD is going to use is a system comprising of 2 databases, and when you register you are given rights to a single line in the database (the communication database) and what you do is put there for my server app to check what you did, and then provide output, all using csv (comma separated values).
I believe the type of access is called user level access, and all the client would do is connect to the database.
In your case Im assuming you would rather want it so they dont have direct access to any database, so then you could have a table and use it to store onlne players details (IP, username, password) that they're connected with, and using that you could have unique ID's automatically made for you, or create your own primary key for more customised Logon/User ID's.
I hope I have helped a little bit.
EDIT: Now that I think about it, depending on what language you use you could use linked lists, and therefore not need a database! I didnt think about it before because I still know hardly anything about them, and havent looked at them enough to know what theyre all about.
If you are using C++:
cprogramming (http://http://www.cprogramming.com/tutorial/lesson15.html)
dislekcia
12-11-2007, 01:34 PM
a friend and I , are designing an MMO using game maker but we are having a little problem giving each player a unique id so they can write into data that the host can then read .if anyone has some code or ideas please help!
The easiest way to ensure the each connected player has a unique ID is to have the server give them that ID. The logic flow is rather simple, assuming the server is running:
Player starts game on their machine, henceforth called the client.
Client connects to server, client joins the correct session.
Client sends a special message to the server, asking for a unique ID. You can't use GM's data write/read for this because you have no "safe" slot to put it in (what if multiple clients ask at the same time?), so you need to use messages. Read up on them in the GM help.
Server generates a unique ID for the client, sets up storage for that client and links that ID to the client's address (the mplay commands can get player connection IDs too).
Server sends unique ID back to only that client, not broadcast data.
Client receives ID, tags all future messages with it.
Now your client can do actual message passing, like logging on, playing, etc.
Personally I recommend starting your exploration of network programming with a simpler game than an MMO, but it's your call. I think you'll find that networking is a lot more complicated than it sounds... That doesn't mean that you can't do it, just that you need to work your way up to doing it on such a large scale.
-D
01DT!m3r
12-11-2007, 02:31 PM
thanks guys for all your support . . . i will definetly be asking more or ( and helping as much as possible) i have made some simple death match type games with GM but no more than two players . . . THANKS AGAIN . . ps if anyone uses mxit please notify me and we can keep in touch . . . thanks:-)
01DT!m3r
13-11-2007, 06:45 AM
i am almost done with a few games of mine but have no where to upload them so that i can get feedback from the community . . . any suggestions?
cairnswm
13-11-2007, 08:55 AM
http://www.gamedev.za.net/filecloset/
01DT!m3r
13-11-2007, 01:55 PM
thanks alot . . . i will be posting i game i was working on for the game.dev contest 15 . . . but didnt meet the deadline cause of school :-( . . thanks again . . . oh and i have heard you that there are sometimes game.dev LANs . . . . please someone post when the next one will be thanks
ShadowMaster
13-11-2007, 05:30 PM
thanks alot . . . i will be posting i game i was working on for the game.dev contest 15 . . . but didnt meet the deadline cause of school :-( . . thanks again . . . oh and i have heard you that there are sometimes game.dev LANs . . . . please someone post when the next one will be thanks
Please, I beg you, use capital letters and please note ellipses(3 fullstops) are only used when you want to show an incomplete idea or want to get someone to think. In all other cases use just one fullstop.
For smilies leave out the hyphens and they become way cooler. ;)
Anyway congrats on finding us and I hope you enjoy your stay. Sorry for sounding rough, but I had to strain my eyes to read your post and in any case good langauge never hurt anyone. ;)
01DT!m3r
13-11-2007, 06:21 PM
No problem Shadow master .Sorry about that but those last few posts were done with my phone and i find it easier to type like that on my phone .SORRY guys for any icnovenience(I hope that is spelt right.)i will definetly enjoy the forums thanks guys!
SkinkLizzard
13-11-2007, 06:23 PM
hey just as a question about lans kinda need to know what area you're in :)
ShadowMaster
13-11-2007, 06:35 PM
No problem Shadow master .Sorry about that but those last few posts were done with my phone and i find it easier to type like that on my phone .SORRY guys for any icnovenience(I hope that is spelt right.)i will definetly enjoy the forums thanks guys!
No, it's fine, I understand typing on a cellphone is difficult and constantly switching between upper and lowercase doesn't make it any better. And good luck with your MMO.
01DT!m3r
13-11-2007, 06:42 PM
thanks.oh um skinklizzard i am in weltevreden , west of Johannesburg I think , i am about 5km from from allen glen high school if that helps in the Roodepoort area
SkinkLizzard
13-11-2007, 06:46 PM
ah ok joburg regionish then that would be fengol or dislekcia who arrange the lans I think
01DT!m3r
13-11-2007, 06:50 PM
thanks I will definetly ask them.
dislekcia
13-11-2007, 08:00 PM
Fixed ;)
And yes, we do need to organise more DevLans and HotLabs... Problem is that this time of year is notoriously difficult due to exams and all that. I'm very out of touch with school cycles, so I have no idea when it's a good time and when not, that means I tend to just sort of go "Oh, November and December are bad times... sigh".
-D
01DT!m3r
13-11-2007, 08:20 PM
okey.Well if it helps i know that all schools in my area close on the 21st or the 22nd of November.
|-|1Pp13
15-11-2007, 12:04 PM
Hey im trying to learn visual basic to make .dll's for my GM games and i was wondering if anyone can help me to use random/randomize? im just playin around with the windows application and it doesn't want to work.
Also as a matter of interest whats the best way to clean a keyboard(/mouse)?
01DT!m3r
15-11-2007, 12:31 PM
Well I clean my keyboard by hitting it against the table(not hard though ).just enough to get the dirt out .Then I wipe it down with a slightly damp cloth.:0
|-|1Pp13
15-11-2007, 01:24 PM
so do i but theres lil bits of wat look like chips and hair that dont wanna come out!
is the random for visual basic? as visual basic doesnt have its own random function as far as I know, all my programs in visual basic that have required random have used a custom written function I found when googling for random in visual basic, if you want I can give you that.
I dont see why you would need it though, Game Maker has a random function built into it.
dislekcia
15-11-2007, 02:28 PM
Hey im trying to learn visual basic to make .dll's for my GM games and i was wondering if anyone can help me to use random/randomize? im just playin around with the windows application and it doesn't want to work.
How do you mean it doesn't work? I take it you need random numbers generated inside your DLL, because GM has a perfectly good random function ;)
-D
Public Function Rand(ByVal Low As Long, _
ByVal High As Long) As Long
Rand = Int((High - Low + 1) * Rnd) + Low
End Function
Here, hope this helps you :)
|-|1Pp13
15-11-2007, 03:53 PM
Thanx! and i wanted random for my visual basic project im working on...separate from my gm one
in visual basic cntrl+space there is random+randomize in that lil menu that pops up!
what version of visual basic are you using? (I use 6)
Pseudo-random numbers are chosen with equal probability from a finite set of numbers. The chosen numbers are not completely random because a definite mathematical algorithm is used to select them, but they are sufficiently random for practical purposes. The current implementation of the Random class is based on Donald E. Knuth's subtractive random number generator algorithm. For more information, see D. E. Knuth. "The Art of Computer Programming, volume 2: Seminumerical Algorithms". Addision-Wesley, Reading, MA, second edition, 1981.
The random number generation starts from a seed value. If the same seed is used repeatedly, the same series of numbers is generated. One way to produce different sequences is to make the seed value time-dependent, thereby producing a different series with each new instance of Random.
To improve performance, create one Random to generate many random numbers over time, instead of repeatedly creating a new Random to generate one random number.
Dim instance As Random
|-|1Pp13
15-11-2007, 04:05 PM
its the 2005 express edition . hmmm.....probably very different
|-|1Pp13
15-11-2007, 04:07 PM
ahhh...thanx!
I have the following:
- VB 6
- VB EE 2005
- VB.net
I just prefer VB6. :) glad I could help
|-|1Pp13
15-11-2007, 04:19 PM
and lets say i had to output this to a label (Label1)
dim number as random
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Label1.Text = number
End Sub
it gives me the error:
Error 1 Value of type 'System.Random' cannot be converted to 'String'.
i dont know wat the conversion type is!
Dim rRandom As New Random
Dim iVar As Integer
iVar = rRandom.Next()
Label1.Text = Str(iVar)
Here you go :)
|-|1Pp13
15-11-2007, 04:33 PM
thanx!! :)
|-|1Pp13
15-11-2007, 04:37 PM
now i have a whole new problem...i forgot what i was going to use it for :P
|-|1Pp13
15-11-2007, 04:41 PM
lol the tgd website basically reffers you back here
:P Im working on content, exams are just getting in the way.
Game Maker Q:
If I write a dll, how would I use things from it in GM?
like I write a few functions in a VB dll, would it use those specific functions?
for example:
public sub test(byval iNum as integer)
'do various things here
end sub
test(123);
And Q no. 2:
Would you 'import' the dll?
or use an include or usage statement?
using mydll.dll test()
or
include mydll.dll
etc
|-|1Pp13
15-11-2007, 04:55 PM
dont know....the gamemaker help confused the hell out of me.
im busy trying dlls to try teach myself
but wat i could piece together was you write the function
include the file in GM with a function(in Gm in a piece of code) including arguments
call on the fuction in the dll and it should do it execute it in the game....
but dont quote me on that :p
|-|1Pp13
15-11-2007, 05:00 PM
i think you have to use it twice...include the file the file in the game options thingy and once in the code
|-|1Pp13
15-11-2007, 05:03 PM
im thinking of starting a thread just for VB and .dll's?
|-|1Pp13
15-11-2007, 06:39 PM
Is it possibe in GM to add an action in a piece of code?
eg add a Draw action in a piece of code that is in the Alarm event?
|-|1Pp13
15-11-2007, 07:23 PM
Ok this might sound stupid but in my gm in the code window when i type code and then want to insert it inserts over. not between...and its not the insert button...tried that. didn't help
eg
random50 //forgot the brackets
random(0 //when i type the code instead of...
random^(^50
dislekcia
15-11-2007, 09:35 PM
Is it possibe in GM to add an action in a piece of code?
eg add a Draw action in a piece of code that is in the Alarm event?
Yes. Read the help entries on object_event_add().
Ok this might sound stupid but in my gm in the code window when i type code and then want to insert it inserts over. not between...and its not the insert button...tried that. didn't help
eg
random50 //forgot the brackets
random(0 //when i type the code instead of...
random^(^50
If you're 100% sure it's not the insert button (you can see the insert status in the lower left corner of the code window - INS vs OVR) then close and restart GM. That usually fixes strange stuff like that. Make sure you save.
-D
|-|1Pp13
16-11-2007, 11:06 AM
Yes. Read the help entries on object_event_add().
If you're 100% sure it's not the insert button (you can see the insert status in the lower left corner of the code window - INS vs OVR) then close and restart GM. That usually fixes strange stuff like that. Make sure you save.
-D
nope but after 2 reboots and some battlefield 2 it was working again
(very strange)
thanx 4 da help anyways!
01DT!m3r
16-11-2007, 03:09 PM
hey everyone I was just wondering is there a thread for gamedevs and hotlabs ?
|-|1Pp13
16-11-2007, 06:07 PM
hey is the game in a day(GID) website still running because it says september as the next compitition???!!!!
|-|1Pp13
16-11-2007, 06:38 PM
my current situation:
i have these objects:
Clip
Player
Bullet
Bullet_clip
What i want them to do:
The clip is a base object that is only used as a reference point or for creating bullet_clip
bullet_clip is a sprite, each one represents a bullet (your ammunition)
when global mouse button is pressed it must create a bullet at the players position
ive basically done that but my problem is how do i delete the relevent bullet_clip?
Cyberninja
16-11-2007, 06:39 PM
Hey guys. How do I make particles take on a custom shape in GM? In the shape of a cross etc? o.O
|-|1Pp13
16-11-2007, 08:40 PM
Hey guys. How do I make particles take on a custom shape in GM? In the shape of a cross etc? o.O
you need to create your sprite in the shape you want
when you create your particle type just selct the sprite you want. ill post an screenshot now
|-|1Pp13
16-11-2007, 08:49 PM
http://drop.io/helpshot1
follow the URL. if it doesn't work type
"drop.io/helpshot1" directly, it isn't password protected and it will be automaticallty deleted after 1 month :) hope it helps
dislekcia
17-11-2007, 02:35 AM
my current situation:
i have these objects:
Clip
Player
Bullet
Bullet_clip
What i want them to do:
The clip is a base object that is only used as a reference point or for creating bullet_clip
bullet_clip is a sprite, each one represents a bullet (your ammunition)
when global mouse button is pressed it must create a bullet at the players position
ive basically done that but my problem is how do i delete the relevent bullet_clip?
I'm afraid I don't understand the problem... What does Clip do? Could mean that you want to delete Clip, if so I don't understand why you're creating one in the first place. Why aren't your bullets destroying themselves when they hit something?
Wait... Are Clip and Bullet_Clip interface objects or something? If so, either read up about pointers in the GM help (see what instance_create() returns, it'll help) or keep track of how many bullets you have and change Clip's draw method to draw that many sprites.
-D
|-|1Pp13
17-11-2007, 09:30 AM
Wait... Are Clip and Bullet_Clip interface objects or something? If so, either read up about pointers in the GM help (see what instance_create() returns, it'll help) or keep track of how many bullets you have and change Clip's draw method to draw that many sprites.
-D
vague but helpful...tanx!-im gonna use stacks, should solve my problem
|-|1Pp13
17-11-2007, 12:13 PM
yup stacks work but now got a new question...
im key mapping (so you can use either WASD or the arrow keys) and i was wondering whats the keyboard code (For the letters). the GM help didn't help
how would you map it?
SkinkLizzard
17-11-2007, 12:31 PM
http://gamedev.openhazel.co.za/filecloset/data/files/267/KeycodeFind.exe
this will return the keycode of keys you press.
not perfect though as the arrow keys report as having an associated character.
|-|1Pp13
17-11-2007, 12:36 PM
this will return the keycode of keys you press.
not perfect though as the arrow keys report as having an associated character.
Thanx! but how would i use this in key mapping?
SkinkLizzard
17-11-2007, 12:51 PM
do you want users to be able to set their own controls?
if so then its just a little more complex and I'll post the source to that silly little app I made.
but if you just want to for example map awsd to the arrow keys then its somewhat simple.
set up the game to use the arrow keys, create an object called keyMapInit (not really necessary but I don't know where all your stuff is) in this objects create event put the following code:
keyboard_set_map(vk_up,<keycode number displayed in the KeycodeFinder when you press w>)
keyboard_set_map(vk_down,<keycode number displayed in the KeycodeFinder when you press s>)
keyboard_set_map(vk_left,<keycode number displayed in the KeycodeFinder when you press a>)
keyboard_set_map(vk_right,<keycode number displayed in the KeycodeFinder when you press d>)
remember to replace the stuff inside the <>
other wise I'll whip up a documented example for you.
|-|1Pp13
17-11-2007, 12:55 PM
then its just a little more complex and I'll post the source to that silly little app I made.
i know how to do the source but thanx.
thats all i needed (im writing it in a dll so i can use it for all my games, its just to automatically map the WASD and arrow keys so you can use either)
Cyberninja
17-11-2007, 08:22 PM
http://drop.io/helpshot1
follow the URL. if it doesn't work type
"drop.io/helpshot1" directly, it isn't password protected and it will be automaticallty deleted after 1 month :) hope it helps
Hi. I apologise for not explaining properly. :) What I meant is: is it possible to make particles follow a certain shape, like the cross below?
http://img3.freeimagehosting.net/uploads/ede2934215.jpg (http://www.freeimagehosting.net/)
* the fire was just a quickie. I know it's fugly. lol.
|-|1Pp13
17-11-2007, 09:39 PM
Hi. I apologise for not explaining properly. :) What I meant is: is it possible to make particles follow a certain shape, like the cross below?
* the fire was just a quickie. I know it's fugly. lol.
sorry cant help with the complex stuff :D
im a low level programmer...eg check out the game im currently working on: Military
dislekcia
18-11-2007, 01:04 AM
im key mapping (so you can use either WASD or the arrow keys) and i was wondering whats the keyboard code (For the letters). the GM help didn't help
how would you map it?
In the GM help it gives you the method: Use the ord() command to find the ascii value of the key you're pressing and you'll have the keycode. I use stuff like key_pressed(ord("w")) all the time.
-D
|-|1Pp13
18-11-2007, 10:21 AM
In the GM help it gives you the method: Use the ord() command to find the ascii value of the key you're pressing and you'll have the keycode. I use stuff like key_pressed(ord("w")) all the time.
-D
thanx ....i found a better way to do my key mapping though
eg: keyboard_set_map(65,vk_left)
i used a handy progrom i got from Skinklizard
sorry buddy but im gonna make my own and fix the keyboard errors....dont worry you will still recive credit
dislekcia
18-11-2007, 12:53 PM
thanx ....i found a better way to do my key mapping though
eg: keyboard_set_map(65,vk_left)
i used a handy progrom i got from Skinklizard
That number you're getting from Skinklizard's program? That's exactly what the ord() function returns ;)
-D
|-|1Pp13
18-11-2007, 01:02 PM
i know ;)
dislekcia
18-11-2007, 01:06 PM
Hi. I apologise for not explaining properly. :) What I meant is: is it possible to make particles follow a certain shape, like the cross below?
http://img3.freeimagehosting.net/uploads/ede2934215.jpg (http://www.freeimagehosting.net/)
* the fire was just a quickie. I know it's fugly. lol.
The best way to do that is to create emitters in the pattern of the shape/object you want to mimic. You're not restricted to one emitter per particle system, nor one type of particle. You could probably mimic most shapes using a few well-placed point emitters. There are methods to automatically select points on shapes that you don't pre-build, but that might be overkill for your needs atmo.
-D
Cyberninja
18-11-2007, 05:22 PM
Ah, I see. Cool, thanks Dis. ^_^ I'll tinker with the emitters and see what happens. I was trying to re-create the look of Diablo. But I wanted to try using particles instead of sprites. Will play around some more. :)
Edit: Yay! ^_^ You were right. :) *Reiner tilesets used for testing.
http://img3.freeimagehosting.net/uploads/465b6fa959.jpg (http://www.freeimagehosting.net/)http://img3.freeimagehosting.net/uploads/66cee9cbc2.jpg (http://www.freeimagehosting.net/)
http://img3.freeimagehosting.net/uploads/fcd1e96f43.jpg (http://www.freeimagehosting.net/)
dislekcia
19-11-2007, 02:15 AM
The only thing I can say is: Wow! ****-wow.
-D
Powered by vBulletin® Version 4.2.4 Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.