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.


Topics - froggy77

Pages: [1] 2
1
General discussion / GIMP - script-fu for pixel art - change RGB
« on: February 24, 2018, 11:09:28 pm »
Hello,

I created another script to be used with GIMP that it is supposed to be useful for pixel artists.
The aim is to change RGB colors of an image or a selection. I got the idea of ​​this script thanks to this topic "Convert US colour to PAL"

This is a beta version, I hope there will be not too many bugs. Please save your work before. ::)
Don't hesitate to report bugs.

See attachment file

What is this kind of script?
It is explained here: https://docs.gimp.org/en/gimp-concepts-script-fu.html
 (There is often a translation of docs.gimp.org pages, just replace "en" by "fr" to get for example the french page: https://docs.gimp.org/fr/gimp-concepts-script-fu.html , it italian, es spanish, de ...)

Where to copy it?
It is explained here:  https://docs.gimp.org/en/install-script-fu.html

Some explanations

- It appears in the menu /Filters/pixelart-change-rgb of GIMP
- It opens a pop-up window where you can change Red, Green and Blue values.
By default, I add 32 to all colors, but you can change these values editing the script.
SF-ADJUSTMENT    "Red"       '(32 -255 255 1 10 0 SF-SLIDER)
SF-ADJUSTMENT    "Green"   '(32 -255 255 1 10 0 SF-SLIDER)
SF-ADJUSTMENT    "Blue"      '(32 -255 255 1 10 0 SF-SLIDER)
- It allows to add or subtract a value to Red Green Blue (RGB) of the selection or the image and draw the result into another image.
- Maximum of 256 colors in your image or in your selection.
- If there is a selection, only the selected layer and its selection are taken into account.
- If there is no selection, all layers are taken into account.

2
Hello,

I created a script to be used with GIMP that it is supposed to be useful for pixel artists.
The aim is to get the colors palette of an image and to help to detect the similar colors that could be replaced.

This is a beta version, I hope there will be not too many bugs. Please save your work before. ::)
Don't hesitate to report bugs.

See attachment file


What is this kind of script?
It is explained here: https://docs.gimp.org/en/gimp-concepts-script-fu.html
 (There is often a translation of docs.gimp.org pages, just replace "en" by "fr" to get for example the french page: https://docs.gimp.org/fr/gimp-concepts-script-fu.html , it italian, es spanish, de ...)

Where to copy it?
It is explained here:  https://docs.gimp.org/en/install-script-fu.html

Some explanations

- It appears in the menu /Filters/pixelart-get-palette of GIMP
- It opens a pop-up window where you can change the width and the height of the "tile" which represents one color.
By default, I put width = 16 pixels and height = 10 pixels, but you can change these values editing the script.
SF-ADJUSTMENT    "Width"        '(16 1 50 1 10 0 SF-SLIDER)
SF-ADJUSTMENT    "Height"        '(10 1 50 1 10 0 SF-SLIDER)
- It allows to get palette of the selection or the image and draw it into another image.
- There is a maximum of 256 colors in your image or in your selection, otherwise the script will not work.
- If there is a selection, only the selected layer and its selection are taken into account.
- If there is no selection, all layers are taken into account.
- For the moment, the script does not sort colors. Maybe in the future.


Several years ago, I posted some scripts on http://registry.gimp.org/ but the site is still in maintenance. So, why not to share it to Solarus community which is one of my favorite forum and where I noticed several gimp users and pixel artists... ;)

3
Development / [Solved]How to add an "opening" animation for chests?
« on: May 07, 2017, 08:06:50 pm »
Hello,

I would like to add an intermediate animation for chests. "closed" and "open" are the basic animations. I added, in the .dat files, an "opening" animation which it could be in 1 or 2 frames according the size of the chests.

How woud you proceed in lua scripts?


Sorry, I have lost a lot of skills in lua and even about Solarus in general, because I have not worked on it for several months.
Moreover, there are now in the last versions, scripts "features" and "multi_events" which is all the more new and difficult for me.
But instead, I improved my pixel art skills a bit  ;) . I will soon update my topic on the project.

4
Development / How to get a list of all .dat files in ./data/maps/
« on: August 02, 2016, 07:10:19 pm »
Hello,

I would like to get a list of all .dat files in ./data/maps/

e.g.:
./data/maps/cave_1f.dat ./data/maps/cave_2f.dat
./data/maps/inside_store.dat
./data/maps/library.dat
./data/maps/lost_woods.dat
./data/maps/outside_store.dat
./data/maps/outside_west.dat
./data/maps/shop.dat
./data/maps/test_map.dat
./data/maps/water_temple_1f.dat
./data/maps/water_temple_2f.dat
./data/maps/water_temple_final_room.dat
I found out a solution but it's quite complicated.
How would you do?

