chronic4

Would you like to react to this message? Create an account in a few clicks or log in to continue.

chronic 4 gamemaker team


3 posters

    Basic Engine.

    avatar
    Flyboymonkey
    Admin


    Posts : 93
    Join date : 2010-03-29
    Age : 42

    Basic Engine. Empty Basic Engine.

    Post  Flyboymonkey Wed Mar 31, 2010 3:36 pm

    I'm going to start making the basic engine (movement shooting etc)


    Tell me everything you want added. If it isnt basic (physics, Lighting, etc) send me a link to an example off the open source forum of the GMC
    Jimmynator
    Jimmynator
    Admin


    Posts : 71
    Join date : 2010-03-30
    Age : 28
    Location : Spain

    Basic Engine. Empty Re: Basic Engine.

    Post  Jimmynator Wed Mar 31, 2010 4:15 pm

    codyyo2
    codyyo2
    Admin


    Posts : 57
    Join date : 2010-03-29

    Basic Engine. Empty Re: Basic Engine.

    Post  codyyo2 Wed Mar 31, 2010 9:14 pm

    We should try to have vehicles, it'll make it funner.
    avatar
    Flyboymonkey
    Admin


    Posts : 93
    Join date : 2010-03-29
    Age : 42

    Basic Engine. Empty Re: Basic Engine.

    Post  Flyboymonkey Wed Mar 31, 2010 10:21 pm

    Easy to make Smile W3D engine can make things look like were tying to spitshine sh*t alot of times.. if it looks good when we get sprites in then ye Smile

    Heres a tutorial for you guys to understand MP grids.

    This will improve your zombie game alot btw Mr. jimmy
    Resources

    * 3 sprites - mouse_spr, cheese_spr, wall_spr
    * Path0 - a default path with no points defined.
    * Objects - mouse_obj, cheese_obj, wall_obj, grid_obj
    * Room - Room needs to contain all 4 objects.

    Sprites:
    For the mouse_spr you may want to get a pretty image of a mouse or use your imagination. The same is true for the cheese_spr.

    The wall_spr I would like to do a little more with. I used an image that I colored pure black for image0 (except the lowest left alpha channel pixel which I made white), and a pure white image for image1. I made the wall_spr transparent. This will give me a blinking wall which will allow me to see the results of the mp_grid_draw() function. If you are wanting the wall to be all pretty and stuff then take an image of the wall and make the left bottom most pixel white and then create a second image that is pure white and make the wall_spr transparent.

    Path:
    Now we create the path. We leave the name as path0. We will not define any points for the path to follow. This path will be used later in the mp_grid_path function which will define the points needed to get from point A(starting point of mouse) to point B(the cheese).

    Objects:
    The easiest object will be the mouse_obj. For this we will simply create it, leaving the default values and assigning an image to it.
    The next object will be the wall. Since I want the wall to blink, so that I can see the mp_grid_draw function, I will create the object, assign the wall_spr, and then create a Create Event with a Change Sprite action. I will set the sprite to the wall_spr and the speed to 0.01. All this does is makes the wall blink at a slower pace so that it isn't too annoying.
    The primary focus is the grid_obj which will handle all our path finding.

    grid_obj:
    Here is the meat and potatoes of our program. It will handle all our path finding.
    Create Event
    This will create the grid. I am creating a grid in the upper left corner of the room. It will cover 320x320 pixels. It will have 10x10 cells. Each cell will be 32x32 pixels. This is important to note since I will want to have my elements in the grid area for them to work. I will store the index of the grid in the variable mygrid.
    The create event will then mark the cells with the object being forbidden.

    mygrid = mp_grid_create(0,0,10,10,32,32);//create grid
    mp_grid_add_instances(mygrid,object1,true);//mark cells with object as being forbidden


    Keyboard Event for <Space> key
    When the space key is hit the program will find a path for the mouse_obj to follow to the cheese. If there is no path that is found then the mouse will not move from it's starting point. If there are points that are defined for path0 and there is no path that is found using mp_grid_path then the original path will be used.
    The following code finds the path to the cheese:

    mypath = mp_grid_path(mygrid,path0,16,16,208,16,false);


    Set Path Action
    I will then use the set path action to assign a path to the mouse_obj which the mouse_obj will then follow.

    * Applies to mouse_obj
    * path: path0
    * speed: 3
    * at end: stop
    * relative: relative

    Draw Event
    I will then use the mp_grid_draw function to see a visual representation of the grid. It will have a green cell for cells that are allowed to be traversed and a red cell for cells forbidden to be traversed. It is recommended in the manual to only use this function for debugging purposes since it is slow. It is used here to be able get a visual representation of the grid.

    mp_grid_draw(mygrid);

    Other Event: Game End
    To be thorough we will create an event to destroy the grid.

    mp_grid_destroy(mygrid);//use this to free up memory by destroying grid when not in use

    Room
    Last but not least is to place the objects into the room. We will want to make sure that we stay within the first 320x320 grid area that we defined. We can either define a larger grid area or move the grid if we don't want it to cover the region that I specified. Place the walls as you see fit to make a maze. Either leave a valid path or block the mouse in so there is no path to follow to see what happens. Play around with moving the walls around to see that it really works.

    Program Execution
    Run the program and hit the space key to see it work.
    avatar
    Flyboymonkey
    Admin


    Posts : 93
    Join date : 2010-03-29
    Age : 42

    Basic Engine. Empty Re: Basic Engine.

    Post  Flyboymonkey Thu Apr 01, 2010 4:17 am

    THERE ARE TWO EXAMPLES!

    Hit the space bar to switch from 1 to 2 .. Its 4:00 am and I have work tomorrow so I didn't add collisions to EG 2... Note the smoothness of EG 1 Smile

    http://www.mediafire.com/?yydcmwz2jd4
    Jimmynator
    Jimmynator
    Admin


    Posts : 71
    Join date : 2010-03-30
    Age : 28
    Location : Spain

    Basic Engine. Empty Re: Basic Engine.

    Post  Jimmynator Thu Apr 01, 2010 5:36 am

    Thanks, but it creates a lot of lag. Maybe in another game.
    avatar
    Flyboymonkey
    Admin


    Posts : 93
    Join date : 2010-03-29
    Age : 42

    Basic Engine. Empty Re: Basic Engine.

    Post  Flyboymonkey Thu Apr 01, 2010 4:42 pm

    Did you try my engine? example 2 wont work.. to.. boring. and if you are talking of MP_GRID functions.. the draw_grid thing lags like crazy.. if you dont draw it your fine
    Jimmynator
    Jimmynator
    Admin


    Posts : 71
    Join date : 2010-03-30
    Age : 28
    Location : Spain

    Basic Engine. Empty Re: Basic Engine.

    Post  Jimmynator Thu Apr 01, 2010 5:36 pm

    I didn't use the draw_grid function. I think it creates lag because of the high number of zombies and the room dimensions.

    Sponsored content


    Basic Engine. Empty Re: Basic Engine.

    Post  Sponsored content


      Current date/time is Sun May 19, 2024 11:42 am