Official Fangame Help Topic

Oh. …Interesting. I didn’t even know that drag 'n drop existed :stuck_out_tongue:

Maybe stick it in the step event so it’s guaranteed to wrap. I don’t know why it wouldn’t work otherwise. It could be that the room is larger than the view you have it set to, but I tried going right for a long time and never got to the left, so I doubt that.

I tried the “LOLSYNTAXERROR” thing and the game still ran perfectly. The code is in my HUD’s Draw event, and the HUD is in the room (the rest of the HUD works fine, by the way)

Perhaps I should put the code somewhere else?

I guess. Try making a new object, adding that code into the draw event, and placing it in the room, and see what happens. Did you accidentally comment out the whole thing? Are you sure you’re placing it in the “execute a piece of code” icon? Once we figure this out there won’t be much left to do other than misc. error fixing.

I tried making a new object, yet nothing would show up. (Yes, I placed it in the room, <_<)

Perhaps it’s some really silly error. I’ll post my code again.

Init_Area_1 Script:

[code]if (global.area != 1) // * = area #
{
global.mapimage = Map1; // * = map sprite
global.area_width = 6;
global.area_height = 6;

/*
You do have global variables for the items, right?
So that if you collect an item, leave the room, and come back…
…It’s not there? If so, here’s where you look at all those
to see if they’re collected or not, and set the correct symbol
on the map
*/

///So you’d clear out all junk from previous areas on the map
for (i = 0; i < 6; i += 1)
{
for (j = 0; j < 6; j += 1)
{
  global.area_symbol[i,j] = 0;
  global.area_symbol[5,5] = 2;
  global.area_symbol[0,0] = 2; //temporary, for testing
}
}

// Then here’s where you’d fill in the symbols over the default set above
if (global.area1_missile0[0] == true) global.area_symbol[5,5] = 1;
else global.area_symbol[5,5] = 2;

if (global.area1_missile1[1] == true) global.area_symbol[0,0] = 1;
else global.area_symbol[5,5] = 2;
}[/code]

Room Creation Code:

[code]global.room_x = 0;
global.room_y = 0;

//global.area1_explored[i,j] = true

init_area_1();

//Item Collection Code
m_e.collection = “global.area1_missile1 = true”;

[/code]

Execute Code In Draw Event of obj_Map: (New object, instead of HUD object)

[code]/////MAP CODE/////

SamusMapx = floor(Samus.x/320)+global.room_x;
SamusMapy = floor(Samus.y/240)+global.room_y;
global.area1_explored[SamusMapx,SamusMapy] = true;

//Draw Black Box Code :open_mouth:
draw_set_color(c_black);
draw_rectangle(view_xview[view_current]+275,view_yview[view_current]+2,view_xview[view_current]+299,view_yview[view_current]+26,false);
draw_set_color(c_white);
draw_set_alpha(1);
//End of Draw Black Box Code

//draw_sprite(spr_mapdata,0,view_xview[view_current]+275,view_yview[view_current]+2);

for (i = samusMapx-1; i <= samusMapx+1; i += 1)
{
for (j = samusMapy-1; j <= samusMapy+1; j += 1)
{

 if (i > 0 && j > 0 && i < global.area_width && j < global.area_height)
 {
     if (global.area1_explored[i,j] == true)
     
     {
     draw_sprite_part(global.mapimage,0,1+i8,1+j8,8,8,view_xview[view_current]+276+(i+1-SamusMapx)*8,view_yview[view_current]+3+(j+1-SamusMapx)*8);
     if (global.area_symbol[i,j] == 1) draw_sprite(spr_itemdot,0,view_xview[view_current]+276+(i+1-SamusMapx)*8, view_yview[view_current]+3+(j+1-SamusMapx)*8);
     else if (global.area_symbol[i,j] == 2) draw_sprite(spr_itemcir,0,view_xview[view_current]+276+(i+1-SamusMapx)*8, view_yview[view_current]+3+(j+1-SamusMapx)*8);    
     }
 }
}
}
[/code]

