Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411490 Posts in 69371 Topics- by 58428 Members - Latest Member: shelton786

April 24, 2024, 05:19:39 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsCommunityTownhallForum IssuesArchived subforums (read only)TutorialsSurfaces in Game Maker Tutorial!
Pages: 1 [2] 3
Print
Author Topic: Surfaces in Game Maker Tutorial!  (Read 53370 times)
moi
Level 10
*****


DILF SANTA


View Profile WWW
« Reply #20 on: September 10, 2009, 08:55:05 AM »

you guys are crazy Droop
Logged

subsystems   subsystems   subsystems
___
Vice President of Marketing, Romeo Pie Software
Level 10
*


View Profile
« Reply #21 on: September 10, 2009, 08:08:42 PM »

Hello this is Pencerkoff

Like how MMF does collision with backdrop?

If I had tried that in MMF any unit I had interacting with a wall would be wiggling uncontrollably for like 3 seconds before shooting off into space.  No, I want something that works, thank you very much.

I've been toying with the RTS genre for a while now and just can't get the damn thing efficient.  I'm a far better physicist than programmer.

-PENCERKOFF



No, you sphincter.

I'm talking about how MMF handles collide with backdrop.  It makes a giant mask of all the backdrops that are marked as obstacle and checks against that huge mask, rather than thousands of small objects.
Logged
Pencerkoff
CCCP
Level 4
*


Hello I am Pencerkoff


View Profile
« Reply #22 on: September 11, 2009, 06:03:47 AM »

Hello this is Pencerkoff

you guys are crazy Droop

Yeah, well I've seen you naked, so lets not make an issue out of it.

I'm talking about how MMF handles collide with backdrop.  It makes a giant mask of all the backdrops that are marked as obstacle and checks against that huge mask, rather than thousands of small objects.

I suppose so.  Now that MMF has it it isn't cool anymore.

-PENCERKOFF

Logged

Carnivac
Level 0
***



View Profile
« Reply #23 on: September 12, 2009, 03:01:19 PM »

Huh, funny you say that, because surfaces work fine for me and I'm using a GeForce card (Go 7400).

Then it's probably not that particular model.  But all the error report emails I've had back have listed various Geforce cards.  I should really sort out all the model numbers that were mentioned.  It might also have to do with the way the surface is used in my games as opposed to how you might have used them.


I've been waiting for better a better room editor personally...

Can't believe I made such a mess of that sentence and then people quoted it.
Logged

Pencerkoff
CCCP
Level 4
*


Hello I am Pencerkoff


View Profile
« Reply #24 on: October 29, 2009, 04:50:00 AM »

Hello this is Pencerkoff

So I had this really slick idea for creating a flow field in GM and using that flow field to direct objects about a room.  I'd take a black surface and add color to it so it looks like an elevation map, where the lowest is black and the highest is white.  Any object would simply have to look at the few pixels around it to see if it was on a gradient, and then it would be compelled to move towards the lower part of the room, as indicated by the surface.  But the surface_getpixel command is really slow for upwards of 20 objects moving in the field, which is the only way I could figure to read color from the surface.

Why are surfaces so fast graphically and yet so slow when determining a single value on it?  I swear... programming is like black magic or something.

-PENCERKOFF
Logged

___
Vice President of Marketing, Romeo Pie Software
Level 10
*


View Profile
« Reply #25 on: October 31, 2009, 03:25:02 AM »

Pencerkoff, what if you built a huge 2d array based off this surface in the start of the room (would cause some massive load time, probably) and then use the array, instead of getpixel?
Logged
Pencerkoff
CCCP
Level 4
*


Hello I am Pencerkoff


View Profile
« Reply #26 on: October 31, 2009, 05:59:55 AM »

Hello this is Pencerkoff

Pencerkoff, what if you built a huge 2d array based off this surface in the start of the room (would cause some massive load time, probably) and then use the array, instead of getpixel?

I did try a grid that was basically like you say, but it's size made things far too slow.  My original idea involved a low-resolution grid, but all of my objects tended to wiggle.

In my most recent experiment with this, I used the surface_copy command to move a single pixel onto a 1 x 1 surface.  I then used the getpixel command and it takes the exact same amount of time.  I know I'm missing something here... how can it be hard to read a pixel from a surface that has one pixel in it?

What I'd like to do is manipulate the surface data directly, but there appears to be no way to access that sort of thing unless I write it as an image to a file.  This, if you hadn't guessed, is very slow.  Even if I could do that, though, I'd be soooo over my head.

-PENCERKOFF
Logged

JMickle
Level 10
*****



View Profile
« Reply #27 on: November 09, 2009, 01:32:22 PM »

hey can i be really awful and bump?  Giggle
Logged

Rostiger
Pixelhead
Level 5
******



View Profile WWW
« Reply #28 on: December 15, 2009, 02:48:36 AM »

Code:

surf_triangle = surface_create(100, 100);
surface_set_target(surf_triangle);

draw_primitive_begin(pr_linestrip);
draw_vertex(0, 100);
draw_vertex(100, 100);
draw_vertex(50, 0);
draw_vertex(0, 100);
draw_primitive_end();

surface_reset_target();


Small note: the y value in surface_create(100, 100); should be set to 101, otherwise the bottom line of the triangle won't be drawn for some reason.

