Jump to content


Photo
- - - - -

Thesnidr's Mode 7


  • Please log in to reply
70 replies to this topic

#1 TheSnidr

TheSnidr

    That guy

  • Global Moderators
  • 2440 posts
  • Version:GM:Studio

Posted 31 August 2009 - 01:10 PM

  • Title: TheSnidr's Mode7
  • Description: A 3D system not using GM's d3d. Also fakes the SNES' background scaling mode 7!
  • GM Version: GM 8
  • Registered: Yes
  • File Type: .rar
  • File Size: 816kb
  • File Link:
    http://host-a.net/u/playway/Mode7.zip
  • Please comment if you download :)

Additional Info
Hi, and thanks for showing interest in my fake 3d first person/ mode 7 engine!
This engine provides an oldschool effect called Mode 7, a background scaling technique that gives an illusion of 3D space, without entering game maker's 3D mode at all! Take Mario Kart for the SNES as an example.

Please give credit when used!

Posted Image

It also comes with functions for drawing different primitives and sprites.

This is based on the "Wannabe 3D" engine, which was made for use with topdown and platform games.

How to use
Before calling any of the other scrips, you must call fps_set_projection. This script creates all the variables needed to make the engine work.
fps_set_projection(camera_x,camera_y,camera_z,camera_angle,camera_tilt,camera_offset,view_scale,max_dist,min_dist)
  • camera_x/y/z: The position of the viewer in the room
  • camera_angle: The direction you're looking, in degrees
  • camera_tilt: Tilt the camera slightly up and down. Note, you cannot look directly up or down. For default setting, write 0
  • camera_offset: Set to a negative value to place camera behind player, and positive to place it in front. For default setting, write 0
  • view_scale: The scale of the world around you. A scale of 1 makes things appear the same size they are in the room editor. I usually use a scale of 10 or greater.
  • max_dist: The maximum drawing distance in pixels. Things further away than this won't be drawn
  • min_dist: This argument is rather abstract, but it basically moves the minimum drawing distance. It's a relative scale, and doesn't have a meaningful measure. Positive numbers move it in front of the camera, negative move it behind the camera. For default setting, write 0
This script should be placed in the create event of the camera object. To update it in real time, something you usually want to do, you should also place it in end step event of the same object.

Now that you've set the projection, you can start adding content. The fps_draw_sprite script has pretty much the same arguments as the function draw_sprite, except it adds 3 arguments:
fps_draw_sprite(sprite_index,image_index,x,y,z,xscale,yscale)
  • Sprite_index/image_index: The image of the sprite that is to be drawn
  • x/y/z: The position of the origin of the sprite
  • xscale/yscale: The scale of the sprite. Use 1 for default

Here's how to draw a wall
fps_draw_wall(texture,x1,y1,z1,x2,y2,z2)
  • texture: Supply a texture index. Find the texture index of a sprite by using sprite_get_texture(sprite_index,image_index)
  • x1,y1,z1/x2,y2,z2: Similar to the function draw_rectangle, only in 3 dimensions: Draws a textured rectangle with lower left corner at (x1,y1,z1) and upper right corner at (x2,y2,z2).

The engine also comes with a script for drawing with background scaling mode 7, a scaling method that's been popular since 3D games on SNES (mario kart, f-zero).
Here's how to use it:
fps_draw_mode7(texture_index,quality,repeat,z,width,height)
  • texture: Supply a texture index. Find the texture index of a sprite by using sprite_get_texture(sprite_index,image_index)
  • quality: A relative scale, where higher means better, but slower. I usually use a quality of 3 or 4.
  • repeat: Whether or not to repeat the texture, drawing them tiled.
  • z: The z-value, hopefully this needs no explanation
  • width/height: The width and height of the texture in the room, as seen from above. To make it fill the whole room, write "room_width,room_height"

Games made with this engine
Doom
Airfighter
Mario Kart

Affine texture mapping
As some of you know, game maker uses affine texture mapping. For those who didn't know, here's the difference between affine and correct mapping: http://upload.wikime...ure_mapping.jpg
This is the reason for "waves" or morphing appears on the ground or on fake 3d walls. As you can see on the picture of the mario kart track, the area close to the camera is a little wavy. That's the doing of the affine texture mapping.
More triangles will fix this problem though - but too many will slow your game down.
Your job will be to find the perfect scale between looks and speed.
Good luck!
  • 0