5
Development / Help: how to get a non rectangular region of a surface?
« on: July 10, 2016, 06:49:16 pm »
Hello,

Is it possible to get the opposite region of several regions in a surface?
In this example, there are several yellow rectangles and I would like to get the black part.


6
Development / HUD: ZL - level (LVL) & experience (XP)
« on: January 28, 2016, 06:54:26 pm »
HUD - ZL - level (LVL) & experience (XP)



I try to create a game system with points of experience and levels for my Zelda-like project.
Starlock sent me an email: "I was also planning on making an xp system and was hoping I could see your code and fiddle around with it :P"
So I share my work if this could be useful for others...

____________________

SCRIPT

Here is the main script for the HUD. See in attachment.
Put this script in '../data/scripts/hud/lvl_and_xp.lua'

In this script there is a table:
self.t_xp_to_levelup = {100, 200, 300, 400, 500, 600, 700, 800}

You are level 1 and you need 100 xp  to level up.
You are level 2 and you need 200 xp  to level up.
You are level 3 and you need 300 xp  to level up.
...
You are level 8 and you need 800 xp  to level up.
Then level 9 appears and xp counters are blocked (800/800). They appears in green because I used 'small_green_digits' font that I think you have got.
Put  your own values. Obviously, it will not be 100, 200, 300 etc.. ;)
You are not limited to 8 values.

____________________

IMPORTANT

You will have to add some lines in certain lua files. See below.
I hope I don't forget something.  ;D

____________________

IMAGE

Copy this image. See in attachment.

../data/sprites/hud/lvl_and_xp_icon.png

_________________

POSITION IN THE HUD

In '../data/scripts/hud.lua' , you need declare the position of lvl and xp elements.
(-104, 16) is an example.


  ---- Create each element of the HUD.
  -- blablabla

Code: [Select]
  local lvl_and_xp_builder = require("scripts/hud/lvl_and_xp")
-- blablabla

