Recent Posts

Pages: 1 2 [3] 4 5 ... 10
21
General discussion / Re: Free Pixel Art Making Programs
« Last post by Zefk on August 07, 2018, 09:54:58 pm »
@froggy77
Added it. Those are some nice tutorials.
22
General discussion / Re: Free Pixel Art Making Programs
« Last post by froggy77 on August 07, 2018, 09:04:40 pm »
There is a blog with a lot of tutorials on Pixel art:
MiniBoss - Pixel art tutorials
The link could be added in the first post.
23
Your projects / Re: New Debian/Ubuntu Package Location
« Last post by Zefk on August 07, 2018, 07:32:45 am »
@Nate-Devv

I have to say thanks for the Ubuntu version! I use it all the time.
24
Development / Re: Multiple enemies not acting the same
« Last post by Diarandor on August 06, 2018, 08:23:15 am »
Some of your state variables, like 'attacking', are not local.
25
Development / Multiple enemies not acting the same
« Last post by Starlock on August 06, 2018, 06:18:11 am »
I have an enemy that creates small spheres that circle around the enemy and are thrown at the hero. However, when I have 2 enemies, only one of them will do the proper attack.

Code: Lua
  1. local enemy = ...
  2. local game = enemy:get_game()
  3.  
  4. local can_shoot = true
  5.  
  6.  
  7. local sprite = nil
  8. local nb_bats_created = 0
  9. local nb_to_create = 0
  10. local raintimer = nil
  11.  
  12. function enemy:on_created()
  13.   -- Set properties.
  14.   self:set_life(4); self:set_damage(6); self:set_hurt_style("normal")
  15.   self:set_pushed_back_when_hurt(true); self:set_push_hero_on_sword(false)
  16.   self:set_traversable(true)
  17.   -- Create sprite if necessary, etc.
  18.   sprite = self:get_sprite()
  19.   if not sprite then sprite = self:create_sprite("enemies/more/dark/rainbow") end
  20.   function sprite:on_animation_finished(animation)
  21.         if animation == "looking" then sprite:set_animation("stopped") end --***
  22.   end
  23.   -- Start enemy.
  24.   self:restart()
  25. end
  26.  
  27.  
  28.  
  29. local function go_hero()
  30.  
  31.   local map = enemy:get_map()
  32.   local hero = map:get_hero()
  33.  
  34.   if enemy:get_distance(hero) < 120 then
  35.  
  36.   local sprite = enemy:get_sprite()
  37.   sprite:set_animation("walking")
  38.   local movement = sol.movement.create("target")
  39.   movement:set_speed(64)
  40.   movement:start(enemy)
  41.  
  42.   else
  43.  
  44.   local sprite = enemy:get_sprite()
  45.   sprite:set_animation("walking")
  46.   local movement = sol.movement.create("random")
  47.   movement:set_speed(64)
  48.   movement:start(enemy)
  49.   end
  50. end
  51.  
  52.  
  53.  
  54.  
  55. function enemy:attack()
  56.  
  57.  
  58.  
  59.   if jumping or attacking then
  60.     return
  61.   end
  62.  
  63.   if cancel_next_attack then
  64.     cancel_next_attack = false
  65.     return
  66.   end
  67.  
  68.   attacking = true
  69.   sprite:set_animation("shooting")
  70.  
  71.   local prefix = "bat" .. "_bat_"
  72.   nb_to_create = 6
  73.  
  74.   function repeat_throw_bat()
  75.  
  76.     sol.audio.play_sound("lamp")
  77.     nb_bats_created = nb_bats_created + 1
  78.     local son_name = prefix .. nb_bats_created
  79.     local son = enemy:create_enemy{
  80.       name = son_name,
  81.       breed = "more/dark/rainattack",
  82.       x = 0,
  83.       y = 0,
  84.       layer = 0,
  85.     }
  86.     if math.random(6) == 1 then
  87.       son:set_treasure("magic_flask", 1)
  88.     end
  89.     son:go_circle(enemy)
  90.     local go_hero_delay = 2000 + (nb_to_create * 150)
  91.     sol.timer.start(son, go_hero_delay, function() son:go_hero() end)
  92.  
  93.     nb_to_create = nb_to_create - 1
  94.     if nb_to_create > 0 then
  95.       raintimer = sol.timer.start(enemy:get_map(), 350, repeat_throw_bat)
  96.     else
  97.       attacking = false
  98.       attack_scheduled = false
  99.       if not vulnerable then
  100.   sol.timer.start(2000, function()
  101.         go_hero()
  102.   end)
  103.       else
  104.         cancel_next_attack = false
  105.       end
  106.     end
  107.   end
  108.   enemy:stop_movement()
  109.   enemy:get_sprite():set_direction(0)
  110.   repeat_throw_bat()
  111. end
  112.  
  113. function enemy:on_hurt()
  114.   nb_to_create = 0
  115.   if raintimer ~= nil then
  116.   raintimer:stop()
  117.   end
  118.   enemy:get_map():remove_entities("bat" .. "_bat_")
  119. end
  120.  
  121. function enemy:on_dying()
  122.   nb_to_create = 0
  123.   if raintimer ~= nil then
  124.   raintimer:stop()
  125.   end
  126.   enemy:get_map():remove_entities("bat" .. "_bat_")
  127. end
  128.  
  129. function enemy:on_restarted()
  130.  
  131.   local map = enemy:get_map()
  132.   local hero = map:get_hero()
  133.  
  134.   go_hero()
  135.  
  136.   can_shoot = true
  137.  
  138.   sol.timer.start(enemy, 100, function()
  139.  
  140.     local hero_x, hero_y = hero:get_position()
  141.     local x, y = enemy:get_center_position()
  142.  
  143.     if can_shoot then
  144. if enemy:get_distance(hero) < 150 then
  145.         attack()
  146.         can_shoot = false
  147.         sol.timer.start(enemy, 6666, function()
  148.           can_shoot = true
  149.         end)
  150.       end
  151.     end
  152.     return true  -- Repeat the timer.
  153.   end)
  154. end
  155.  
  156. function enemy:on_movement_changed(movement)
  157.  
  158.   local direction4 = movement:get_direction4()
  159.   local sprite = self:get_sprite()
  160.   sprite:set_direction(direction4)
  161. end
  162.  
  163.  
