Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - Atelier

#481
Code: AGS

DrawingSurface*surface;
DynamicSprite*sprite, overlay, final;
//sprite.Graphic is the background sprite with all the units drawn on top

function repeatedly_execute() 
{
     if (player.Room == 1) {
          
     int u = 1;
     
     while (u <= total*2)
     {
         
         if (((unit[u].x-13 <= mouse.x) && (mouse.x <= unit[u].x+13)) && ((unit[u].y-13 <= mouse.y) && (mouse.y <= unit[u].y+13))) {

               overlay = DynamicSprite.Create(800, 600, true);
               final = DynamicSprite.CreateFromExistingSprite(sprite.Graphic);

               surface = overlay.GetDrawingSurface();
               int slot;
               if (unit[u].type == eUnionInfantry) slot = 30;
               else if (unit[u].type == eUnionCavalry) slot = 29;
               else if (unit[u].type == eUnionArtillery) slot = 28;
               else if (unit[u].type == eConfInfantry) slot = 25;
               else if (unit[u].type == eConfCavalry) slot = 24;
               else if (unit[u].type == eConfArtillery) slot = 8;
                    
               if (unit[u].plyr) surface.DrawingColor = 10; else surface.DrawingColor = 12;
               int first, second; // make sure the smallest circle is always drawn last
               if (unit[u].mvm < unit[u].rng) { first = unit[u].rng; second = unit[u].mvm; }
               else if (unit[u].rng < unit[u].mvm) { first = unit[u].mvm; second = unit[u].rng; }
               
               surface.DrawCircle(unit[u].x, unit[u].y, first);
               if (unit[u].plyr) surface.DrawingColor = 2; else surface.DrawingColor = 4;
               surface.DrawCircle(unit[u].x, unit[u].y, second);
               surface.DrawImage(unit[u].x-1-(Game.SpriteWidth[slot]/2), unit[u].y-1-(Game.SpriteHeight[slot]/2), slot);
               
               surface = final.GetDrawingSurface();
               surface.DrawImage(0, 0, overlay.Graphic, 60);
               
               surface.Release();               
               gBattlefield.BackgroundGraphic = final.Graphic;
               
               if (unit[u].type == eUnionInfantry) infoType.Text = "Unionist Infantry";
               else if (unit[u].type == eUnionCavalry) infoType.Text = "Unionist Cavalry";
               else if (unit[u].type == eUnionArtillery) infoType.Text = "Unionist Artillery";
               else if (unit[u].type == eConfInfantry) infoType.Text = "Confederate Infantry";
               else if (unit[u].type == eConfCavalry) infoType.Text = "Confederate Cavalry";
               else if (unit[u].type == eConfArtillery) infoType.Text = "Confederate Artillery";
               
               infoWeapon.Text = unit[u].weapon;
               infoStats.Text = String.Format("Dam: %d Mvm: %d Rng: %d Def: %d", unit[u].dam, unit[u].mvm, unit[u].rng, unit[u].def);
               
               if (unit[u].plyr) infoType.TextColor = 10;
               else infoType.TextColor = 12;
               
               int width = GetTextWidth(infoType.Text, infoType.Font);
               if (width < GetTextWidth(infoWeapon.Text, infoWeapon.Font)) width = GetTextWidth(infoWeapon.Text, infoWeapon.Font);
               if (width < GetTextWidth(infoStats.Text, infoStats.Font)) width = GetTextWidth(infoStats.Text, infoStats.Font);
               
               infoType.Width = width+12; infoWeapon.Width = width+12;
               infoStats.Width = width+12; gInfo.Width = width+12;
          
               int x = mouse.x+2, y = mouse.y+2;
               if (800-gInfo.Width < x) x = 800-gInfo.Width-5;
               if (600-gInfo.Height < y) y = 600-gInfo.Height-5;
               gInfo.SetPosition(x, y);
               
               gInfo.Visible = true;
          }

          else // mouse not over a unit, so change to background sprite
          {
               gInfo.Visible = false;
               gBattlefield.BackgroundGraphic = sprite.Graphic;
          }
          

     u++;
     
     }
     
     
  }
}