Code: [Select]
  menu = lvl_and_xp_builder:new(game)
  menu:set_dst_position(-104, 16)
  hud.elements[#hud.elements + 1] = menu

-- blablabla

____________________

SAVEGAME FILE

In "../data/scripts/game_manager.lua", and more precisely in the "function game_manager:create(file)", we have to declare two values for a new savegame file. Also add 'current_level = 0'  and 'current_xp = 0' in your existing savegame files.

--  if not exists then
    ---- This is a new savegame file.
   -- blablabla
Code: [Select]
game:set_value("current_level", 0)
game:set_value("current_xp", 0)
--  end
-- blablabla

____________________

FUNCTIONS TO ADD, SET or GET XP and LEVEL

In '../data/scripts/quest_manager.lua', because I think it is practical to add or set or  get xp and level of our hero, I added some functions.
All these functions are not necessaries, but they are very useful in debug console to test.
hero:set_level(3) is equal to game:set_value("current_level", 3)
hero:add_level(1) so  'current_level = 4' in your 'saveX.dat' if you save the game.
hero:get_level() is equal to game:get_value("current_level")
hero:set_xp(100)    is equal to  game:set_value("current_xp", 100)
hero:add_xp(10)   so  'current_xp = 110' in your 'saveX.dat' if you save the game. hero:add_xp(number) is the most useful for enemies.
hero:get_xp()  is equal to  game:get_value("current_xp")


Code: Lua
  1. -- Initializes some behavior of our hero.
  2. local function initialize_hero()
  3.  
  4.   local hero_meta = sol.main.get_metatable("hero")
  5.  
  6.   -- ZL --  Functions for levels of our hero
  7.   function hero_meta:set_level(lvl)
  8.  
  9.     if type(lvl) == "number" then
  10.                 local game = self:get_game()
  11.                 game:set_value("current_level", lvl)
  12.         else
  13.         print("Error in hero:set_level(lvl), lvl should be a number.")
  14.     end
  15.   end
  16.   function hero_meta:add_level(lvl)
  17.  
  18.     if type(lvl) == "number" then
  19.                 local game = self:get_game()
  20.                 local current_level = game:get_value("current_level")
  21.                 game:set_value("current_level", current_level + lvl)
  22.         else
  23.         print("Error in hero:add_level(lvl), lvl should be a number.")
  24.         end
  25.   end
  26.   function hero_meta:get_level()
  27.  
  28.         local game = self:get_game()
  29.         local current_level = game:get_value("current_level")
  30.         return current_level
  31.   end
  32.   -- ZL --  Functions for experience points of our hero
  33.   function hero_meta:set_xp(xp)
  34.  
  35.     if type(xp) == "number" then
  36.                 local game = self:get_game()
  37.                 game:set_value("current_xp", xp)
  38.         else
  39.         print("Error in hero:set_xp(xp), xp should be a number.")
  40.     end
  41.   end
  42.   function hero_meta:add_xp(xp)
  43.  
  44.     if type(xp) == "number" then
  45.                 local game = self:get_game()
  46.                 local current_xp = game:get_value("current_xp")
  47.                 game:set_value("current_xp", current_xp + xp)
  48.         else
  49.         print("Error in hero:add_xp(xp), xp should be a number.")
  50.         end
  51.   end
  52.   function hero_meta:get_xp()
  53.  
  54.         local game = self:get_game()
  55.         local current_xp = game:get_value("current_xp")
  56.         return current_xp
  57.   end
  58.  
  59. end
  60.  
  61.  

Edit: Sorry, don't forget to  initialize_hero() !!!
Code: Lua
  1. function quest_manager:initialize_quest()
  2.  
  3.   -- blablabla
  4.   initialize_hero()
  5.   -- blablabla
  6.  
  7. end

____________________

ENEMIES

In your scripts for enemies where you have declared their behavior  (e.g  ../data/enemies/lib/slime_behavior.lua),
just add a variable named for example "properties.xp" in your 'function behavior:create(enemy, properties)'. I don't know, but the name of your function is perhaps different.

In my example, I decided to define xp according to life, damage and speed of the enemy.
Code: [Select]
properties.xp = properties.xp or (properties.life * properties.damage * properties.normal_speed)
In this example, I added xp in the 'function enemy:on_dying()', I think it is logical, but you can do differently:

  function enemy:on_dying()
 
Code: [Select]
local hero = enemy:get_map():get_entity("hero")
hero:add_xp(properties.xp)
  end

7
Development / Help: destructible / regenerate / lift / animation and sound
« on: November 21, 2015, 07:59:19 pm »
Hello,

I would like an object that can regenerate.
But, my problem is that when I tick the option to regenerate, there are two animations of destruction:
First, there is an animation of destruction (with the sound) when the hero begins to lift an object
 and then, there is the same animation and the same sound when the hero is destroying this objet (after having throwing it).
The first animation is OK for a "flower bomb", not too ugly for a bush, but strange for a rock or something in wood.

Is there a way to have two animations and sounds or even delete the first animation of destruction and its sound?
I tried with metables, but I did not succeed.

Thanks in advance.

8
Development / Problem with fade_in and fade_out methods
« on: October 04, 2015, 06:53:51 pm »
Hello,

I don't know if there is a bug with the following methods:
drawable:fade_in([delay], [callback])
 and
drawable:fade_out([delay], [callback])

I make maybe some mistakes in the use of these methods. :-[
These methods work, but at the end, the chosen colors are not exactly the same.
When I picked the color in an image editor (e.g. Gimp), I can see it's darker.
It is as if the surface kept a little transparency at the end of my fade_in() . Even when I used surface:clear()

So instead of writing this,
self.bg_surface:fade_in()

I write this:
self.bg_surface:fade_in(20, function () self.bg_surface:set_opacity(255) end)

This workaround may not work with text_surface, because there is no text_surface:set_opacity(opacity)
Is there a solution?

9
I see this method  'pickable:get_followed_entity()' exists so I guess it is possible to attach a pickable heart to a custom entity  would return together to the hero.
Perhaps with movements? But how then appoint an unnamed pickable heart created automaticcally by the engine?I can get the sprite with a table, but not the entity.

10
Hello,

Unless I am mistaken, only surfaces have the following method in drawable objects (surfaces, text surfaces and sprites):
surface:set_opacity(opacity)

drawable:set_opacity(opacity) would be a good  feature, isn't it?

11
Development / HUD: ZL Hearts
« on: May 24, 2015, 06:35:56 pm »
----------------------------
HUD - "ZL HEARTS"
version 1.0


Attachment:  HUD - ZL Hearts.zip
----------------------------

- Explanation:
This stuff will help you to change the appearance of the health bar in your Solarus project.
The first heart represents the first four lives... OK stop! No further explanation!. A picture is worth a thousand words;

Example 1:
The original health bar (here, there are 15.5/20 hearts or 15.5 * 4 = 62 lives on 80) will be replaced by this smaller bar:


Example 2:
I played with the console to test "game:set_life()" and "game:set_max_life()"



- Tested with Solarus v1.4.2

- IMPORTANT !!! Save your files before replacing them!

- Copy these files in your Solarus project. The file path may differ from yours.

..\data\sprites\hud\empty_heart.dat    (There are 6 animations instead of 2 animations if you compare with the original data file.)

..\data\sprites\hud\hearts.png      (Some graphics are edited from a Zelda game. For copyright reasons, don't sell your project! )

..\data\scripts\hud\hearts.lua      (This file contains the main script edited from a original one by Christopho.)

..\data\scripts\hud\hud.lua      (It is not necessary to replace this file. The script contains a few more lines than the original created by Christopho. Keep yours and see below )
1st choice:
 Copy the "hud.lua" file or add/replace these lines if you want to align element to right  when the player wins a new  heart container.
Code: [Select]
(...)
local hearts = hearts_builder:new(game)
hearts:set_dst_position(- (game:get_max_life() + 16), 6)
hud.elements[#hud.elements + 1] = hearts
local nb_max_hearts_displayed = game:get_max_life() / 4
(...)
local nb_max_hearts = game:get_max_life() / 4

if nb_max_hearts ~= nb_max_hearts_displayed then
nb_max_hearts_displayed = nb_max_hearts
hearts:set_dst_position(- (game:get_max_life() + 16), 6)
 end
(...)

2nd choice:
Keep your "hud.lua" file if you want to align element to left when the player wins a new heart container.
Just adjust the x value of  hearts:set_dst_position(-104, 6)
Perhaps you should also change the value of x hearts.surface = sol.surface.create(116, 11) in the "hearts.lua" file.


EDIT:
- Erratum: For empty_heart.dat, I said there were "6 animations instead of 4 animations",  but it's "6 animations instead of 2 animations"
- Images were hosted at an ISP, so I attached them directly at the forum,  as I did with the .zip file.
You just have to be connected to see images.


12
Development / Question: Is it possible to resize a surface?
« on: May 18, 2015, 10:23:04 pm »
Hello,

Is it possible to resize a surface with something like "surface:set_size()" that seems to not exist?

I would like to to do it in a "rebuild_surface' function.


Thanks in advance.

13
Your projects / Solarus - ZL project
« on: April 14, 2015, 11:03:36 pm »
Quelques graphiques qui sont en cours pour un projet Zelda-like. Si vous avez des critiques, je suis preneur! /
Some graphics that are in progress for a Zelda-like project. If you have critics, I'm interested!  ;)


ENEMY:

Sorcier Rouge / Red Wizard




NPCs:


Très inspiré par Hamlet le cochon dans Illusion of Time. / Very inspired by Hamlet the pig in Illusion of Gaia. image















14
Development / Create an output file to debug your script
« on: April 13, 2015, 08:23:49 pm »
I am a beginner in lua scripting , but I would like to share something that helped me to debug a problem in a lua script.
This will be useful only for newbies like me ;)
I simply redirected the outcome of variables into a new text file to better understand what was wrong with my script .
Just add these lines in the script by replacing, of course, the name of your variables.
For my part , I inserted these lines in a loop.

- Here an example with 3 variables: var1, var2 and booleanvar

Code: [Select]
file = io.output (io.open ("my_debug.txt", "a +"))
io.write ("variable1 =" ,var1 , "\tvariable2 =", var2, "\t", "\tboolean variable =")
if booleanvar then
io.write ("true")
else
io.write ("false")
end
io.write ("\n")
io.close (file)

- Info:
"\t" means tab
so "\t", "\tboolean variable =" will generate 2 tabs.

"\n" creates a new line in the file.

Further explanation here and here
(Sorry but it's in French)


- In "my_debug.txt" that will be created in your Solarus project, you will get lines like these:
(Of course DO NOT name your output file "error.txt")

Quote
variable1 =232   variable2 =277      boolean variable =false
variable1 =232   variable2 =277      boolean variable =false
variable1 =232   variable2 =277      boolean variable =false
variable1 =232   variable2 =277      boolean variable =false
variable1 =232   variable2 =277      boolean variable =false
variable1 =232   variable2 =277      boolean variable =false
variable1 =232   variable2 =277      boolean variable =true
variable1 =232   variable2 =277      boolean variable =false
variable1 =232   variable2 =277      boolean variable =false
variable1 =232   variable2 =277      boolean variable =false
variable1 =232   variable2 =277      boolean variable =false
variable1 =232   variable2 =277      boolean variable =false
variable1 =232   variable2 =277      boolean variable =false
variable1 =232   variable2 =277      boolean variable =true
variable1 =338   variable2 =413      boolean variable =false
variable1 =338   variable2 =413      boolean variable =false
variable1 =338   variable2 =413      boolean variable =false
variable1 =338   variable2 =413      boolean variable =false
(...)

15
Development / Help: Enemy throwing a projectile
« on: February 07, 2015, 08:25:24 pm »
Is there an explanation somewhere on the way to create an enemy that throws something like a fireball?
 The enemy would throw the projectile only if the hero is quite close and if the enemy  can see him.

Pages: [1] 2