26
General discussion / Re: Text position on top...
« Last post by Dokk on August 05, 2018, 12:20:43 pm »
In a grow of work, I didn't read comments for script. Shame on me! Thank you , Christopho. My progress is saved  ;D
27
Bugs & Feature requests / Re: Complex movements
« Last post by Christopho on August 04, 2018, 11:24:38 pm »
More complex example from stdgregwar:
this is the final custcene of Zelda XD2 rewritten with his script.
Code: Lua
  1. -- Final cinematic, but flat
  2. function map:start_cinematic_redux()
  3.   cutscene.builder(game,map,hero)
  4.     .wait(500)
  5.     .dialog('final.zelda_4',player_name)
  6.     .set_direction(hero,1)
  7.     .dontWaitFor.hero_animation('walking')
  8.     .movement{ --movement 1
  9.         type='target',
  10.         entity=hero,
  11.         movement_properties={
  12.           target = {104,192},
  13.           speed = 50,
  14.           smooth = true,
  15.           ignore_obstacles = true,
  16.         }
  17.              }
  18.     .set_direction(hero,0)
  19.     .dontWaitFor.hero_animation('stopped')
  20.     .wait(500)
  21.     .dialog('final.zelda_5',player_name)
  22.     .wait(500)
  23.     .dialog('final.mr_grump_3')
  24.     .wait(500)
  25.     .dialog('final.zelda_6',player_name)
  26.     .set_direction(hero,2)
  27.     .dontWaitFor.hero_animation('walking')
  28.     .movement{--movement 2
  29.         type = 'target',
  30.         entity=hero,
  31.         movement_properties={
  32.           target = {-32,192},
  33.           speed = 80,
  34.           smooth = true,
  35.           ignore_obstacles = true
  36.         }
  37.              }
  38.     .wait(500)
  39.     .set_direction(hero,0)
  40.     .dontWaitFor.hero_animation('carrying_walking')
  41.     .dontWaitFor.sprite_animation(cocktails:get_sprite(),'walking')
  42.     .movement(--movement 3
  43.       {
  44.         type='target',
  45.         entity=hero,
  46.         movement_properties={
  47.           target = {104,192},
  48.           speed = 80,
  49.           smooth = true,
  50.           ignore_obstacles = true
  51.         }
  52.       },
  53.       function(mov)
  54.         function mov:on_position_changed()
  55.           if cocktails then
  56.             local hero_x,hero_y = hero:get_position()
  57.             cocktails:set_position(hero_x,hero_y-16)
  58.           end
  59.         end
  60.       end)
  61.     .dontWaitFor.hero_animation('carrying_stopped')
  62.     .dontWaitFor.sprite_animation(cocktails:get_sprite(),'on_ground')
  63.     .wait(1500)
  64.     .exec(
  65.       function()
  66.         cocktails:remove()
  67.       end)
  68.     .dontWaitFor.hero_animation('stopped')
  69.     .dialog('final.zelda_7',player_name)
  70.     .wait(500)
  71.     .dontWaitFor.hero_animation('dying')
  72.     .wait(2000)
  73.     .dontWaitFor.hero_animation('walking')
  74.     .set_direction(hero,2)
  75.     .movement{--movement 4
  76.         type='target',
  77.         entity=hero,
  78.         movement_properties = {
  79.           target = {-32,192},
  80.           speed = 80,
  81.           smooth = true,
  82.           ignore_obstacles = true
  83.         }
  84.       }
  85.     .wait(1000)
  86.     .dialog('final.zelda_8')
  87.     .wait(500)
  88.     .and_then(
  89.       function(cont)
  90.         fade_sprite = sol.sprite.create('entities/heart_fade')
  91.         local camera_x, camera_y = map:get_camera():get_position()
  92.         local zelda_x, zelda_y = grump_and_zelda:get_position()
  93.         fade_x = zelda_x - camera_x
  94.         fade_y = zelda_y - camera_y - 16
  95.         fade_sprite:set_animation('close',cont)
  96.       end)
  97.     .exec(
  98.       function()
  99.         -- Fill screen with black.
  100.         local quest_w, quest_h = sol.video.get_quest_size()
  101.         black_surface = sol.surface.create(quest_w, quest_h)
  102.         black_surface:fill_color({0, 0, 0})
  103.       end)
  104.     .wait(1000)
  105.     .exec(
  106.       function()
  107.         local menu_font, menu_font_size = language_manager:get_menu_font()
  108.         end_text = sol.text_surface.create{
  109.           horizontal_alignment = "center",
  110.           vertical_alignment = "middle",
  111.           color = {255, 255, 255},
  112.           font = menu_font,
  113.           font_size = menu_font_size * 2,
  114.           text_key = "final.end_text",
  115.         }
  116.       end)
  117.     .wait(2000)
  118.     .exec(
  119.       function()
  120.         -- Launch Ending credits.
  121.         local dialog_box = game:get_dialog_box()
  122.         dialog_box:set_position("bottom")
  123.       end)
  124.     .dialog('final.credits')
  125.     .exec(
  126.       function()
  127.         local statistics = statistics_manager:new(game)
  128.         game:set_suspended(true)
  129.         sol.menu.start(game, statistics)
  130.         function statistics:on_finished()
  131.           -- Reset game.
  132.           sol.main.reset()
  133.         end
  134.       end)
  135.     .start()
  136. end
  137.  
