Jump to content


Photo
- - - - -

Rts Tutorial 1


  • Please log in to reply
38 replies to this topic

#1 Rani_sputnik

Rani_sputnik

    GMC Member

  • GMC Member
  • 456 posts
  • Version:GM:Studio

Posted 16 June 2010 - 01:10 AM

  • Title: Easy Top-down --> Isometric Converting
  • Description: Easilly converts back and forth between isometric and top-down.
  • GM Version: GM 8 (But the scripts alone should work with older versions of Game Maker)
  • Registered: Probably not.
  • File Type: .gmk
  • File Size: 0.02MB
  • File Link: Download Here
Additional Info
The example isn't too flash but the engine is very capable. Hope you like it! Credit would be lovely, but not required. Apologies about the game info btw. I was originally going to write the tutorial there but I decided on the site here was a bit nicer. THis way people can see the functions before they download. YAY!


Isometric Rendering

Posted Image

Isometric is a perspective without perspective (ha! a witty opener) and I still don't know of a simple way to explain it (hence the Age of Empires image). Basically it takes the x and y axis and puts them on angles, then adds a third axis (z) in the upwards direction. Its often used in tech drawing, but became quite popular during the 90's in rts games. Sadly it has almost died out, but that's what we are here for! So shall we get started?


The Process


So one day, having done a bit of research into this isometric business, it occured to me that calculating EVERYTHING in isomtric was very difficult. Almost as hard as calculating regular 3d, so I tried to think of ways my poor little artist brain could understand it. The conclusion I eventually came to was this engine.

Basically what happens is the entire game is calculated like a top-down game, until it comes time to render the thing. Before it is drawn, all instances calcuate their isometric co-ordinates and they are drawn there instead. This gives the illusion of isometric, while allowing for all of Game Maker's other functions to be used in a simle way (mp_grids for example). This was a break through for me because all of a sudden I had a very simple way of transferring top-down movement (which lets face it is rather boring) into psuedo 3d movement! And I didn't even need to do any of those stupid calculations where I need to reduce speed by half when moving vertical and pathfind around diamond tiles etc.

The other great thing about only drawing in isometric is its REALLY easy to change the view-point of the game. Thaaaaaaaat's right, this engine can render in four different view points (NE,SE,SW and NW), and possibly even top-down if you make it so. Anyway without further ado, on to the engine itself.


The Isometric Engine


To start with we need to set up the game to allow isometric rendering. There is ONE function that will do this for you

iso_start(factor) Begins viewing the room in an isometric projection.


Now what this does is sets up all the variables needed for the isometric engine to work, so MAKE SURE YOU CALL IT BEFORE ANY OTHER FUNCTION. factor refers to the ratio of the y axis to x. So if we want the 'diamond' to be half as tall as it is wide, all we need to put here is 0.5 and done.

Note: In this isometric engine the co-ordinates actually work the opposite way to what you would think. In the 'top-down' processing, everything needs 3 co-ordinates, so that the isometric position can be calculated but when it comes to the isometric rendering, we actually only need two, x and y, because we are talking in terms of the position on the screen rather than the position in the room. The screen is 2d, the room 3d catch my drift? Hope that's clear enough.

Once we have the game set up there is another thing we can do that's very simple and that is set the projection.

iso_set_projection(direction) Sets the direction in which the world will be viewed.


The game automatically sets itself to North-East projection but this can be changed to 3 other directions, each with a corresponding numerical value.
So for direction, 0=North East, 1=South East, 2=South West and 3=North West. Nothing else needs changing for all the other functions to work correctly.


Calculating Position

So once we have the easy stuff out of the way, its time to get on to the truely useful functions. These functions calculate an objects drawing co-ordinates, based on its 3 dimensional position in the room.

iso_get_x(x,y,z) Function returns the x co-ordinate used for drawing the instance in isometric.

iso_get_y(x,y,z) Function returns the y co-ordinate used for drawing the instance in isometric.


Easy enough? Before you draw, simply call these functions to find the x and y positions wher you should draw

Note: Make sure you take a look at the spriting tips below to ensure the position is correct.