obj_Samus1 Collision with MiTank (Missile Expansion)

global.maxmissiles+=5; global.missiles+=5; global.area1_missile0[0] = true; ///execute_string(mcollection);

:angry:

Alright.

I test-ran the code myself in a new program, and… I got the black box in the corner. <_<

The map itself was moving around randomly and crashing occasionally, but I fixed that (several tyupos, a logic error, several more tuypso, etc.) and now it’s working just fine in my little program. I added the symbols in and they work, too.

So, I filled in a bunch of “EDIT SPOT” comments to point out places you can edit to change items or areas and rooms. Don’t edit anything else or it may mess up the system. You can see that I already followed a few of the edit spots and added some stuff in. Some of it is because I was working with one room the size of the entire area. Just pay attention to what it says at each EDIT SPOT and hopefully you’ll be able to figure out what to do for the rooms in your game.

The new code:

init_area_1():

[code]// EDIT NOTE: If you want to have different areas
// copy and paste the code into a new init_area_*() script
// and change the EDIT SPOTs to match the new area

// EDIT SPOT: Change the number below to the area number of the script
if (global.area != 1) // * = area #
{
// EDIT SPOT: Same here.
global.area = 1;

// EDIT SPOT: Change the following 3 values for other areas
global.mapimage = Map1; // * = sprite of the map of the area
global.area_width = 6; // * = area width in squares
global.area_height = 6; // * = area height in squares

// This clears out symbols so there are none on the map
// (there will likely be symbols leftover from other areas
// so it’s a good idea to clear the area first)
for (i = 0; i < 6; i += 1)
{
for (j = 0; j < 6; j += 1)
{
 global.area_symbol[i,j] = 0;
}
}

// EDIT SPOT:
// Here’s where you fill in the symbols over the default set above
// To add item symbols, add these two lines of code:
// if (global.ITEM_ID == true) global.area_symbol[ITEM_X,ITEM_Y] = 1;
// else global.area_symbol[ITEM_X,ITEM_Y] = 2;
// ITEM_ID is the same value given to the item from
// within the room’s creation code that the item is in.
// If they’re not the same, it won’t work right.
// ITEM_X and ITEM_Y are the coordinates of the square containing the item
// Other symbols are easy to figure out how to add

// 1 = collected item, 2 = not collected item
// These are ALL the symbols in the area:

if (global.area1_missile0 == true) global.area_symbol[5,5] = 1;
else global.area_symbol[5,5] = 2;

if (global.area1_missile1 == true) global.area_symbol[5,2] = 1;
else global.area_symbol[5,2] = 2;

}[/code]

HUD draw event code:

[code]/////MAP CODE/////

SamusMapx = floor(obj_Samus1.x/320)+global.room_x;
SamusMapy = floor(obj_Samus1.y/240)+global.room_y;
if (SamusMapx >= 0 && SamusMapy >= 0) global.area1_explored[SamusMapx,SamusMapy] = true;

//Draw Black Box Code :open_mouth:
draw_set_color(c_black);
draw_rectangle(view_xview[view_current]+275,view_yview[view_current]+2,view_xview[view_current]+300,view_yview[view_current]+27,false);
draw_set_color(c_white);
//End of Draw Black Box Code

//draw_sprite(spr_mapdata,0,view_xview[view_current]+275,view_yview[view_current]+2);