Sorry, here's the full code (copied and pasted this time, not translated manually to avoid all my typos ;))

Like I say, the GUI only shows up and circles are only drawn if the mouse is over the last unit in the array, which is always an enemy unit.
#482
Does anybody know why the while loop isn't functioning properly? It's really frustrating :-\
#483
Thanks Khris, it works now.

But something strange happens - when the mouse hovers over units a GUI should appear... this only happens to the enemy units though. Basically the player selects how many of each unit they want, this becomes int total, and the same amount of [randomised] units becomes AI. So total*2 should equal the last used slot in the unit array. But for some reason the while loop only checks the last half (ok, it's probably not a fault in the while loop, but it doesn't make sense, because I check the value of total*2 just before and there's no reason why it shouldn't cycle through just the last half).

Code: AGS

function room_RepExec()
{
     int u = 1;

     while (u <= total*2)
     {
          //check coords
     
          u++;
     }

}


Is it something wrong with the loop, or is the problem how the units are defined in the first place?

Edit: It's worth mentioning that

Code: AGS

while (u <= total)


does show the first half of total*2, because naturally the loop doesn't extend to the other half of the units (enemy units). Only when total is multiplied by 2 does the first half of the units not show on mouseover...

Edit 2:

Ok, another problem...

Doing

Code: AGS

if (unit[u].x-13 <= mouse.x && mouse.x <= unit[u].x+13) {
if (unit[u].y-13 <= mouse.y && mouse.y <= unit[u].y+13) {
 //
}}


causes it to check that the mouse is within the x boundary properly, but if you move the mouse up and down within that, the GUI remains until you hover over another unit, even if you are way more than 13 pixels vertically from the first one. This only happens when you don't multiply total by 2 for the condition of the while loop. If you do, it works fine, but only on the enemy units (last half), so the first problem applies again. I did this:

Code: AGS

if ((unit[u].x-13 <= mouse.x && mouse.x <= unit[u].x+13) && (unit[u].y-13 <= mouse.x && mouse.x <= unit[u].x+13))


and this works as intended, but only when you hover over the last unit to be defined!

I'm thinking of changing it to tile-based to avoid these problems, even though I really wanted an "open" movement system and I present the game in four days...
#484
Hi guys, this is pretty basic but my brain is frazzled. I'm checking whether the mouse is over a certain coordinate.

The units in my game have an x and y coordinate and the sprite is 27x27 with the coordinate in the middle (so the sprite is drawn at x-13, y-13).

Code: AGS

function room_RepExec()
{
     while (u <= total*2) // total allied units, x2 for enemy units
     {
          if ((unit[u].x-13) < mouse.x < (unit[u].x+13)) {
          if ((unit[u].y-13) < mouse.y < (unit[u].y+13)) {

               // do stuff

          } }

     u++;

     if (total*2 < u) u = 1;
     }
}


I think the co-ord checking bit would work in theory?

But obviously, the game just crashes because I cycle through all the units constantly, but I can't check the coordinates if I don't do that, and noloopcheck locks the game up. How else could I do it?