So what happens if we have something on the screen like the mouse? Remember mouse_x and mouse_y are no longer the mouses position in the room, they are its isometric drawing co-ordinates. To get its real position, we need to perform the following functions.

iso_get_regx(isox,isoy,z) Function returns the x co-ordinate based on isometric co-ordinates.

iso_get_regy(isox,isoy,z) Function returns the y co-ordinate based on isometric co-ordinates.


Sweet as, we whizzed through that, now onto the next show!


Easy Depth

Depth is a problem that always plagues isometric engines. The depth in this engine works in layers. Let me explain. Everything with the lowest isoy co-ordinate and the lowest layer number will be drawn first. Then the stuff with the same isoy, but a higher layer number will be next. Then once all the layers are drawn, the engine moves onto the next lowest y value. This way, the closer to the bottom of the screen stuff is, the closer it gets to the viewer, make sense? For this to work we need to define the number of layers we wish to use.

iso_set_depth(depthmin,layers) Sets the depth to be used in the functions.


Now depthmin refers to the depth to use for the top layer at the bottom of the drawing field, and layers is the number of layers to use in the room. Now though this depth seems very limited, it is really useful for flying instances or clouds.. i dunno, I haven't eplored many possibilities. Once improvement that I have only considered as I write this is to allow multiple depth grids. So for example, having the tiles all in a depth grid, so that tiles can overlap with the correct depth, but having them all behind another depth grid, which is used for the instances. Note that that is not currently possible with the engine, but I'll get to work on it straight away.

Anyways back to depth. When it comes to the actual calculation there are two possibilities

iso_get_depth(isoy,z,layer) Returns a depth value based on the units position in the room.


This function can be used to get the depth of instance based on its position in the room. HEED THIS WARNING: This will use a HUGE number of depth values, especially for larger rooms, so this should only really be used on things that wont have their depth updated in every step (tiles for instance).

The other function is much more useful in my opinion

iso_get_depth_view(isoy,z,layer) Returns a depth value based on the units drawing position in the view.


(There is a typo on this in the script, it says room instead of view)
This function takes the minimum drawing position to be the bottom of the current view, so only uses depth values that are currently needed (as we don't need to be drawing anything that's outside the view do we :D)


The End?

NO OF COURSE NOT. Sure I have run out of functions to throw at you but I can still be a bother by giving you some handy hints.

TIP 1 - Masks
EVERY object in your game will need a mask for its top-down collisions. Because its not being auto-drawn, it needs to keep a mask at its top down position to have any sort of presence in the room.

TIP 2 - Center of the image
The example doesn't really show this because it doesn't handle collisions but if you want to do collisions, where you place the 'origin' of the sprite is important. This requires some visualisation on your part. If your sprite has a square mask, try to visualise this square in isometric (it will become a diamond) Now chuck this diamond onto your sprite. Even if on your mask the origin is in the middle, chances are you wont want it in the middle for your sprite. THe diamond should be at the foot of your soldier, so the middle of the diamond will actually be towards the bottom of the sprite. I hope I haven't confused anyone with this, just be careful is all I'm trying to say haha.