28
General discussion / Re: Text position on top...
« Last post by Christopho on August 04, 2018, 08:06:27 pm »
The dialog box script explains how to do that:
Code: Lua
  1. -- - dialog_box:set_position(position):
  2. --   Sets the vertical position of the dialog box for subsequent dialogs.
  3. --   position must be one of:
  4. --   - "auto": Choose automatically so that the hero is not hidden.
  5. --   - "top": Top of the screen.
  6. --   - "bottom" (default): Bottom of the screen.
  7. --   - a table with x and y integer fields.
  8.  
29
General discussion / Text position on top...
« Last post by Dokk on August 04, 2018, 07:22:03 pm »
Hello. I have a problem with some specific text position. I made a map titles (kinda "Level 1: The Beginning") as a dialogs. And I want to start this map name then game is starting on the top of the screen for 2-3 seconds.

Code: Lua
  1. function map:on_started()
  2.  
  3. --Starting a map title
  4. game:start_dialog("level.1")
  5.  

 I tried to change the position directly in alttp_dialog_box and surely all my dialogs became to the top ;D

So, how to change the text position only for some specific text as mine?
30
Your projects / Re: Book Alpha Release
« Last post by Zefk on August 03, 2018, 07:55:29 am »
Okay, this is still experimental, but here it is the book!

You can find everything in Github release. The pdf is in the "book" directory.

Github Alpha Release: Here
Website: Here

Please report any errors/suggestions here or on Github and see new commits for fixes
Pages: 1 2 [3] 4 5 ... 10