G-9 2019-11-12 12:07
Just a mini RPG. Draws of items are in ! ( It is for you to remix ...)
was8bit 2019-11-12 16:43
Looks great :)
I have streamlined your code by using a SUB which is a VERY powerful tool.... the sub I added can be used to control ANY little sprite including computer enemied ;)
A SUB acts like a mini program, so all variables used inside a SUB are seperate from all other variables outside a SUB... so X used in your program is DIFFERENT than X used in a SUB.... thats how you can use a SUB generically for anything..
I changed your program X To X1 just in case you wanted to add more sprites.... you can change x1,y1 into anything you want, but the variables inside the SUB should NEVER be changed.
Also, one IMPORTANT note, use WAIT VBL only ONCE at the bottom of your main DO LOOP, and you should really never use WAIT again in your games... this way ALL moving things will seem more natural... if you want something to move slower then 1 per loop, use maybe 0.5 or 0.1 to control their speed ;)
Post any questions :)
was8bit 2019-11-12 16:55 (Edited)
... let me break down the SUB for you... remember a SUB is kinda like you programming your own command ;) this SUB can be used to move ANY sprite
So YOU would use
So, X1,Y1 can be changed but should be the variables your program uses to keep track of the X,Y location of the sprite you are wanting to move
#1,#2 are the amounts of movement in the x,y directions... use a 0 for no movement in a direction
#3 is the number of the sprite.... in your case it is 1.... to move a different sprite, use that sprite's number instead
#4 is the sprite image, or character#... if you want the same image all the time, just use the same image... to use different images for different directions (as i have done) then use a different #s for each direction
G-9 2019-11-12 17:01
G-9 2019-11-12 17:01
can you help me ? I created a topic ...
was8bit 2019-11-12 17:06
There is an additional trick i can show you....
I will let you exlpore this trick.. post if you have questions ;)
was8bit 2019-11-12 17:32
One last update ;)
was8bit 2019-11-12 17:34 (Edited)
On the last update it was easier to keep the computer player as one image... there are a few tricks that can be used to have that automatic.... but i would rathr you understand what ive done so far before adding extra tricks...
DJMoffinz 2019-11-13 02:54
Timo 2019-11-13 07:29
I wouldn’t agree with “Never use WAIT”. It depends very much on the type of game and wanted control. Also using decimal numbers for positions can complicate the logic. Sometimes the simple solutions are the best, it always depends.
was8bit 2019-11-13 12:48 (Edited)
I could have worded myself better.... i have seen too many new to programming write many little "rabit trails" of code that go off and do this, and go off and do that, using WAIT a few times in each one to help control the timing in each trail... then don't understand why all of their other rabbit trails are stopped and not running while one rabbit trail is running...
I have found best practice is to focus on one main DO LOOL with one WAIT VBL and that way everything can go...
For example, using several WAIT's in a section of code to control the animation or movement of a bullet until it hits something means everything else on the screen freezes until the bullet hits something... the game maker then wonders why everything else freezes when the bullet gets fired....
All movements should be incrementally adjusted via each pass thru the main game DO LOOP.... that way everything can move at the same time....
But then this means you have to make your code smart enough to know what the status is of each thing so your code can know what it needs to do at any given pass thru the loop..
So, for example, you may need a variable for a bullet status so your code knows that if this bullet isnt yet fired then do nothing, if this bullet just now fired, update the bullet data as to where it is and its direction of travel, if the bullet is active and moving then update its position, if this bullet has hit something, process that event... if the programmer wants an explosion then now update the explosion... and finally once the explosion is done change the final bullet status to now unused and ready to be fired again...
For the issue of timing, if everything is getting moved by 1 each time it is moved, then that means everything will be going the same speed... i use decimal movements as an easy way to slow something down... alternatively, to slow one thing down and NOT use decimal movement, then you will have to add a timing variable to everything... so for example a slower bullet will need say TBULLET and TMAXBULLET so you can do INC TBULLET each pass thru the main game loop.. and then use IF TBULLET=TMAXBULLET THEN move bullet one space, and reset TBULLET=0..
I just think using decimal movements is a much easier way to slow something down in your main DO LOOP
multiple DO LOOPS are fine, just as long as you realize that all other DO LOOPS stop...
Now, in the GAME MAKER software, this isn't true...each "thing's" programming simutaneously runs at the same time... which for me was constantly confusing... in LOWRES NX, each one line is executed at a time... it does NOT run multiple lines of code simultaneosly....
G-9 2019-11-13 17:31