TIP 3 - Oh, I only had two tips :(

I hope you guys found this tutorial useful. There'll be more RTS goodness soon, have fun with it!
  • 5

My games - In DecemberBoy Goes to Space, Proleague (Facebook & Kongregate), Making WayJam Tart (GMCJam#14)

Currently working on FloxGM - All-in-one backend for leaderboards, scores, cross device saves and analytics

Check out my website: ryanloader.me, or follow me: twitter.com/RaniSputnik


#2 krele

krele

    GMC Member

  • GMC Member
  • 638 posts
  • Version:GM:Studio

Posted 08 July 2010 - 09:20 AM

Why, why, WHYYYY do people just ignore awesome stuff like this?...

You made something brilliant, being glad to share your knowledge, and people do nothing. They don't give any feedback...

Let's just face it, GMC sucks and is overrun by script kiddies that just wanna download an uber-cool-ultimate engine to make the game for themselves...

Too bad =/... This engine is awesome =)
  • 0

If I helped you, you can help me back :3

Brocoola


#3 Shadowrend

Shadowrend

    Master of Shadows

  • GMC Member
  • 3054 posts
  • Version:GM8

Posted 08 July 2010 - 10:21 AM

Indeed. This is awesome.
  • 0

#4 zeldarules28

zeldarules28

    GMC Member

  • GMC Member
  • 215 posts

Posted 08 July 2010 - 04:17 PM

I saw this too, and its really cool. I downloaded it yesterday and I like it, but Im not skilled in rts programming enough to do this. Well..maybe sort of.. If I start working on an rts Ill definntly use this. Ive been looking for a tutorial on how to do this. Thanks!
  • 0

#5 Phantom107

Phantom107

    Graphics Enthusiast

  • GMC Member
  • 2763 posts
  • Version:GM:Studio

Posted 08 July 2010 - 04:21 PM

You know, the problem with RTS tutorials is that the novice users cannot make a game out of it, and advanced/expert users write their own system anyway.
  • 0

GMCSignature.png

 

The most advanced GM game yet. Check out the Titan Rush GMC topic here! Developed by Phantom Technology


#6 ga05as

ga05as

    GMC Member

  • GMC Member
  • 881 posts

Posted 18 July 2010 - 10:11 PM

I haven't tested this out yet, but it sounds very good.
I am going to extend this for my purposes. and this will REALLY help with my game.
Thanks very much.
If i finish it. You can have credit :P
  • 0


#7 freko

freko

    The Professional

  • GMC Member
  • 504 posts
  • Version:GM8

Posted 19 July 2010 - 12:41 PM

Has anyone made an iso RTS map editor :( . I really need one
  • 0

#8 CaptainLepidus

CaptainLepidus

    GMC Member

  • GMC Member
  • 851 posts
  • Version:GM:HTML5

Posted 19 July 2010 - 06:23 PM

Damn, at first I thought that was a screenshot of the examplePosted Image Still awesome though.

EDIT: I worked on your .gmk a bit. I added in a way to create+draw correctly iso backgrounds starting only with a top down background (plus I added in some iso blocks).
If you want it, here's a link to the .gmk:
Iso test1.gmk

Edited by CaptainLepidus, 19 July 2010 - 07:53 PM.

  • 0

"The reason programming is addictive is the same reason a good game is addictive: it constantly feeds you with a sense of minor accomplishment on your way to [achieving] the greater goal."

Yal

Planning to build a network of like-minded, innovative GameMaker developers, connected by a set of tools for building awesome games. Interested? PM me.


#9 Manuel777

Manuel777

    InvaderGames

  • GMC Member
  • 3554 posts
  • Version:GM:Studio

Posted 20 July 2010 - 12:36 AM

Awesome tutorial, i was looking for something like this some time ago... i spent like two days trying to figure out how in hell can i make and isometric pacman game xD (it wasnt even a project... i was bored :( )
  • 0

#10 CaptainLepidus

CaptainLepidus

    GMC Member

  • GMC Member
  • 851 posts
  • Version:GM:HTML5

Posted 24 July 2010 - 03:58 AM

I just had to bump this because this is an awesome example and it shouldn't fall off the first page.
  • 1

"The reason programming is addictive is the same reason a good game is addictive: it constantly feeds you with a sense of minor accomplishment on your way to [achieving] the greater goal."

Yal

Planning to build a network of like-minded, innovative GameMaker developers, connected by a set of tools for building awesome games. Interested? PM me.


#11 Rani_sputnik

Rani_sputnik

    GMC Member

  • GMC Member
  • 456 posts
  • Version:GM:Studio

Posted 24 July 2010 - 10:47 PM

Hey thanks for all the replies! Sorry I hadn't replied sooner, I actually forgot about this tutorial given all the work I'm doing for comp06 :/ oops hehe.

@ Krele && Shadowrend && manuel777
Thank you so much :D Any suggestions for the next version?

@ Zeldarules
I have tried to make everything as clear as possible so that you don't need to understand the internal workings of the scripts, but if it gets too confusing, let me know and I can go over with you step by step using the engine.

@ Phantom
Much truth in your words my friend, I just thought since this is a bit of a different way of thinking I better post it haha.

@ Freko

Has anyone made an iso RTS map editor. I really need one


They're really easy once you know how much you need to put into them. If you pm me with more specific questions I can help you out.

@ CaptainLepidus
Thanks dude I'll check out your improvements when I get home, I'll try include them in the next version. What would you like to see improved? Thanks for the bump too haha
  • 0

My games - In DecemberBoy Goes to Space, Proleague (Facebook & Kongregate), Making WayJam Tart (GMCJam#14)

Currently working on FloxGM - All-in-one backend for leaderboards, scores, cross device saves and analytics

Check out my website: ryanloader.me, or follow me: twitter.com/RaniSputnik


#12 jackyboyhenry

jackyboyhenry

    just jack

  • GMC Member
  • 466 posts

Posted 27 July 2010 - 11:11 AM

Why, why, WHYYYY do people just ignore awesome stuff like this?...

You made something brilliant, being glad to share your knowledge, and people do nothing. They don't give any feedback...

Let's just face it, GMC sucks and is overrun by script kiddies that just wanna download an uber-cool-ultimate engine to make the game for themselves...

Too bad =/... This engine is awesome =)

Im a kid.. and.. i like this engine :D
  • 0
Im to cool for a nice signature.

#13 peceecar

peceecar

    GMC Member

  • New Member
  • 321 posts

Posted 28 July 2010 - 01:41 PM

i can not thank you enough for this it will grately help me with the design of my own projects
  • 0

#14 Rani_sputnik

Rani_sputnik

    GMC Member

  • GMC Member
  • 456 posts
  • Version:GM:Studio

Posted 28 July 2010 - 08:42 PM

Wow more and more compliments, thanks heaps guys! Any improvement suggestions though? I can't work on the engine atm but after competition06 I will be creating a new version. If you want to have input lemmie know now.

Cheers
  • 0

My games - In DecemberBoy Goes to Space, Proleague (Facebook & Kongregate), Making WayJam Tart (GMCJam#14)

Currently working on FloxGM - All-in-one backend for leaderboards, scores, cross device saves and analytics

Check out my website: ryanloader.me, or follow me: twitter.com/RaniSputnik


#15 freko

freko

    The Professional

  • GMC Member
  • 504 posts
  • Version:GM8

Posted 29 July 2010 - 05:06 AM

Wow more and more compliments..

And more to come ^_^

Edited by freko, 29 July 2010 - 05:12 AM.

  • 0

#16 leocesar

leocesar

    GMC Member

  • New Member
  • 25 posts

Posted 26 August 2010 - 08:07 AM

I love people like you! great tut.
  • 0


#17 CaptainLepidus

CaptainLepidus

    GMC Member

  • GMC Member
  • 851 posts
  • Version:GM:HTML5

Posted 26 August 2010 - 05:02 PM

Note about my addition to the example: make sure you go to global game settings and turn off Interpolate between pixels to get a good look.
  • 0

"The reason programming is addictive is the same reason a good game is addictive: it constantly feeds you with a sense of minor accomplishment on your way to [achieving] the greater goal."

Yal

Planning to build a network of like-minded, innovative GameMaker developers, connected by a set of tools for building awesome games. Interested? PM me.


#18 Hillstrom

Hillstrom

    GMC Member

  • New Member
  • 28 posts

Posted 28 August 2010 - 07:15 PM

And don't forget that this tutorial/example also work for any kind of game type, not only RTS.
Even works for parallax games, (Zelda, 16 bit RPGs), again just messing with the draw events only. I am right... Right?
The only thing this Top View => Isometrics conception doesn't solve by itself is "jumping", but for RTS is just the way to go.
  • 0

#19 Rani_sputnik

Rani_sputnik

    GMC Member

  • GMC Member
  • 456 posts
  • Version:GM:Studio

Posted 02 September 2010 - 10:12 AM

I love people like you! great tut.


Why thank you, it's great to hear.

@ Captain Lepidus, I am kinda embarrassed that you had to effectively create a new example for yourself since mine was so useless lmao. In fact that is an apology to you all, my example is aweful. I am hoping so release an example of how to use this engine for rpg style games and rts when I release the next version (hopefully after uni finishes up for the year). I promise it will be good. the way I figure it the depth needs to be easier to use, but is there anything else you would like to see in the next version? Anyone? Last chance... (Well not really, uni still has a while yet)

Oh and @ Hillstrom, yes it can be used for jumping. If you add a z co-ordinate to the object you want to use it, you'll be all good.
  • 0

My games - In DecemberBoy Goes to Space, Proleague (Facebook & Kongregate), Making WayJam Tart (GMCJam#14)

Currently working on FloxGM - All-in-one backend for leaderboards, scores, cross device saves and analytics

Check out my website: ryanloader.me, or follow me: twitter.com/RaniSputnik


#20 CaptainLepidus

CaptainLepidus

    GMC Member

  • GMC Member
  • 851 posts
  • Version:GM:HTML5

Posted 02 September 2010 - 09:32 PM


I love people like you! great tut.


Why thank you, it's great to hear.

@ Captain Lepidus, I am kinda embarrassed that you had to effectively create a new example for yourself since mine was so useless lmao. In fact that is an apology to you all, my example is aweful. I am hoping so release an example of how to use this engine for rpg style games and rts when I release the next version (hopefully after uni finishes up for the year). I promise it will be good. the way I figure it the depth needs to be easier to use, but is there anything else you would like to see in the next version? Anyone? Last chance... (Well not really, uni still has a while yet)

Oh and @ Hillstrom, yes it can be used for jumping. If you add a z co-ordinate to the object you want to use it, you'll be all good.


No, this is an awesome example! I just wanted to see what I could do with it. Seriously, I would never have figured out how to convert top down to isometric by myself.
  • 0

"The reason programming is addictive is the same reason a good game is addictive: it constantly feeds you with a sense of minor accomplishment on your way to [achieving] the greater goal."

Yal

Planning to build a network of like-minded, innovative GameMaker developers, connected by a set of tools for building awesome games. Interested? PM me.


#21 mortalpico

mortalpico

    GMC Member

  • New Member
  • 556 posts

Posted 04 September 2010 - 12:27 AM

can you make a GM7 version of it?
  • 0
"Remembering ISHIMURA..."

#22 Rani_sputnik

Rani_sputnik

    GMC Member

  • GMC Member
  • 456 posts
  • Version:GM:Studio

Posted 14 September 2010 - 10:38 AM

can you make a GM7 version of it?


Lol fair point... Ummm I uploaded the scripts somewhere hang on... Here! It wont have an example but hopefully my explaination of the scripts will be enough to help you out. I will try remember to upload a GM7 version with the update.

Cheers for the replies!
  • 0

My games - In DecemberBoy Goes to Space, Proleague (Facebook & Kongregate), Making WayJam Tart (GMCJam#14)

Currently working on FloxGM - All-in-one backend for leaderboards, scores, cross device saves and analytics

Check out my website: ryanloader.me, or follow me: twitter.com/RaniSputnik


#23 weckar

weckar

    Helping Hand

  • GMC Member
  • 2616 posts
  • Version:Unknown

Posted 14 September 2010 - 01:50 PM

If only it was easier to do iso human sprites... or to rip them xD
  • 0
Just had my 10-year forum anniversary. Feeling - Even - Older.
Awards & Recognitions:
Spoiler

[I have a nasty habit of writing "it is" simply as "it". Please forgive me, I try to avoid it.]

#24 goldage5

goldage5

    GMC Member

  • GMC Member
  • 152 posts

Posted 02 March 2011 - 01:46 AM

:(*crying* aaaawww!!!! this doesnt work in lite!!!!!!! :( :( i hate it when my computer breaks!!!!!:angry: :angry:

would it be possible to make a lite version of this??? pleaaase????
  • 0

#25 Rani_sputnik

Rani_sputnik

    GMC Member

  • GMC Member
  • 456 posts
  • Version:GM:Studio

Posted 03 March 2011 - 09:13 AM

I'm pretty sure the scripts all work with lite. I'm pretty sure this example will too. Hopefully this helps. :) I got a bit of a suprise to see this old beast pop back up on the community, I should really update it.
  • 0

My games - In DecemberBoy Goes to Space, Proleague (Facebook & Kongregate), Making WayJam Tart (GMCJam#14)

Currently working on FloxGM - All-in-one backend for leaderboards, scores, cross device saves and analytics

Check out my website: ryanloader.me, or follow me: twitter.com/RaniSputnik


#26 SimplySeth

SimplySeth

    GMC Member

  • GMC Member
  • 79 posts
  • Version:GM:Studio

Posted 09 March 2011 - 07:49 AM

Finally!! I've been trying to figure out this whole isometric calculating thing and I never thought of rendering it like that. My method always led to complicated room setups and way too many bugs.

One thing I'm struggling with your engine though. I don't understand your rotate script or the physics you use for moving. I tried manipulating them but I can't seem to shake the "balloon" physics if you know what I mean. The unit will travel around in circles around the goal and it will never reach its destination. What would be the easiest way to make a unit travel from point A to point B without any of the unnecessary 'turning' or 'circling'?



Good job on the engine and keep up the good work!

Edit::

Nevermind, problem mostly solved.

Edited by SimplySeth, 09 March 2011 - 08:10 AM.

  • 0

Posted Image
"It's a big Universe, everything happens somewhere," --The Doctor


#27 Rani_sputnik

Rani_sputnik

    GMC Member

  • GMC Member
  • 456 posts
  • Version:GM:Studio

Posted 09 March 2011 - 08:54 AM

I know you said you mostly solved it but it's a good point that needs re-stating, and this goes for everyone. Make everything like you would in a top down game, movement included. Only the drawing needs to be isometric. Thanks btw, I should really actually make some other RTS tutorials... lol. But it is always nice to see this pop up on the first page of the tut list :)

Rani
  • 0

My games - In DecemberBoy Goes to Space, Proleague (Facebook & Kongregate), Making WayJam Tart (GMCJam#14)

Currently working on FloxGM - All-in-one backend for leaderboards, scores, cross device saves and analytics

Check out my website: ryanloader.me, or follow me: twitter.com/RaniSputnik


#28 Boysano

Boysano

    GMS Pro Member

  • GMC Member
  • 409 posts
  • Version:GM:Studio

Posted 10 March 2011 - 07:05 PM

I know you said you mostly solved it but it's a good point that needs re-stating, and this goes for everyone. Make everything like you would in a top down game, movement included. Only the drawing needs to be isometric. Thanks btw, I should really actually make some other RTS tutorials... lol. But it is always nice to see this pop up on the first page of the tut list :)

Rani


Thanks so much for this!

I'm new to GM8, just got my pro version, did all the basic tuts and started developing my own RPG/RTS game and this solves most of my first issues already lol - like getting a unit to travel to destination even after i unselect it.
And making the selection block (rectangle) with mouse outline and show transparent in it. Very nice.

I hope my graphics designer friend will keep up with the iso method :) I'm already seeing diamonds.

thanks, hope to see more
  • 0

#29 Rani_sputnik

Rani_sputnik

    GMC Member

  • GMC Member
  • 456 posts
  • Version:GM:Studio

Posted 10 March 2011 - 08:17 PM

Cheers Boysanyo.

I have an idea for the new version finally!

Better example
New functions (see below)
Easier to use! :o *what? How?*

My idea is this. You call iso_start() to begin using the iso engine.
Next in each object you want isometric, you simply call iso_instance_create() and this script automatically adds a littl script into that objects step end step event which updates the isometric co-ordinates. These co-ordinates are stored in the object as isox and isoy.
Then all you need to do is use them like built in variables for the object! Likewise depth will also be updated in this manner... oooh excitemtent.
But of course I'll have a function to switch off this automatic updating and it can be stopped with iso_end too.
Two functions -> object is ready to use, can't get much easier than that right? I'm at uni all day so I don't know when I'm gonna work on it, but I hope it's soon.

Let me know if any of you have any more ideas for the engine, cheers!
Rani.

I suddenly thought, wait what if they change the projection during the step event???? *scandal* also depth is based on position so best do it after all the moving is done

Edited by Rani_sputnik, 10 March 2011 - 08:19 PM.

  • 0

My games - In DecemberBoy Goes to Space, Proleague (Facebook & Kongregate), Making WayJam Tart (GMCJam#14)

Currently working on FloxGM - All-in-one backend for leaderboards, scores, cross device saves and analytics

Check out my website: ryanloader.me, or follow me: twitter.com/RaniSputnik


#30 SimplySeth

SimplySeth

    GMC Member

  • GMC Member
  • 79 posts
  • Version:GM:Studio

Posted 11 March 2011 - 07:03 AM

Quick question...

I know how to solve the movements but the sprite drawing is confusing me.

I used a system of arrays to check if the sprite is standing, walking, attacking, etc. the state is later defined by the variable 'state' when the character is walking, standing, etc.

So my creation code looks like this.

/*set the IMAGE CHECK variables 
state
0 = stand
1 = walk 
2 = attack

sub-state
0 = up
1 = down
2 = right
3 = left
*/

//for standing
state_anim[0,0] = spr_conscript_upstand;
state_anim[0,1] = spr_conscript_downstand;
state_anim[0,2] = spr_conscript_rightstand;
state_anim[0,3] = spr_conscript_leftstand;
//for walking
state_anim[1,0] = spr_conscript_upwalk;
state_anim[1,1] = spr_conscript_downwalk;
state_anim[1,2] = spr_conscript_rightwalk;
state_anim[1,3] = spr_conscript_leftwalk;

I obviously don't get the math. When call the different directions in the draw event, it bugs out and only works for some directions.

if direction < 315  && direction > 45 {draw_sprite(state_anim[state,2],-1,iso_get_x(x,y,0),iso_get_y(x,y,0));}
if direction < 45 && direction > 135 {draw_sprite(state_anim[state,0],-1,iso_get_x(x,y,0),iso_get_y(x,y,0));}
if direction < 135 && direction > 225 {draw_sprite(state_anim[state,3],-1,iso_get_x(x,y,0),iso_get_y(x,y,0));}
if direction < 225 && direction > 315 {draw_sprite(state_anim[state,1],-1,iso_get_x(x,y,0),iso_get_y(x,y,0));}



so is iso_get_x and iso_get_y for projecting any instances on the screen? or is just to place the object itself and not used for drawing sprites in the draw event?

Sorry, i'm super confused :blink:
  • 0

Posted Image
"It's a big Universe, everything happens somewhere," --The Doctor


#31 Rani_sputnik

Rani_sputnik

    GMC Member

  • GMC Member
  • 456 posts
  • Version:GM:Studio

Posted 12 March 2011 - 06:47 AM

Okay so I'll start by saying I'm really sorry how vague the sprite stuff is haha. I plan to update that soon and will be much more self explanitory in the next example.

so is iso_get_x and iso_get_y for projecting any instances on the screen? or is just to place the object itself and not used for drawing sprites in the draw event?


Picture it this way. The room in which your instances are moving is 3d, the screen is 2d yes? Well the isox and isoy represent screen co-ordinates for an x,y,z position in the room. Effectively the iso_get_x and y are a 3d->2d conversion script. Yes, isox and isoy are where you want to be drawing your sprite. You are mistaking the problem I'm afraid, the isox and isoy you're doing perfectly the problem comes with the direction checking.

One of the biggest issues with checking a direction is that 360 degrees and 0 degrees are the same thing. It's really important not to forget this when you program but it is certaintly easy when such a simple thing just comes as common sense. It means that when you come to check if the instance is right you have to make sure it's either less than 45 or greater than 315. Seems silly? Well I had to edit this post because I made that mistake. Lol. Like I say it's an easy thing to do trust me.

Now some fixy code stuff
if direction > 315  || direction < 45 {draw_sprite(state_anim[state,2],-1,iso_get_x(x,y,0),iso_get_y(x,y,0));} 
if direction > 45 && direction < 135 {draw_sprite(state_anim[state,0],-1,iso_get_x(x,y,0),iso_get_y(x,y,0));} 
if direction > 135 && direction < 225 {draw_sprite(state_anim[state,3],-1,iso_get_x(x,y,0),iso_get_y(x,y,0));} 
if direction > 225 && direction < 315 {draw_sprite(state_anim[state,1],-1,iso_get_x(x,y,0),iso_get_y(x,y,0));}

The other problem was that you had the greater than/less than signs the wrong way around, everything else was perfect.
Sorry for that long-winded explanation, I love to rant :)

Hope it helps (works) lol
Rani.

EDIT : Ooops made a mistake hehe. Fixed the code so it will actually do something now.
EDIT2: That is such a frieken cool avatar btw

Edited by Rani_sputnik, 12 March 2011 - 06:54 AM.

  • 0

My games - In DecemberBoy Goes to Space, Proleague (Facebook & Kongregate), Making WayJam Tart (GMCJam#14)

Currently working on FloxGM - All-in-one backend for leaderboards, scores, cross device saves and analytics

Check out my website: ryanloader.me, or follow me: twitter.com/RaniSputnik


#32 SimplySeth

SimplySeth

    GMC Member

  • GMC Member
  • 79 posts
  • Version:GM:Studio

Posted 13 March 2011 - 01:25 AM

Oh ok I see now. I thought I was using the scripts right I just wasn't sure. Thanks so much for the explanation!


lol. Yeah, my avatar came from a game concept stuck in my head for the longest time. It's called Amadeus: about a cardboard box guy who lives in a cardboard box village with other cardboard box people. Life was good until plastic people (they look kinda like lego guys) invade with their most diabolical weapon ever: fire! It's up to Amadeus and the BoxBrother's infantry division to storm the plastic stronghold and put out all the fire along the way. =) it's kind of a silly game concept but I really want to do something with a cardboard box character.
  • 0

Posted Image
"It's a big Universe, everything happens somewhere," --The Doctor


#33 Boysano

Boysano

    GMS Pro Member

  • GMC Member
  • 409 posts
  • Version:GM:Studio

Posted 16 March 2011 - 10:56 AM

Fantastic i like your ideas to improve it into script functions and make it more like a dynamic engine,
so it is easier to use.

This sprite code is also useful, even on this thread, for us noobs.

Lets admit it, we need to learn how to integrate your engine in the best way for the other normal codes.

Thanks again!
  • 0

#34 Boysano

Boysano

    GMS Pro Member

  • GMC Member
  • 409 posts
  • Version:GM:Studio

Posted 16 March 2011 - 08:36 PM

I tried your iso movement code for the player sprite, and get same static sprites in diff direction.

It does move in correct direction, and I made the "state" variable set to 1 whenever an arrow button on keyboard is pressed?

I'm struggling more to figure out how to use this iso view properly?
How do i get rid of white spaces around the room or allow another room to load, seems like it bugs other rooms i imported.

Could you plz so me aka noob, simple example of how i must incorporate my chars in what you call normal 2d design to work with this iso?

Sorry dont mean you must write my game for me, im just struggling lots with this one. :(
  • 0

#35 Bezique

Bezique

    GMC Member

  • GMC Member
  • 40 posts

Posted 28 April 2011 - 03:56 PM

Hi rani_sputnik

I just wanted to say thanks for posting this tutorial. It's really very good. I have recently blended your methods as described here with the TBS engine made by TheHateSeed. I've posted an image of my progress in his thread. I'm not finished making all aspects of the isometric functions work yet, but it's coming along nicely.

Thanks
  • 0

#36 SimplySeth

SimplySeth

    GMC Member

  • GMC Member
  • 79 posts
  • Version:GM:Studio

Posted 12 June 2011 - 03:53 AM

This topic deserves a bump!

I could use some help on my isometric engine. If anyone can lend a hand click on the link in my signature
  • 0

Posted Image
"It's a big Universe, everything happens somewhere," --The Doctor


#37 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • GMC Elder
  • 17274 posts
  • Version:GM:Studio

Posted 05 July 2011 - 03:06 AM

If this had a more concrete example than just a balloon, it would make staff choice
Perhaps you could add a few rooms and incrementally demonstrate the engine features/interations
  • 0

#38 Ancientart

Ancientart

    GMC Member

  • GMC Member
  • 129 posts
  • Version:GM:Studio

Posted 09 July 2011 - 06:11 AM

doesnt seem to work! >< under obj balloon says some statement is missing 2 arguments
  • 0

#39 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • GMC Elder
  • 17274 posts
  • Version:GM:Studio

Posted 09 July 2011 - 06:27 AM

doesnt seem to work! >< under obj balloon says some statement is missing 2 arguments


The tutorial is for gm8... not gm8.1
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users