Title: code
Description: can you code
Erik - September 29, 2003 07:41 PM (GMT)
i think im a 9 :D provided I can use the latest DSL.
ok
but im not doing GM too often lately, im busy surfing, playing new games, and drawing (new hobby ^_^)
Donovan_dcann - September 22, 2003 04:06 AM (GMT)
Hey how here is good at coding???
snabela - September 22, 2003 04:09 AM (GMT)
At a scale between 1 and 10 where 10 is best I am 8!
Burning Sheep Productions - September 22, 2003 06:30 AM (GMT)
I don't know everything.
I don't know how to do arrays.
But I'm still very good.
Cuz I do code and code only.
No D&D allowed for me.
Donovan_dcann - September 22, 2003 09:51 AM (GMT)
no the scale 1-10 I'm a 7 arrays I kind of under stand it a bit.
Star fox - September 22, 2003 10:54 PM (GMT)
Monkster - September 22, 2003 11:03 PM (GMT)
ya...i can't do arrays...but i know my way round GM pretty well...and i use lots of code...not very much D & D...i'd give myself a 7 outta 10
BomberJake - September 23, 2003 10:54 PM (GMT)
6/10 so-so. i don't understand all coding, but what i do understand makes up for the other 4/10 :D
Donovan_dcann - September 24, 2003 01:29 AM (GMT)
Burning Sheep Productions - September 24, 2003 01:35 AM (GMT)
Monkster - September 24, 2003 01:42 AM (GMT)
Burning Sheep Productions - September 24, 2003 01:48 AM (GMT)
Donovan_dcann - September 24, 2003 03:11 AM (GMT)
Burning Sheep Productions - September 24, 2003 12:12 PM (GMT)
Donovan_dcann - September 24, 2003 10:47 PM (GMT)
Ok Burning Sheep Productions about the Arrays An array is like a long list of variables with the same name, but with a (usually) numerical index that tells them apart. Suppose that you have a need to lots of very similar variables, like the location of different text in our example. We could write it like this:
in create event
| CODE |
text[0] ="Hey!!" text[1] = "What's Your Name??"; text[2] = 'Donovan'; text[3] = 'where do you live??'; text[4] = 'In ontario canada'; text[5] = 'How old are you??'; text[6] = "I'm 27 "; |
in drawing event
| CODE |
| draw_text(80,80,text[0]); |
now give it a test
ok now that you have dun that
you should see the text Hey!!
but how do you change it to the next text???
so we create a new variable call it
in create event
in drawing event we will change the code to
| CODE |
| draw_text(80,80,text[nexttext]); |
so now we need to change nexttext value in the key press event for the up key we will do this
now give it a test again :unsure:
did you get an error :( not to worry :rolleyes: we need to fix that....
we know that text index gose from 0-6.
so we create a new variable call it
so in step event we will check if nexttext >Maxtext we will set it nexttext back to 0;
| CODE |
if nexttext>Maxtext { nexttext = 0; }
|
now give a try again :blink:
now you should have an idea how array work right :D
Monkster - September 24, 2003 10:58 PM (GMT)
now i get it...its actually really simple...how would u use this in a game?
Donovan_dcann - September 24, 2003 11:07 PM (GMT)
i dont know Monkster ;) i just explane how to use it :D
Donovan_dcann - September 24, 2003 11:08 PM (GMT)
did you try it?? :unsure:
Monkster - September 24, 2003 11:15 PM (GMT)
not yet...but i will...right now im on a pc that doesn't have GM on it, yet.
Donovan_dcann - September 24, 2003 11:26 PM (GMT)
ok when you get some time :D
Tropper - September 24, 2003 11:40 PM (GMT)
I only code when i need to. I try to use the drop drag options. lol :lol:
Donovan_dcann - September 24, 2003 11:51 PM (GMT)
I stop using D&D a long time a go :rolleyes:
Burning Sheep Productions - September 25, 2003 03:28 AM (GMT)
Woah!
I've been using arrays all this time and I never knew!
I tohught they were that kind of:
if i<100 i=1 i!=5
I dunno but I don't understand one bit of that.
Donovan_dcann - September 25, 2003 09:53 AM (GMT)
ok Burning Sheep Productions it's not
it's for like
Donovan_dcann - September 25, 2003 10:01 AM (GMT)
I'll try to give you a example when i get home :rolleyes:
Burning Sheep Productions - September 26, 2003 01:11 AM (GMT)
Heh, danke.
What's it called?
Donovan_dcann - September 26, 2003 01:13 AM (GMT)
ok we will use the for with draw_sprite(sp,0,0,0)
so load up a sprite any sprite and rember the width of it.
in create event we will create a varaible name
now in key press event for up put code
and in the down press event
now in drawing event we will draw the sprite0 wtih image number 0
and the x and y position.
so you should have this
| CODE |
| draw_sprite(sprite0,0,20,20); |
so lest look at the for so we have a varaible we call it a
so a has a value of 0 now if a less than a value say 1 then
a will + or - a value so we have this for(a =0;a<1;a+=1)
we will use the varaible food so now we have for(a=0;a<food;a+=1)
so now we will use it with the draw_sprite(sp,0,0,0)
now here we go
| CODE |
for(a=0;a<food;a+=1;) { draw_sprtie(sprite0,0,20,20); } |
now give it try
what happen nothing :(
we will add the sprite width to x 20
so we have thisdraw_sprite(spriet0,0,20+32,20);
so now we will take the sprite width and multiply by a
now we have thisdraw_sprite(spriet0,0,20+32*a,20);
now give it try and press up and doun key
Burning Sheep Productions - September 26, 2003 01:17 AM (GMT)
I kind of...
Well...
I would've done it differently.
Donovan_dcann - September 26, 2003 01:20 AM (GMT)
Burning Sheep Productions - September 26, 2003 01:23 AM (GMT)
I'd have the food thing in the key events but just have:
draw_sprite(sprite0, 0, 20+food, 20);
Donovan_dcann - September 26, 2003 01:28 AM (GMT)
ok that wont work :( sorry that will make the sprite move left :D
Burning Sheep Productions - September 26, 2003 01:32 AM (GMT)
Fizzwhizz?
I'm confused.
I would've done:
sprite_set_width();
Donovan_dcann - September 26, 2003 01:41 AM (GMT)
Donovan_dcann - September 26, 2003 02:08 AM (GMT)
there is no function for sprite_set_width();
Burning Sheep Productions - September 26, 2003 03:24 AM (GMT)
There isn't?
Then howabout:
sprite_width();
I dunno what it is but I saw it in the manual yesterday.
Donovan_dcann - September 26, 2003 09:55 AM (GMT)
| QUOTE |
| sprite_width* Indicates the width of the sprite. This value cannot be changed. |
now how can you use it with draw_sprite(sp,0,0,0);
Burning Sheep Productions - September 27, 2003 09:03 AM (GMT)
You don't.
Are you useing v5 or v5.1?
Donovan_dcann - September 27, 2003 04:11 PM (GMT)
Burning Sheep Productions - September 28, 2003 02:53 AM (GMT)
That's why you can't change sprites in real time!
Donovan_dcann - September 28, 2003 05:14 AM (GMT)
yes i can :rolleyes:
| CODE |
| clown = sprite_add("C:\Program Files\Game_Maker5\Sprites\pacman\monster1.gif", 0, true,true ,true , false, 0, 0); |