#2 PivotGamer84

PivotGamer84

    GMC Member

  • New Member
  • 170 posts

Posted 04 September 2009 - 06:04 AM

Well, as like your last w3d engine, nice job, the only thing thats causing me to not really want to use this, is the fact that when the mouse view is rotated, it stretches the building in the second room. Maybe fixable, maybe not.
  • 0

#3 TheSnidr

TheSnidr

    That guy

  • Global Moderators
  • 2440 posts
  • Version:GM:Studio

Posted 04 September 2009 - 01:48 PM

Please leave a comment when downloading. Give me your opinion.
I worked a lot on this engine, it's sad to see it being ignored.

PivotGamer84:
Wait, how did you manage to post before me? There were no posts in the topic when I posted :S
The stretching is because the engine uses affine texture mapping, and can't be fixed. But hey, that's only charming right?

Edited by TheSnidr, 04 September 2009 - 04:12 PM.

  • 0

#4 dadio

dadio

    I miss my cupcake

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

Posted 04 September 2009 - 07:14 PM

Great engine! :snitch:

Keep up the good work! :lol:
  • 0

#5 eafg2

eafg2

    GMC Member

  • GMC Member
  • 166 posts

Posted 05 September 2009 - 05:30 PM

This will kick d3d out!
The camera is a litte odd? :snitch:
Anyway, this is good.
  • 0

#6 TheSnidr

TheSnidr

    That guy

  • Global Moderators
  • 2440 posts
  • Version:GM:Studio

Posted 08 September 2009 - 08:35 AM

This will kick d3d out!
The camera is a litte odd? :)
Anyway, this is good.

Is the camera odd?
What do you mean?

Edited by TheSnidr, 08 September 2009 - 08:36 AM.

  • 0

#7 eafg2

eafg2

    GMC Member

  • GMC Member
  • 166 posts

Posted 08 September 2009 - 02:30 PM

When you drive outside of the track the camera continued to follow the track (Not outside the room),
Well i'am sure that was only me who had a bit to much fun.
  • 0

#8 toao

toao

    GMC Member

  • New Member
  • 157 posts

Posted 08 September 2009 - 04:03 PM

I cant play rar. files. Please make another link.
  • 0

#9 xot

xot

    media multimixer

  • Global Moderators
  • 4651 posts
  • Version:GM:Studio

Posted 08 September 2009 - 04:43 PM

can't be fixed. But hey, that's only charming right?

Heh, I like your attitude.

I cant play rar. files. Please make another link.

Toao is right to complain. You can post RARs but they MUST be accompanied by a ZIP or an uncompressed GM project file. That's one of the rules in here. Since I know you are active I'm not going to close this topic, but please update it with a new link as soon as possible.
  • 0

#10 TheSnidr

TheSnidr

    That guy

  • Global Moderators
  • 2440 posts
  • Version:GM:Studio

Posted 08 September 2009 - 05:07 PM

There, thanks for reminding me.
I use winrar, in which it's quicker to make a .rar file than a .zip file, so I keep forgetting not everyone have it (though, it's really easy to download)
Added a .gmk in the first post.

Edited by TheSnidr, 09 September 2009 - 12:52 PM.

  • 0

#11 mr glasses

mr glasses

    GMC Member

  • New Member
  • 425 posts

Posted 10 September 2009 - 10:12 PM

I have one questions, say you are drawing multiple sprites in the draw event of one objec, how did you deal with layering?
  • 0

#12 TheSnidr

TheSnidr

    That guy

  • Global Moderators
  • 2440 posts
  • Version:GM:Studio

Posted 10 September 2009 - 11:33 PM

If you want to draw multiple sprites with one object, you will have to draw them in the correct order. I encountered this problem when making the fps_model_draw script, finding out what walls to draw first.
There I used a list, added the depth of all the coordinates in a list, sorted the list, and drew them in the resulting order.
As you can see in the example, the walls are drawn in perfect order according to each other, but the model itself might sometimes overlap the flags in front of it sometimes. This is the biggest problem when drawing several things in one object: everything has the same depth.

Even though I'd prefer drawing one sprite per object, yes, it is possible to draw multiple sprites.
  • 0

