Wow this seems really cool oO, thanks again
When is AGS 4 update planned for then?
When is AGS 4 update planned for then?


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 MenuQuote from: Crimson Wizard on Fri 19/07/2024 20:54:45The thing is, it does not matter whether there's a valid background, or a blank background, it takes exactly same size in memory ("blank" pixels are still pixels).I thought the same but was explained that pictures are like divided into areas of the same exact colors. So if you have one huge area of a single color it takes almots no memory (my room sprite was 100 ko) while a picture with different colors on every pixel will take more, even a two colors grid (the map I drew was 18Mo and it's more than 4 times as small). Multiplied by the number of maps I thought it was worth saving a bit, maybe it's not relevant compared to the extra ram it would require to generate the tiles.
Quote from: Crimson Wizard on Fri 19/07/2024 09:34:26I think i posted a reply to something very similar a while ago. (I cannot remember whether it was your question or someone elses).
function cd_countdown(int i){
//this function aims at displaying the cooldown of a spell once you've played it. (When you cast the spell,it sets Spell[i].cd to a positive value, which triggers the following codes)
if(Spell[i].cd>0){
Spell[i].cd--;
gSpellbar.Controls[i].AsLabel.Text=String.Format("%d", 1+(Spell[i].cd/40)); //a label from the gui that appears on top,
}
else{
Spell[i].cd=-1;
gSpellbar.Controls[i].AsLabel.Visible=false;
}
}
//but since there are 10 buttons in my spell bar I want it to be checked for every button and spell so I use this :
function repeatedly_execute(){
for(int j=0;j<10;j++){
cd_countdown(j);
}
}
#define MOUSEOVER_NONE 0
#define MOUSEOVER_TRIGGERED 1
#define MOUSEOVER_HOLDING 2
function Mouse_over(){
InventoryItem*item=InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
Character*perso=Character.GetAtScreenXY(mouse.x, mouse.y);
GUIControl*lab=GUIControl.GetAtScreenXY(mouse.x, mouse.y);
GUI*gi=GUI.GetAtScreenXY(mouse.x, mouse.y);
Object *objet=Object.GetAtScreenXY(mouse.x, mouse.y);
if(lab!=null){
if(lab.OwningGUI.ID==54){ ///////specific infos for specific gui54
int s=lab.ID-10;///specific link between my controls numbers and my array
///set the placement and dimensions for the info gui 'ginfoloot'
gInfoloot.Visible=true;
gInfoloot.X=41;
gInfoloot.Height=(stuff[s].lignes+5)*10;
gInfoloot.Width=150;
Infonom.Text=String.Format("%s",stuff[s].Name); ////this label is part of the info gui
}
//-------------------------------------------------------
else if(lab==Btnbuffennemi1){
//here goes the same kind of infos, but for another type of control
//and so on for all the possible guicontrols
}
}
///------------------------------then we go in case the mouse is over a gui------------------
if(gi!=null){
if(gi==ginventory){
///for some reason I use another gui to display info here, called 'ginfo_aide'
ginfo_aide.Visible=true;
ginfo_aide.X=49;
ginfo_aide.Y=329;
Lblinfotitre.TextColor=65184;
Lblinfotitre.Text="Backpack (B)";
ginfo_aide.Height=20;
ginfo_aide.Width=110;
}
else if(gi==gSpellbook){
//same for the other guis
//...
}
}
//-------------------
if(item!=null){
//same for items, characters and objects
}
mo = MOUSEOVER_HOLDING;
}
void repeatedly_execute() {
if(InventoryItem.GetAtScreenXY(mouse.x, mouse.y)!=null||Character.GetAtScreenXY(mouse.x, mouse.y)!=null||GUIControl.GetAtScreenXY(mouse.x, mouse.y)!=null||GUI.GetAtScreenXY(mouse.x, mouse.y)!=null||Object.GetAtScreenXY(mouse.x, mouse.y)!=null){
if(mo==MOUSEOVER_NONE){mo=MOUSEOVER_TRIGGERED;}
}
else{mo=MOUSEOVER_NONE;}
if(mo==MOUSEOVER_TRIGGERED){
Mouse_over();
}
}
int mo=0;
function mouse_over(){
///the same as before except at the very end...
mo=2;
}
function repeatedly execute(){
if(GUIControl.GetAtScreenXY(mouse.x, mouse.y)!=null){ ///||GUI.Getaatscreen||object... for all the type of objects that trigger mouse_over
mo=1;
}
else{
mo=0;
}
if(mo==1){
mouse_over();
}
}
#loadscript.asc
function dataload(){
////loads the data for items...
loot[0].sprite=2184;
loot[0].Name="Casque rare de la Chouette";
loot[0].bonus_agi=10;
loot[1].sprite=2185;
//.....
///and also for skills. Like a template that evolves through a skilltree
skill[1].Nom="Hard skin";
skill[1].Description=String.Format("Increases armor by %d%",(skill[1].lvlcurrent+1)*2);
skill[1].sprite=403;
//skill[1].lvlcurrent=0;
skill[2].Name="Advanced strenght";
//.....
}
function game_start(){
dataload();
}
function mouse_over(){
GUIControl*lab=GUIControl.GetAtScreenXY(mouse.x, mouse.y);
GUI*gi=GUI.GetAtScreenXY(mouse.x, mouse.y);
if(lab!=null){ ////there are a bunch of other conditions here but I removed them to stay focused on the issue
Lblinfotitre.Text=String.Format("%s",skill[u].Nom ); ///this first label gives the skill name. Works perfectly
Lblinfo.Text=String.Format("%s",skill[u].Description); ////this one calls for the description given before. Here is the problem
}
function repeatedly_execute(){
mouse_over();
}
function room_RepExec()
{
Btnfondminimap.X=64-(player.x/10); ///map size in 10 times smaller than the original one
Btnfondminimap.Y=40-(player.y/10);
Btnarrowminimap.NormalGraphic=3220+player.Loop; ///3220 is the arrow facing down, then the 7 others follow the standard directions
}
QuoteOverall, when you need to have 2 objects connected, don't do that with iterating arrays, instead create "links" for a faster access.That's copied, I ll be cautious with this
When possible use integer indexes instead of strings, because comparing strings is slower.
If you really need to use strings, check out "Dictionary", which is made for a faster searches by a string key.
QuotePPS. Ah, I should also note that AGS has a limit of 300 inventory items, for some reason. If you think that your game will need more of these, then you would need to think of another solution (reusing InventoryItems for multiple purposes, for example, or else).
function Materialize_loot(int enemyId) {
for (int li = 0; li < limitestuff; li++) {
////I attribute loots at start up using a function given in a previous topic by Khris. But it's just data until triggered by this function.
///"count" is the amount of item[li] character[enemyId] has in its inventory
int count = enemy_item[EiLookup(enemyId, li)].count;
if (count > 0) {
int tt=-1;
////check the inventory item doesn"t exist yet-->look for the index--->this step will be erased with "index" property
for(int c=0;c<nombre_objets_inventory;c++){
if(inventory[c].Name==butin[li].Nomobjet){
tt=c;
}
}
if(tt!=-1){ ////already created
character[enemyId].AddInventory(inventory[tt]);
}
else{ //new creation
//inventaireused is an int that gives me the next free inventory item
inventory[inventaireused].Name=butin[li].Nomobjet;
inventory[inventaireused].Graphic=butin[li].sprite;
inventory[inventaireused].CursorGraphic=butin[li].sprite;
inventory[inventaireused].SetProperty("Couleur", butin[li].couleur);
/////so this is where I'm going to set :
inventory[inventaireused].SetProperty("index",li);
character[enemyId].AddInventory(inventory[inventaireused]);
////the function that updates inventaireused
inventaire_maj();
}
}
}
}
//Declared as a struct arrays in a script
Item[0].name=hammer;
Item[0].sprite"40;
//...more item stats
Item[1].name=Sword;
Item[1].sprite=41;
//And so on for all the items
//And for instance
Function mouse_over(){
Inventoryitem*selected=inventoryitem.GetatscreenXY(mouse.x,mouse.y);
//Here is the important part:
for int(i=0;i<itemlimit;i++){
if (selected.name==item[i].name){
///Do things using the database, like display the stats, etc.
}
}
}
By continuing to use this site you agree to the use of cookies. Please visit this page to see exactly how we use these.
Page created in 0.080 seconds with 14 queries.