for (i = SamusMapx-1; i <= SamusMapx+1; i += 1)
{
for (j = SamusMapy-1; j <= SamusMapy+1; j += 1)
{

if (i >= 0 && j >= 0 && i < global.area_width && j < global.area_height)
{
   if (global.area1_explored[i,j] == true)
   
   {
   draw_sprite_part(global.mapimage,0,1+i8,1+j8,8,8,view_xview[view_current]+276+(i+1-SamusMapx)*8,view_yview[view_current]+3+(j+1-SamusMapy)*8);

   if (global.area_symbol[i,j] == 1) draw_sprite(spr_itemdot,0,view_xview[view_current]+276+(i+1-SamusMapx)*8, view_yview[view_current]+3+(j+1-SamusMapy)*8);
   else if (global.area_symbol[i,j] == 2) draw_sprite(spr_itemcir,0,view_xview[view_current]+276+(i+1-SamusMapx)*8, view_yview[view_current]+3+(j+1-SamusMapy)*8);    

// EDIT SPOT: Here’s where you draw symbols on the map
// So, if you add a new symbol, add a new line above these comments
// Fill in “SYMBOLNUMBER” and “SYMBOLSPRITE” appropriately from the below format
// Change nothing else. Here’s the format for adding a symbol:
// else if (global.area_symbol[i,j] == SYMBOLNUMBER) draw_sprite(SYMBOLSPRITE,0,view_xview[view_current]+276+(i+1-SamusMapx)*8, view_yview[view_current]+3+(j+1-SamusMapy)*8);    

   }
}
}
}

// EDIT SPOT: If you’re going to add a flashing Samus icon or
// something over the center of the mini-map, here is where you would add it.[/code]

obj_Samus1 collision with missile expansion:

[code]// This is the Samus’s collision with the missile expansion.

with (other)
{

global.maxmissiles+=5;
global.missiles+=5;

execute_string(collection);

global.area_symbol[floor(x/320)+global.room_x,
                   floor(y/240)+global.room_y] = 1;

instance_destroy();
}[/code]

Room creation code:

[code]// EDIT NOTE: Copy and paste all of this code in for each room in your game
// that uses the mini-map, then change the coordinates and other EDIT SPOTs
// to fit the room

// EDIT SPOT: Change the coordinates of the room for each room
// It’s the coordinates of the upper-left square of the room, remember
// Otherwise it’ll be messed up
// The coordinates:
global.room_x = 0;
global.room_y = 0;

// global.area1_explored[i,j] = true

// EDIT SPOT: This function should call the area that the room is in
// If the room isn’t in the area number it’s calling right now
// Change it to make it so or the minimap won’t work correctly.
init_area_1();

// Item Collection Code
// EDIT SPOT: For each item in this particular room…
// Add these two lines of code:
// newexpansion = instance_create(ITEM_X,ITEM_Y,ITEM_OBJECTNAME);
// newexpansion.collection = “global.ITEM_ID = true;”;
// Change ITEM_X and ITEM_Y to the coordinates of the
// item, in pixels, in the room
// ITEM_OBJECTNAME is the name of the object. m_e for missile expansions,
// for example
// ITEM_ID is what you’d call the item in the area. Like, “area1_missile1”
// It should be the same as what the end of init_area_1 uses
// to check if it has been collected or not. That’s the only reason
// it’s used.
// This code adds the instance, so don’t place the objects into the room
// with GM’s room editor or there will be two. Remember the location of
// those and add them using the two lines in here.
// Anywhere, here’s where you add those lines of code:

newexpansion = instance_create(160+3205,120+2402,m_e);
newexpansion.collection = “global.area1_missile0 = true”;

newexpansion = instance_create(160+3205,120+2405,m_e);
newexpansion.collection = “global.area1_missile1 = true”;

// If there aren’t any items in the room, don’t bother with the code.[/code]

AND
Here is my program:
http://download.yousendit.com/C40D9F9F1E240CE7

I was lazy with the graphics, and the entire area is one huge room. Zoom around the area, collect the black circles which are apparently missile expansions and watch as the symbol on the map changes.

Maybe it’ll help you figure out what’s wrong with how you’re adding the code to your own game…

Or if not, it at least shows you that it works really nicely. If you need a full map drawn on the pause menu, just ask. (It’s set up to easily support that)

I tried it, followed exactly what you said, and it still didn’t show up. So, I deleted everything off the room except the Map/HUD controllers and Samus, yet it still didn’t work. >__<

I’ll keep trying until I get it, :astonished:!