#13 sabriath

sabriath

    12013

  • GMC Member
  • 3147 posts

Posted 10 September 2009 - 11:58 PM

Actually, all you'd have to do is mimic the depth of objects by putting the depth in an array along with the surface data (or whatever you were drawing). Then just run through the array drawing in order. If you needed to bump some of them in front or behind, you'd just swap them up/down the array. Depending on exactly what you were trying to accomplish, this could actually be faster than using the built-in depth on objects stuff (GM would run each objects code through a coder giving it frame space, loading/saving, etc. etc...where as if you do it all in 1 draw event, it saves some of that time). It might be faster, but a lot more hassle...you'll have to saccrifice something in your choice. :D
  • 0

#14 Zelda4evr

Zelda4evr

    GMC Member

  • GMC Member
  • 615 posts
  • Version:Unknown

Posted 29 September 2009 - 01:02 AM

i thought my fake 3d was good, i have fallen in love with this engine, and am now deving something. idk what yet but youll probably see it posted soon

ps: just so theres no confusion, if you test my engine(arrow keys: rotate camera, wasd: move, 8642:move camera, space:shoot)

Edited by Zelda4evr, 29 September 2009 - 01:02 AM.

  • 0

#15 D1g1talAli3n

D1g1talAli3n

    BoyGenius

  • New Member
  • 963 posts
  • Version:GM8

Posted 29 September 2009 - 01:06 AM

One thing that's promising with this engine is that you can use SURFACES! YAY! :whistle: that would make for more 'shaders' and special effects.

Edited by D1g1talAli3n, 29 September 2009 - 01:07 AM.

  • 0

#16 Zelda4evr

Zelda4evr

    GMC Member

  • GMC Member
  • 615 posts
  • Version:Unknown

Posted 29 September 2009 - 03:29 AM

question, with the mario kart example, how come when i change maps and set a path for it, the computer players follow the path but not on the track(did the same when i remade the path for the demo track)

edit: well i got bored and made the demo playable link
meh, someone can make something out of it, i won't

Edited by Zelda4evr, 29 September 2009 - 06:45 AM.

  • 0

#17 TheSnidr

TheSnidr

    That guy

  • Global Moderators
  • 2440 posts
  • Version:GM:Studio

Posted 29 September 2009 - 06:20 AM

Thanks!

I can't download any of your files, sorry. Your host is... bad. Use www.willhostforfood.com or www.host-a.net :whistle:
I believe your problem is that the computer players follow the path relative to their starting position. Fix it by changing the "absolute" argument in the creation event of the object from false to true.
  • 0

#18 Zelda4evr

Zelda4evr

    GMC Member

  • GMC Member
  • 615 posts
  • Version:Unknown

Posted 29 September 2009 - 06:39 AM

sorry about that, also you have it as false and it works, i have it at true to work, i was wondering how you did this.

you're right, my host is slow, new link:
link

Edited by Zelda4evr, 29 September 2009 - 06:41 AM.

  • 0

#19 TheSnidr

TheSnidr

    That guy

  • Global Moderators
  • 2440 posts
  • Version:GM:Studio

Posted 29 September 2009 - 01:48 PM

Nice!
But a few things you missed:
Instead of centering the camera at the player, you made it follow him. Good idea, but unnecessary, as that's what the "camera_offset" argument is for. Set it to -30 and center the camera at the player, and you'll get the same effect.
The background's dimensions should always be a power of two. The height of your map was 1100. Change it to 1024.
If you don't want the map to bug outside its canvas, make the edge around the background the same color. If you want an example of how it bugs, start your map2 and look to the left.

...also you have it as false and it works, i have it at true to work, i was wondering how you did this.

The computer was driving outside the track in my version too.
  • 0

#20 Zelda4evr

Zelda4evr

    GMC Member

  • GMC Member
  • 615 posts
  • Version:Unknown

Posted 29 September 2009 - 03:57 PM

in your version on my computer the racers would follow the track but relative to their position so they would go off a little but not as bad as usual.

thanks, i know all these things i just didn't have the time to change anything, but i was 10 seconds away from making a mario kart mmo and decided not to at the last second(i was wondering what camera_offset did thx)

Edited by Zelda4evr, 29 September 2009 - 03:58 PM.

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users