Thanks for the tutorial though - it's good to finally get a grasp on surfaces. Now I'd really be itnerested in collision checking with drawn surfaces! Gentleman
Logged

Clemens Scott
Co-Founder & Artist of Broken Rules
Xishem
Level 0
**



View Profile WWW
« Reply #29 on: December 29, 2009, 06:58:25 PM »

Small note: the y value in surface_create(100, 100); should be set to 101, otherwise the bottom line of the triangle won't be drawn for some reason.
Yup. That's because surface_create() creates a surface with width and height of the parameters. Since it uses a 0-based index and it has a height of 100, it can only be drawn on from 0 to 99.

Very nice tutorial by the way, ChevyRay. I've still yet to master the use of surfaces  Droop
Logged
Ninomojo
Level 2
**



View Profile WWW
« Reply #30 on: February 04, 2010, 10:27:53 PM »

Quote
Why are surfaces so fast graphically and yet so slow when determining a single value on it?  I swear... programming is like black magic or something.

-PENCERKOFF

My guess is that surfaces are stored in your graphics card's VRAM, which is why they're fast to draw. Transfering data from video memory to RAM is slow even on modern computers, even with PCIexpress. So that's why you can't tweak surface data I think, and that's why it's very slow for the CPU to access it. It would have to transit from your card's VRAM to your computer RAM first.
Logged

True Gamer
TIGBaby
*


View Profile
« Reply #31 on: June 14, 2010, 08:58:41 AM »

I understand how to make the surfaces, but i want to make a health bar and Score krpt in a surface (the view in my game spins but i don't want the health to--can this be used to make the health stay in the same place?
Logged
MaloEspada
Guest
« Reply #32 on: June 22, 2010, 06:51:33 PM »

Ok, I've got a problem here; I'm trying to save a surface using the built-in saving from GM, and *sometimes*, when loading the game, it gives the error "trying to draw a non-existent surface".

I'm wondering, how can I save the surface and make sure it always loads it properly?
Logged
JMickle
Level 10
*****



View Profile
« Reply #33 on: June 23, 2010, 08:04:42 AM »

I assume what you are doing is writing the variable to the save file (the variable returned when you create the surface), then you just load that and draw it again? I'm not entirely sure how it works, but I would have thought that would have done.

Then again, surfaces are stored in graphics memory I believe, so that could be why it's not saving properly.
Logged

pgil
Guest
« Reply #34 on: June 23, 2010, 08:26:07 AM »

How are you saving it? Like JMickle said, surfaces are saved in video memory. If you want to keep it for a long period of time, you probably need to save it as a background or sprite. Look up background_create_from_surface()

Or are you trying to save it as an image file?
Logged
MaloEspada
Guest
« Reply #35 on: June 23, 2010, 09:18:07 AM »

I think I meant saving it as information; I tried something here but I can't guarantee it's working properly. The original bug only happened sometimes and I still have to find the error using the new method.

Basically I'm setting the object that draws the surface to be destroyed when saving the game, and when the game is loaded the object is created again. It seems to be working.. I'm not exactly saving the surface, just recreating it again.

Thanks for the sugestion, though!
Logged
man of doom
Level 2
**


It's not Tom and Jerry!


View Profile WWW
« Reply #36 on: October 14, 2010, 03:05:59 PM »

Cool tutorial, couldn't really get my head around surfaces until I went through this, now I feel pretty confident with them. Shame it isn't finished, I wanted to learn them to make a lighting system for my game, but after reading through and with a couple of hours of experimenting, lighting a go go!
In short- cheers!  Beer!
Logged

http://manofdoom.co.uk
Where all my stuff is at!
http://soundcloud.com/man-of-doom
Various musical stuff of mine
Ted
Level 4
****


View Profile WWW
« Reply #37 on: October 27, 2010, 04:52:46 PM »

Could someone point me to the source code of a game that uses surfaces?  I have a bunch of extremely noob questions that I think would be best answered by looking at some code.  Things like:

How to animate a sprite that uses surfaces.
Collisions with surfaces.
How I make game?
etc.

Embarrassed
Logged

iPhoenix
Level 0
*


View Profile
« Reply #38 on: November 01, 2010, 05:57:00 AM »

First post here, so hi :D

Very nice tutorial!
Sincew I've read that some guys are wondering about collisions or other uses for surfaces, here you go:

Collisions are easy. You draw on a surface, then use
Code:
sprite_add_from_surface ( surface_mask , your_surface , 0 , 0 , surface_width , surface_height )
mask_index = surface_mask
Now you apply that sprite to your wall-object, maybe set it to solid, and then you're set.

Also, if you understood surfaces, you clearly should continue with blendmodes - since surfaces combined with blendmodes are extremely powerful.
For instance you can create destructible terrain with just one object, or create multiple light-sources on one screen. That's also really nice for the performance.
So, go and check it out! :D
Logged
BoxedLunch
Guest
« Reply #39 on: December 04, 2010, 03:58:17 PM »

i'm having trouble clearing the screen during each end step event. i'm trying to have an exclamation point pop-up above a character as an action-alert style thing. but when i try to do the surface clear thing at the end of the step, the exclamation point doesn't show up, and when i don't do the clear thing, i get this.

i have the surface drawing in the step event and the clearing in the end-step event,  if that helps.

what should i do?
Logged
Pages: 1 [2] 3
Print
Jump to:  

Theme orange-lt created by panic