As for the map on the pause menu, how about when you double click the map/press “M” it appears?

Wouldn’t be hard to click the map; I could just make an invisible object at the Black box’s coordinates, and when you click the invisible object, it’ll take you to the room that has the map on it.

Or instead of using up tons of memory and more CPU to add a new object, I’ll just check if the mouse coordinates are in that area when it’s clicked. >_>

Do you have a pause menu already? If not I’ll work out some way to pause it.

No I don’t have a pause screen yet.

how do i create two health bars? one for each player.

In the Draw Event:

draw_healthbar(x1,y1,x2,y2,amount,back color,min % color (e.g. c_red),max % color (e.g. c_green),direction,showback (1=yes, 0=no),showborder (1=yes, 0=no))

so it may look like this in the real code:
draw_healthbar(100,48,200,64,player1_hp,c_black,c_red,c_green,0,1,1)
draw_healthbar(400,48,500,64,player2_hp,c_black,c_red,c_green,0,1,1)

ok i have a bad problem! whenever samus walks to the right, she floats about a centimeter of the ground.then when you turn left she walks back on the ground, but then you can’t turn right again! also why does samus jump straight to morphball when you push down? then while in morphball you can push up to crouch and stand again as normal. if you can’t answer my questions by playing the demo:

http://www.megaupload.com/?d=5MJNANCR

then maybe i could send you the engine for inspection.

i need some help with my game.
i need richter to be able to walk faster if i press a direction key twice, and be able to jump across about 5 squares before he lands, without falling through the floor.
this is what i have so far: http://files.filefront.com/Castlevania+ric…;/fileinfo.html
can anyone help?

for my metroid fangame how do i make it so you can shoot then charge and also how do i make the little spark things fly out when charging :confused:

Edit: i want to hold the shoot button after firing to charge a stronger bullet :confused:

Don’t double post. Review the forum rules.

For the charge shot, I would do something like this pseudo-code for your character object:

Object creation:
create a variable “chargeTimer”, set it to 0.
Each step:
if (fire key is pressed) fire a normal shot.
if (fire key is being held) add 1 to chargeTimer.
otherwise
{
if (chargeTimer is greater than, say, 45) fire a charged shot.
set chargeTimer back to 0.
}

To add graphics or sound to it, the main part is just determining whether a shot is being charged or not. With the above code, that would be when chargeTimer is greater than some low value like 10.

You’ll probably want to look up more info about the language you’re working with to get the above pseudo-code translated. If it’s Game Maker, then the help library is what you’ll use.

could you right it down in code for me so i can copy and paste im not really a programer :smiley:

What language?
I could do it in GM, but you want it in wut? ASM?

aperson, you seem like a nice guy, but you also seem rather young and inexperienced.

A word of advice: try and choose an area to get good at, instead of trying to make a fangame all by yourself. You’ve already asked for our sprites for your fangame (I think that’s what it was, at least), and now you’ve admitted you can’t really program.
I’m not saying you’re incapable entirely, but you ought to learn a trade before you try and demonstrate your skill…
Browse the internet for info on programming, get some BASIC language (really good way to start, though a lot of people jump right into the more complicated languages), or, if you want to become a spriter, just post sprites you’ve made here on our forums.

I’ve been trying to learn different things for years now, and I still don’t think I’m competent enough for a fangame, and I think hardly ANYONE is good enough to make a fangame all by themselves. You’re reaching a bit too high.

Yes, but copy and paste is the lazy way out. It would be faster to look up some things about the language you’re working in so you can at least use that knowledge to create the code on your own. :stuck_out_tongue:

If you’re using Game Maker, anyway (which I assume you are), the pseudo-code translates into GML line for line. Obviously you can’t translate it without knowing some specific functions and syntaxes of the language, so you’ll want to take a trip through the GML section of Game Maker’s help file. It shouldn’t take very long to find the functions you need.

ok im 10 and i want to be a spriter :smiley:

what sprites havnt you made yet because im willing to try