Cheers
Atelier
#485
I might enter this one myself, spare-time permitting. I know that would be setting my own theme but I genuinely thought of it on the fly and in retrospect think it's a really fun theme. Does anybody mind?
#486
How mooving :~( Here you go Ponch, heifer cookie as your prize!

#487
In that case, Ponch WINS!


Woo yeah you go girl you are won!
#488
Topic: 'Fairy Tale'

The theme for July is really simple: create a game based on an existing fairy tale. If you wish, you can put your own spin on a traditional plot, but the fairy tale must remain recognizable. Or, you could mash different fairy tales together.

(A lot of) Ideas to help you:

http://en.wikipedia.org/wiki/List_of_fairy_tales



Ending 6/8/2012




What is MAGS?

MAGS is a monthly competition for all amateur adventure game makers. The idea is to create a game in under a month, following the rules set by the previous winner. It aims to help you work to a deadline, improve your skills, or provide a kick-start into making adventure games. Regardless of skill, MAGS is for everyone. Voting is based on "favorite" games, and not the most artistic, or the best coded. If you have bad art skills, use it as a chance to do some graphic work. If you're sub-standard at coding, use it as a chance to give scripting a go. Ultimately, people will vote for the most enjoyable entry.

You may get help for the competition, although you must end up doing something yourself. You should however be warned that it proves difficult to organize a big team within thirty days. You are not allowed to use material already created before this competition. Your game must be completely new! Music and sound is an exception; you can use free material that is available to the public, if you wish. Modules and templates are also allowed. Please do not enter the competition with a rushed entry (a game created last minute). Sure, you can make a game and rush it - but don't do this just to win by default.

Entering MAGS is simple. First, conceptualise your game following the month's criteria (see top). Second, create your game fueled only by coffee. Third, finally, and most importantly, post your game here, including:

âœ" A working download link.
âœ" The title of your game.
âœ" A suitable screenshot.

At the end of the month, the all-important voting will begin! This period usually lasts fifteen days. Should you win, along with announcing the next month's rules, your name and game will be immortalised in the MAGS Archive. Yet hopefully, at the end of the month, the accomplishment of finishing a game will be your greatest prize. For more information please visit the Official MAGS website.
#489
Damn I did it again, even though I said I wouldn't :( I'm finding less time for MAGS... I hope you all believe it's busyness not laziness.

So, I think we should stick to the original deadline, for a good reason which will be revealed later (when the time is right)!

Ghost, any report on whether you made it or not? I'll leave this topic open until then.
#490
Site & Forum Reports / Re: Forum upgrade
Thu 05/07/2012 18:23:05
Not sure where to put this. I think it would make more sense to have the "I've worked on the following games" above the google map, seeing as people are more likely to look at a profile for their games. Plus it is sort of annoying scrolling down. Would a switcheroo be possible and am I the only one who thinks this?
#491
Sorry, I'll explain more, I didn't want to use characters because there will likely be about 20 different units on the screen. It's a small simulator to reenact tactics of the American Civil War for a History project. By internal boundaries, I meant that the battlefield is surrounded by an outer boundary, but within that outer boundary could be small objects which are also impassible, like a rock, but are surrounded by walkable areas.

Quote from: Khris on Mon 02/07/2012 19:55:54
Quote from: Atelier on Mon 02/07/2012 19:05:10I can only think that you'd need to define all the coordinates which are impassable and stop the entity from ever going on them.
You can do the same thing as AGS: use a sprite and GetPixel.

Ah ok. So, I could draw the battlefield how it will appear in-game, then create an overlay where I draw the impassable regions in one colour and leave the rest transparent (or vice versa)? Then I just check the overlay sprite using GetPixel to see if the region you direct a unit to is walkable (has no pixels)?
#492
What would be the best way to mimic a walkable area but for things that are not characters? For example, you have a car, boat or person (defined by a struct/array) which has an x and y value on the map, but cannot go beyond a boundary enclosing the map (impassable area). It would be simpler if this boundary was a line, but how about a curved/irregular one? I can only think that you'd need to define all the coordinates which are impassable and stop the entity from ever going on them.

Also, how about restricted areas within the outer boundary, like a rock or something? Would this mean I'd need to write a pathfinding algorithm? Internal boundaries aren't really important though for what I need. Here's a really bad diagram to illustrate, with grey areas being impassable:



Thanks.
#493
Quote from: Calin Leafshade on Fri 04/05/2012 11:02:45
why we segregate men from women (toilets and locker rooms and stuff)

I know this thread is old but I randomly thought of some reasons. The segregation can be explained by the cultural context of the first public toilet opened in London, 1852. The toilets were designated male and female to provide privacy for both (Victorians were insanely prude) and more practically to reduce the risk of sexual assault. In the 1830s people were still being executed for homosexuality, so the only distinction was somebody's biological sex because that's all society knew. I guess this is just something that has remained and been applied to most other areas (swimming pools etc) because it set the norm for dividing public places into male and female, and it has worked very efficiently since then so why change it by adding all these extra doors?

Arguably, if the entire public toilet system was to be redesigned (as if we forgot they ever existed) it might be that public toilets are divided by gender identity rather than biological gender. That's major theorising on my part but given the extremely more liberal attitudes and political correctness since 1852, it's definitely a possibility. Also, the number of public unisex toilets now are increasing and some councils have created gender-neutral toilets (there's one in my area). Essentially, the answer is that attitudes have evolved, but the basic system of discriminating between members of the public has remained the same because it is still the most logical approach. If LGBT were not a small minority, I would agree that the system wouldn't make sense. But there is no point creating separate rooms for lesbians, transexuals, gays, bisexuals, and asexuals if the vast majority of the public are heterosexual and identify their gender with their biological sex.
#494
Thanks Ponch :) Anybody else entering? There's still about two weeks left.
#495
Beginners' Technical Questions / Re: code
Thu 07/06/2012 21:02:52
#496
Topic: 'In Soviet Russia...'

This month's guidelines were set by Baron et al.:

Just as in the russian reversal jokes originated by Yakov Smirnoff, you need to take something that normally happens in an adventure game and make it function in reverse.  This can be taken to absurd levels, or just be a reversal of one element that is commonplace in the genre.  The game need not actually take place in Soviet Russia!

Ideas to help you:

• Instead of taking inventory items, inventory item takes YOU!
• The villain is actually a cool and downright decent fellow, while your hero is a loathsome and repelling character.
• Instead of the cursor moving the character, the character moves the cursor.
• Try doing the opposite of any number of adventure game clichés.



Ending 6/7/2012 (6th July, sorry for posting late again! I will break the habit next month fo sho)




What is MAGS?

MAGS is a monthly competition for all amateur adventure game makers. The idea is to create a game in under a month, following the rules set by the previous winner. It aims to help you work to a deadline, improve your skills, or provide a kick-start into making adventure games. Regardless of skill, MAGS is for everyone. Voting is based on "favorite" games, and not the most artistic, or the best coded. If you have bad art skills, use it as a chance to do some graphic work. If you're sub-standard at coding, use it as a chance to give scripting a go. Ultimately, people will vote for the most enjoyable entry.

You may get help for the competition, although you must end up doing something yourself. You should however be warned that it proves difficult to organize a big team within thirty days. You are not allowed to use material already created before this competition. Your game must be completely new! Music and sound is an exception; you can use free material that is available to the public, if you wish. Modules and templates are also allowed. Please do not enter the competition with a rushed entry (a game created last minute). Sure, you can make a game and rush it - but don't do this just to win by default.

Entering MAGS is simple. First, conceptualise your game following the month's criteria (see top). Second, create your game fueled only by coffee. Third, finally, and most importantly, post your game here, including:

âœ" A working download link.
âœ" The title of your game.
âœ" A suitable screenshot.

At the end of the month, the all-important voting will begin! This period usually lasts fifteen days. Should you win, along with announcing the next month's rules, your name and game will be immortalised in the MAGS Archive. Yet hopefully, at the end of the month, the accomplishment of finishing a game will be your greatest prize. For more information please visit the Official MAGS website.
#497
No worries, I'll close it.
#498
That's the one thanks :)
#499
I'm trying to remember which film this is... it's about some super-soldiers who were genetically engineered and then cryogenically frozen to keep them dormant, until they needed to be used to fight some Russian/Ukranian terrorist who had taken over a nuclear power station, who had this uber-supreme-super-soldier who single-handedly took down the super-soldier army. I also remember one of the super-soldiers was being reprogrammed into civilian life but he went into a frenzy in a café. Also it starts with the kidnapping of some diplomat's daughter by men in balaclavas. It's a pretty lame film but does anybody know it?
#500
Thank you Sephiroth! I have a confession - I started working on a solution before I saw your reply :-[ In any case, your code looks much more concise than mine. I appreciate it a lot! For posterity:

Code: AGS

if (Parser.Said("look rol") || Parser.Said("take rol") || Parser.Said("fight rol")) // Can add more but these are the main global commands
{
               String word[49];
               int verb_type, index, w;
               
	       // Set the action the player wants to perform, to be used much later on
               if (Parser.Said("look rol")) verb_type = 1;
               else if (Parser.Said("take rol")) verb_type = 2;
               else if (Parser.Said("fight rol")) verb_type = 3;
               
               if (command.IndexOf(" ") != -1) { // Player has typed more than two words so has a verb AND a target
                                                       
                    // Separate the verb...
                    String verb = command.Substring(0, command.IndexOf(" "));
                    // from the target.
                    String target = command.Substring(command.IndexOf(" ")+1, command.Length-command.IndexOf(" "));
                    
                    if (target.IndexOf(" ") == -1) word[0] = target; // It is a one-word target, so we can skip below!
                    
                    else {
                    
                    // Now remove all additional spaces from the target so we get separate words to store in an array
                                        
                         while (target.IndexOf(" ") != -1) {

                              // Get the first word in the target string
                              index = target.IndexOf(" ");
                              String first_word = target.Substring(0, index);
                                                            
                              // Put the first word into an array. Do not if it is an ignored word in parser dictionary, or another space.
                              if (Parser.FindWordID(first_word) != 0 && first_word.Length != 1) {
                                   word[w] = first_word; w++; }
                              
                              // Now, make the original string the remainder of the text
                              target = target.Substring(index+1, target.Length-index);
                              
                              // If the remainder doesn't contain any more spaces, it is the final word so we must store it!
                              if (target.IndexOf(" ") == -1) word[w] = target;
                              
                         }
                    }                       
 
                    // Now we have found the words to check, we can cycle through all the named entities in the game:
                                       
                    struct Occurence { int occurence[99], match, max, a; };
                    Occurence entity[3]; // entity 1 for mobs, 2 for items, 3 for equipment
                    int x, m = 1, i, e; // m = 1 because do not check mob 0 (player)
                   
                    while (x < 49) // Cycle through all the words stored
                    {
                         if (!String.IsNullOrEmpty(word[x])) {
                              
                              while (m < Max_Mobs) 
                              {
			           // To be a valid target, m must be in the same room and contain the word(s) the player entered
                                   if (!String.IsNullOrEmpty(mob[m].name) && mob[m].loc == mob[0].loc && mob[m].name.IndexOf(word[x]) != -1) entity[0].occurence[m]++; // It does, so it matches at least one word
                                   m++;
                              }
                              
                              while (i < Max_Items) 
                              {
                                   // Must be in the player's inventory and have a name match
                                   if (!String.IsNullOrEmpty(item[i].name) && (item[i].loc == mob[0].loc || item[i].quan) && item[i].name.IndexOf(word[x]) != -1) entity[1].occurence[i]++;
                                   i++;
                              }
                              
                              while (e < Max_Equipment) 
                              {
                                   // Equipment must be available to wear/wield
                                   if (!String.IsNullOrEmpty(equ[e].name) && equ[e].unlocked && equ[e].name.IndexOf(word[x]) != -1) entity[2].occurence[e]++;
                                   e++;
                              }
                         }
                        
                         x++; m = 1; i = 0; e = 0;

                     }


                     // Now we have looked at all the words, we can find the entity with the most matched words (occurence) - ie, the most likely target
                     
                     while (m < Max_Mobs)
                     {
                         if (!String.IsNullOrEmpty(mob[m].name)) {
                         if (entity[0].max < entity[0].occurence[m]) { entity[0].max = entity[0].occurence[m]; entity[0].match = m; } // If it has more matches than the current max, it is potentially the target                       

                         // Print(String.Format("%s - %d matches", mob[m].name, entity[0].occurence[m])); // Just shows a list of mobs and how many word matches they had
                                        
                         }
                                        
                         m++;
                                        
                         if (m == Max_Mobs) { // The while loop has ended
                              m = 1;
                              while (m < Max_Mobs) // Cycle through again to check whether more than one word has the max value
                              {
                                   if (entity[0].max && entity[0].occurence[m] == entity[0].max) entity[0].a++; // a counts how many times the maximum value appears
                                   m++;
                              }
                         }
                     }

                     while (i < Max_Items) // Comments as above
                     {
                         if (!String.IsNullOrEmpty(item[i].name)) {
                         if (entity[1].max < entity[1].occurence[i]) { entity[1].max = entity[1].occurence[i]; entity[1].match = i; }                         

                         // Print(String.Format("%s - %d matches", item[i].name, entity[1].occurence[i]));
                                        
                         }
                                        
                         i++;
                                        
                         if (i == Max_Items) {
                              i = 0;
                              while (i < Max_Items)
                              {
                                   if (entity[1].max && entity[1].occurence[i] == entity[1].max) entity[1].a++;
                                   i++;
                              }
                         }
                     }

                     while (e < Max_Equipment)
                     {
                         if (!String.IsNullOrEmpty(equ[e].name)) {
                         if (entity[2].max < entity[2].occurence[e]) { entity[2].max = entity[2].occurence[e]; entity[2].match = e; }                         

                         // Print(String.Format("%s - %d matches", equ[e].name, entity[2].occurence[e]));
                                        
                         }
                                        
                         e++;
                                        
                         if (e == Max_Equipment) {
                              e = 0;
                              while (e < Max_Equipment)
                              {
                                   if (entity[2].max && entity[2].occurence[e] == entity[2].max) entity[2].a++;
                                   e++;
                              }
                         }
                     }

	       // Now we can find the actual target:

               if (!entity[0].a && !entity[1].a && !entity[2].a) { Print("There is nothing here by that name."); return; } // There were no matches at all :(
               else if (1 < entity[0].a || 1 < entity[1].a || 1 < entity[2].a) { Print("Please be more specific."); return; } // i.e, max occurence appears at least twice, so we can never find the desired target

                     int target_type;

                     if (entity[1].max < entity[0].max && entity[2].max < entity[0].max) target_type = 1;        // If there are more matches for a mob than there are for items or equipment, target is a mob
                     else if (entity[0].max < entity[1].max && entity[2].max < entity[1].max) target_type = 2;   // ...
                     else if (entity[0].max < entity[2].max && entity[1].max < entity[2].max) target_type = 3;   
                     else { Print("Please be more specific."); return; } // No entity type has a majority so again the target cannot be found

	             // Finally, give the response:

                     if (verb_type == 1) // LOOK
                     {
                         if (target_type == 1) Print(mob[entity[0].match].desc);        // A mob had the most matches, and the specific mob was the match
                         else if (target_type == 2) Print(item[entity[1].match].desc);  // ...
                         else if (target_type == 3) Print(equ[entity[2].match].desc);
                     }
                     
                     if (verb_type == 2) // TAKE
                     {
                         if (target_type == 1) // ...
                         if (target_type == 2) // ...
                     }
                     
                     if (verb_type == 3)
                     {
                          // ...
                     }

                 }
               
                    else { // Only a single word was entered
                         if (verb_type == 1) Build(mob[0].loc);
                         // ...
                    }
}


In an indirect way it checks how likely the player wants one thing taking into account all the other entities in a room. "look c" would show the description for a chest if it's the only thing in the room, but not if there was also a candle present. If you entered "look ch" then it would describe the chest. I'm not sure how foolproof it is but so far it seems to be working...
SMF spam blocked by CleanTalk