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 - wrightmat

Pages: [1] 2 3
1
General discussion / PC Gamer article
« on: September 18, 2017, 07:49:53 pm »
PC Gamer did an awesome little article on our own Christopho and his excellent engine, Solarus! If you haven't seen it, I highly recommend the read!  :D

http://www.pcgamer.com/zeldas-most-dedicated-fan-game-developers-built-an-engine-anyone-can-use/

Great to see good work recognized, and we all know that Christopho has done some great work with Solarus!

2
Bugs & Feature requests / "normal" video mode is at 2x
« on: June 02, 2017, 04:31:33 am »
It appears, and the API confirms, that the "normal" video mode actually stretches the image by a factor of 2. Is it possible to just have the game run un-stretched? If there's not currently, I really think this should be added as a feature soon. Currently it would be pretty much impossible to use higher resolution resources when making games.

3
Development / Enemies not piling up
« on: May 26, 2017, 02:36:48 am »
In my game my enemies have a bad habit of "piling up" on each other, which makes it much easier to kill several of them with one hit. I was trying to avoid this with the code below, but I've now traced the code to some random crashes I've been having, so I need to take it out. I'd still like to find a way to not have the enemies pile up, and my guess is this was a stupid way in the first place and there's some obvious answer I've missed. So, my hope is the community can save me from my own stupidity again :)

 
Code: Text
  1. function enemy:on_collision_enemy(other_enemy, other_sprite, my_sprite)
  2.   if enemy:is_traversable() then
  3.     enemy:set_traversable(false)
  4.     sol.timer.start(200, function() enemy:set_traversable(true) end)
  5.   end
  6. end

4
Bugs & Feature requests / text surface fade_in and fade_out?
« on: April 07, 2017, 03:53:55 pm »
When I create a text surface, I can draw it near a custom entity by using draw_visual from on_post_draw, but when I try to apply a fade_in or fade_out to that surface (which the api says is general to all drawables) it doesn't seem to do anything. Is this a bug? Has anyone else tried this and succeeded?

5
Development / Equipment items as a class
« on: October 13, 2016, 03:08:59 pm »
I've been thinking about equipment items and if it would be possible to extend them to work more like a class in an RPG, so you could give custom stats and such to items. The ultimate extension would be to allow for a sort of crafting system where you could customize the item and it would be saved with the custom stats and sprite.

My thought is this should be possible by creating an item script for each type of item, say a sword or dagger or axe, then using variants to cover the different sprites. Then I'm wondering if it's possible to create a function in the item script that's called after item_create that passes and sets the stats and saves the item. The condition I see is that you'd still only be able to have one type of each item, or at least one variant, right?

Any other interesting ideas anyone has about extending the built in items? Or is this something that's better handled by ditching the built in items and using custom entities?

6
Development / Is there a way to tell when the map is scrolling?
« on: October 05, 2016, 03:25:21 pm »
I'd like a script to detect when the map is undergoing a scrolling transition - is that possible? This may be related to Solarus issue #989 (https://github.com/solarus-games/solarus/issues/989), but my screen overlay for map tone scrolls with the map when the hero hits the teletransporter. This is not the desired behavior since all of the lights that I've drawn on the surface move when they should stay stationary. My contingency plan is to disable drawing of those lights at the moment of screen scrolling, but I can't figure out if that's possible.

7
Bugs & Feature requests / Video/hardware acceleration
« on: August 22, 2016, 02:18:24 pm »
Is there a way from code or settings to disable video/hardware acceleration by default? It looks like you can do it from the launcher, but I'd like to not give the option and just disable it for my game by default if possible. Thanks!

8
Development / Failed to create software surface
« on: July 31, 2016, 01:52:18 am »
I'm using a modified version of Satoh's code that was posted at http://forum.solarus-games.org/index.php/topic,676.15.html to make the day/night system I had work with the new blend modes introduced in 1.5. It uses the map metatable to force a night overlay to drawn on all maps when it's night time. The problem is that after 10 to 15 minutes of game play at night (an overlay with blend modes being drawn) my game crashes with the fatal error "Failed to create software surface". I'm assuming that my code is just inefficient and the repeated re-drawing is causing memory issues, but I'm not sure how to improve it. Hopefully someone here will have an idea that can help me improve me code! And thanks for looking!

Code: Text
  1.   function map_metatable:on_draw(dst_surface)
  2.     local game = self:get_game()
  3.     local hour_of_day = (time_counter / 3000)
  4.     -- Put the night (or sunrise or sunset) overlay on any outdoor map if it's night time.
  5.     if (hour_of_day >= 19.6 or hour_of_day <= 7.4) and
  6.     (game:is_in_outside_world() or (self:get_world() == "dungeon_2" and self:get_id() == "20") or
  7.           (self:get_world() == "dungeon_2" and self:get_id() == "21") or (self:get_world() == "dungeon_2" and self:get_id() == "22")) then
  8.       local x,y = game:get_map():get_camera():get_position()
  9.       local w,h = game:get_map():get_camera():get_size()
  10.      
  11.       if draw_counter >= 15 then
  12.         shadow:clear()
  13.         if hour_of_day >= 19.6 and hour_of_day < 20 then
  14.           t[1] = 255; t[2] = 255; t[3] = 255
  15.           -- Dusk
  16.           if t[1] >= 2 then
  17.             t[1] = t[1] - 2 -- Red: Goal is 0 (fade to black, which is the same as fading in for this blend mode)
  18.           else
  19.             game:set_value("time_of_day", "night")
  20.             game:set_value("hour_of_day", 20)
  21.           end
  22.           if t[2] >= 3 then
  23.             t[2] = t[2] - 3 -- Green: Goal is 0
  24.           else
  25.             game:set_value("time_of_day", "night")
  26.             game:set_value("hour_of_day", 20)
  27.           end
  28.           if t[3] >= 4 then
  29.             t[3] = t[3] - 4 -- Blue: Goal is 0
  30.           else
  31.             game:set_value("time_of_day", "night")
  32.             game:set_value("hour_of_day", 20)
  33.           end
  34.           shadow:fill_color(t)
  35.         elseif hour_of_day >= 20 and hour_of_day <= 21 then
  36.           -- Sunset
  37.           if t[1] >= 32 then t[1] = t[1] - 3 end -- Red: Goal is 32 (from 255)
  38.           if t[2] >= 64 then t[2] = t[2] - 2 end -- Green: Goal is 64 (from 255)
  39.           if t[3] >= 128 then t[3] = t[3] - 1 end  -- Blue: Goal is 128 (from 255)
  40.           shadow:fill_color(t)
  41.         elseif hour_of_day >= 6 and hour_of_day <= 7 then
  42.           -- Sunrise
  43.           t[1] = (182*(hour_of_day-6))+18 -- Red: Goal is 182 (from 32)
  44.           t[2] = (62*(hour_of_day-6))+66 -- Green: Goal is 126 (from 64)
  45.           t[3] = (37*(1-(hour_of_day-6)))+87 -- Blue: Goal is 91 (from 128)
  46.           shadow:fill_color(t)
  47.         elseif hour_of_day > 7 and hour_of_day <= 7.4 then
  48.           -- Dawn
  49.           if t[1] <= 253 then
  50.             t[1] = t[1] + 2 -- Red: Goal is 255 (fade to white, which is the same as fading out for this blend mode)
  51.           else
  52.             game:set_value("time_of_day", "day")
  53.             game:set_value("hour_of_day", 7.5)
  54.           end
  55.           if t[2] <= 252 then
  56.             t[2] = t[2] + 3 -- Green: Goal is 255
  57.           else
  58.             game:set_value("time_of_day", "day")
  59.             game:set_value("hour_of_day", 7.5)
  60.           end
  61.           if t[3] <= 251 then
  62.             t[3] = t[3] + 4 -- Blue: Goal is 255
  63.           else
  64.             game:set_value("time_of_day", "day")
  65.             game:set_value("hour_of_day", 7.5)
  66.           end
  67.           shadow:fill_color(t)
  68.         else
  69.           -- Night
  70.           shadow:fill_color({32,64,128,255})
  71.           game:set_value("time_of_day", "night")
  72.         end
  73.        
  74.         lights:clear()
  75.         for e in game:get_map():get_entities("torch_") do
  76.           if e:get_sprite():get_animation() == "lit" and e:get_distance(game:get_hero()) <= 250 then
  77.             local xx,yy = e:get_position()
  78.             local sp = sol.sprite.create("entities/torch_light")
  79.             sp:set_blend_mode("blend")
  80.             sp:draw(lights, xx-32, yy-32)
  81.          end
  82.         end
  83.         for e in game:get_map():get_entities("night_") do
  84.           if e:is_enabled() and e:get_distance(game:get_hero()) <= 250 then
  85.             local xx,yy = e:get_position()
  86.             local sp = sol.sprite.create("entities/torch_light")
  87.             sp:set_blend_mode("blend")
  88.             sp:draw(lights, xx-24, yy-24)
  89.           end
  90.         end
  91.         for e in game:get_map():get_entities("lava_") do
  92.           if e:is_enabled() and e:get_distance(game:get_hero()) <= 250 then
  93.             local xx,yy = e:get_position()
  94.             local sp = sol.sprite.create("entities/torch_light_tile")
  95.             sp:set_blend_mode("blend")
  96.             sp:draw(lights, xx-8, yy-8)
  97.           end
  98.         end
  99.         for e in game:get_map():get_entities("warp_") do
  100.           if e:is_enabled() and e:get_distance(game:get_hero()) <= 200 then
  101.             local xx,yy = e:get_position()
  102.             local sp = sol.sprite.create("entities/torch_light_tile")
  103.             sp:set_blend_mode("blend")
  104.             sp:draw(lights, xx-16, yy-16)
  105.           end
  106.         end
  107.         for e in game:get_map():get_entities("poe") do
  108.           if e:is_enabled() and e:get_distance(game:get_hero()) <= 200 then
  109.             local xx,yy = e:get_position()
  110.             local sp = sol.sprite.create("entities/torch_light")
  111.             sp:set_blend_mode("blend")
  112.             sp:draw(lights, xx-32, yy-32)
  113.           end
  114.         end
  115.         -- Slowly drain magic when using lantern.
  116.         if magic_counter >= 50 then
  117.           game:remove_magic(1)
  118.           magic_counter = 0
  119.         end
  120.         if not game:is_suspended() then magic_counter = magic_counter + 1 end
  121.         draw_counter = 0
  122.       end
  123.       draw_counter = draw_counter + 1
  124.  
  125.       if game:has_item("lamp") and game:get_magic() > 0 then
  126.         local xx, yy = game:get_map():get_entity("hero"):get_position()
  127.         local sp = sol.sprite.create("entities/torch_light_hero")
  128.         sp:set_blend_mode("blend")
  129.         sp:draw(lights, xx-64, yy-68)
  130.       end
  131.  
  132.       lights:draw_region(x,y,w,h,shadow,x,y)
  133.       shadow:draw_region(x,y,w,h,dst_surface)
  134.     end
  135.   end

9
Bugs & Feature requests / Universal Windows App
« on: June 26, 2016, 08:40:46 pm »
I'm wondering if it would be possible in a future release (1.6?) to enable the Solarus engine as a Universal Windows App (UWA), which should allow games to be run on XBox One as well as Windows 10. It looks like it would require SDL version 2.0.4 (not sure what Solarus is using currently) and development in Visual Studio 2015. I just think it would be really cool to be able to play our games on XBox!

https://msdn.microsoft.com/en-us/library/hh875012.aspx

10
Development / Hole into teletransporter
« on: June 17, 2016, 04:42:16 pm »
In the past, I was able to place a teletransporter over a hole so that when the hero fell into the hole, he was transported to a new map. This no longer appears to work in 1.5dev - was this intentional? Is it possible to get the old behavior back?

Also Christopho, I was wondering if there was any estimate on the release of 1.5? I wanted to release the full version of my game soon, but wanted it to run on Solarus 1.5

Thanks!

11
Bugs & Feature requests / Flying enemies and walls
« on: April 14, 2016, 02:48:15 pm »
I have enemies where I've set enemy:set_obstacle_behavior("flying") and enemy:set_layer_independent_collisions(true) that are traversing walls that are set to block enemies - is this the expected behavior? Is there a way I can change this if it is?

12
I get multiple "libpng warning: iCCP: known incorrect sRGB profile" errors when displaying a menu. I'm guessing this is related to my pause_submenus.png file, but the error does not specify. I also haven't been able to manipulate the image to eliminate the error - I use gimp, and have searched the internet for solutions to no avail. Anyone have any insight into this?

In a future version, can the engine at least specify the file that's throwing the error?

13
Development / Expanding item_1 and item_2 commands
« on: February 09, 2016, 01:41:48 am »
I'm thinking it should be possible, probably using metatables, to expand the item_1 and item_2 commands and include item_3 and even item_4, for when more items are needed. But I'm wondering, does modifying the metatable of existing functions expand them or overwrite them? For example, would the code below work? If not, I could create a custom function similar to each of the built-in ones for each of the item slot functions.

Code: Lua
  1. local game_metatable = sol.main.get_metatable("game")
  2. function game_metatable:get_item_assigned(slot)
  3.   if slot == 2 then
  4.     return game:get_value("slot_2_item")
  5.   elseif slot == 3 then
  6.     return game:get_value("slot_3_item")
  7.   end
  8. end
  9.  

I'm also not 100% sure how the button mapping part would work. Is game:get/set_command_keyboard_binding() expandable or configurable?

Just brainstorming and wanted others' thoughts...

14
Development / Fading out overlay in different map
« on: December 13, 2015, 09:23:49 pm »
I have a surface that I'm using as an overlay, but it only exists on two maps. What I'd like to have happen is that when you enter one of the two maps, the overlay fades in (it's fog, so it's for effect) and then when you leave, it fades out. I can get the fade in to work just fine. I've tried to use the teletransport:on_activated event to call the fade_out, but so far I can't get it to work. I'm assuming the surface is automatically attached to the map because when you leave the map, the surface overlay immediately disappears. Is it possible to have this fade out instead?

15
Development / Menu help
« on: November 08, 2015, 12:47:47 am »
At the request of my brother, I've created a new warp menu for my game. Everything basically works, but I have a couple things that aren't working as well as they could, and I was hoping I could get some help.

1) The caption (the last part of on_draw) is not displaying, and I don't know why. This is based off of christopho's map submenu. I've checked that there is text in the variables (and there is) and I've tried to change the draw coordinates to no avail.

2) I can't figure out how to change the HUD icons. I've frozen the hero when the menu starts so you don't move around when trying to interact with the menu, but that's also frozen the HUD. I would like the attack icon to be "Confirm" (validate) and the pause icon to be "Back".

Code: Lua
  1. local game = ...
  2. local warp_menu = {}  -- The warp menu.
  3. local initial_point
  4. local initial_y = 10
  5. local index
  6.  
  7. -- Warp point name, Companion point, Warp to map, Coordinate x on minimap, Coordinate y on minimap, Name of warp.
  8. warp_points = {         -- Intentionally Global!
  9.   b1500 = { "b1501", "133", 166, 102, "Old Kasuto" },
  10.   b1501 = { "b1500", "46", 178, 220, "Hidden Village" },
  11.   b1502 = { "b1503", "51", 90, 194, "Kakariko City" },
  12.   b1503 = { "b1502", "11", 162, 372, "Ordon Village" },
  13.   b1504 = { "b1505", "72", 2, 228, "Gerudo Camp" },
  14.   b1505 = { "b1504", "66", 208, 178, "Goron City" },
  15.   b1506 = { "b1507", "82", 50, 346, "Beach" },
  16.   b1507 = { "b1506", "37", 218, 266, "Lost Woods" },
  17.   b1508 = { "b1509", "60", 4, 180, "Snowpeak" },
  18.   b1509 = { "b1508", "88", 15, 25, "Calatia Peaks" },
  19.   b1510 = { "b1511", "56", 160, 150, "Septen Heights" },
  20.   b1511 = { "b1510", "139", 178, 126, "Three Eye Rock" },
  21.   b1512 = { "b1513", "57", 184, 150, "Zora's Domain" },
  22.   b1513 = { "b1512", "93", 34, 40, "Rito Town" },
  23.   b1514 = { "b1515", "34", 120, 258, "Lake Hylia" },
  24.   b1515 = { "b1514", "13", 210, 365, "Floria Peninsula" }
  25. }
  26.  
  27. function game:on_warp_started(point)
  28.   initial_point = point
  29.   if not sol.menu.is_started(warp_menu) then sol.menu.start(game:get_map(), warp_menu) end
  30. end
  31.  
  32. function warp_menu:on_started()
  33.   game:get_map():get_hero():freeze()
  34.   self.hero_head_sprite = sol.sprite.create("menus/hero_head")
  35.   self.hero_head_sprite:set_animation("tunic" .. game:get_item("tunic"):get_variant())
  36.   self.background_surfaces = sol.surface.create("pause_submenus.png", true)
  37.   self.background_surfaces:set_opacity(192)
  38.   self.cursor_sprite = sol.sprite.create("menus/pause_cursor")
  39.   self.caption_text_1 = sol.text_surface.create{
  40.     horizontal_alignment = "center",
  41.     vertical_alignment = "middle",
  42.     font = "fixed",
  43.     font = menu_font,
  44.     font_size = menu_font_size,
  45.   }
  46.   self.caption_text_2 = sol.text_surface.create{
  47.     horizontal_alignment = "center",
  48.     vertical_alignment = "middle",
  49.     font = "fixed",
  50.     font = menu_font,
  51.     font_size = menu_font_size,
  52.   }
  53.  
  54.   -- Show a world map.
  55.   self.caption_text_1:set_text(sol.language.get_string("map.caption.warp"))
  56.   self.outside_world_minimap_size = { width = 225, height = 399 }
  57.   self.world_minimap_img = sol.surface.create("menus/warp_map.png")
  58.   self.world_minimap_movement = nil
  59.  
  60.   -- Initialize the cursor and scroll map to initial point.
  61.   for k, v in pairs(warp_points) do
  62.     if k == initial_point then
  63.       index = k
  64.       self:set_cursor_position(v[3], v[4])
  65.       if v[4] >= 133 then initial_y = v[4] - 133 + 10 else initial_y = 0 end
  66.       self.world_minimap_visible_xy = {x = 0, y = initial_y }
  67.     end
  68.   end
  69. end
  70.  
  71. function warp_menu:on_command_pressed(command)
  72.   if command == "left" or command == "up" then
  73.     self:previous_warp_point()
  74.     handled = true
  75.   elseif command == "right" or command == "down" then
  76.     self:next_warp_point()
  77.     handled = true
  78.   elseif command == "action" or command == "attack" then
  79.     for k, v in pairs(warp_points) do
  80.       if k == index and game:get_value(v[1]) then
  81.         game:start_dialog("warp.to_"..v[2], function(answer)
  82.           if answer == 1 then
  83.             sol.menu.stop(warp_menu)
  84.             game:get_map():get_hero():set_animation("ocarina")
  85.             sol.audio.play_sound("ocarina_wind")
  86.             game:get_map():get_entity("hero"):teleport(v[2], "ocarina_warp", "fade")
  87.           end
  88.         end)
  89.       end
  90.     end
  91.   elseif command == "pause" then
  92.     sol.menu.stop(warp_menu)
  93.   end
  94.  
  95.   return true
  96. end
  97.  
  98. function warp_menu:next_warp_point()
  99.   if index == "b1500" then index = "b1501"
  100.   elseif index == "b1501" then index = "b1502"
  101.   elseif index == "b1502" then index = "b1503"
  102.   elseif index == "b1503" then index = "b1504"
  103.   elseif index == "b1504" then index = "b1505"
  104.   elseif index == "b1505" then index = "b1506"
  105.   elseif index == "b1506" then index = "b1507"
  106.   elseif index == "b1507" then index = "b1508"
  107.   elseif index == "b1508" then index = "b1509"
  108.   elseif index == "b1509" then index = "b1510"
  109.   elseif index == "b1510" then index = "b1511"
  110.   elseif index == "b1511" then index = "b1512"
  111.   elseif index == "b1512" then index = "b1513"
  112.   elseif index == "b1513" then index = "b1514"
  113.   elseif index == "b1514" then index = "b1515"
  114.   elseif index == "b1515" then index = "b1500" end
  115.  
  116.   -- Move cursor and scroll map to new warp point.
  117.   for k, v in pairs(warp_points) do
  118.     if k == index and game:get_value(v[1]) then
  119.       self:set_cursor_position(v[3], v[4])
  120.       if v[4] >= 133 then initial_y = v[4] - 133 + 10 else initial_y = 0 end
  121.       self.world_minimap_visible_xy = {x = 0, y = initial_y }
  122.     end
  123.   end
  124. end
  125.  
  126. function warp_menu:previous_warp_point()
  127.   if index == "b1500" then index = "b1515"
  128.   elseif index == "b1501" then index = "b1500"
  129.   elseif index == "b1502" then index = "b1501"
  130.   elseif index == "b1503" then index = "b1502"
  131.   elseif index == "b1504" then index = "b1503"
  132.   elseif index == "b1505" then index = "b1504"
  133.   elseif index == "b1506" then index = "b1505"
  134.   elseif index == "b1507" then index = "b1506"
  135.   elseif index == "b1508" then index = "b1507"
  136.   elseif index == "b1509" then index = "b1508"
  137.   elseif index == "b1510" then index = "b1509"
  138.   elseif index == "b1511" then index = "b1510"
  139.   elseif index == "b1512" then index = "b1511"
  140.   elseif index == "b1513" then index = "b1512"
  141.   elseif index == "b1514" then index = "b1513"
  142.   elseif index == "b1515" then index = "b1514" end
  143.  
  144.   -- Move cursor and scroll map to new warp point.
  145.   for k, v in pairs(warp_points) do
  146.     if k == index and game:get_value(v[1]) then
  147.       self:set_cursor_position(v[3], v[4])
  148.       if v[4] >= 133 then initial_y = v[4] - 133 + 10 else initial_y = 0 end
  149.       self.world_minimap_visible_xy = {x = 0, y = initial_y }
  150.     end
  151.   end
  152. end
  153.  
  154. function warp_menu:set_cursor_position(x, y)
  155.   self.cursor_x = x
  156.   self.cursor_y = y
  157.   if y > 133 then
  158.     if y <399 then self.world_minimap_visible_xy.y = y - 51 else self.world_minimap_visible_xy.y = 399 end
  159.   end
  160.  
  161.   -- Update the caption text.
  162.   for k, v in pairs(warp_points) do
  163.     if k == initial_point then self.caption_text_2:set_text(sol.language.get_string(v[5])) end
  164.   end
  165. end
  166.  
  167. function warp_menu:on_draw(dst_surface)
  168.   -- Draw background.
  169.   local width, height = dst_surface:get_size()
  170.   self.background_surfaces:draw_region(320, 0, 320, 240, dst_surface, (width - 320) / 2, (height - 240) / 2)
  171.  
  172.   -- Draw the minimap.
  173.   self.world_minimap_img:draw_region(self.world_minimap_visible_xy.x, self.world_minimap_visible_xy.y, 255, 133, dst_surface, 48, 59)
  174.  
  175.   -- Draw the warp points.
  176.   for k, v in pairs(warp_points) do
  177.     if game:get_value(v[1]) then -- Only those that have been discovered are shown.
  178.       local point_visible_y = v[4] - self.world_minimap_visible_xy.y
  179.       if point_visible_y >= 10 and point_visible_y <= 133 then self.hero_head_sprite:draw(dst_surface, v[3] + 40, point_visible_y + 51) end
  180.     end
  181.   end
  182.  
  183.   -- Draw the cursor.
  184.   if self.cursor_y >= (10 + self.world_minimap_visible_xy.y) and self.cursor_y <= (133 + self.world_minimap_visible_xy.y) then
  185.     self.cursor_sprite:draw(dst_surface, self.cursor_x + 48, self.cursor_y + 55 - self.world_minimap_visible_xy.y)
  186.   end
  187.  
  188.   -- Draw caption (Not working currently for some reason).
  189.   local width, height = dst_surface:get_size()
  190.   self.caption_text_1:draw(dst_surface, width / 2, 200)
  191.   self.caption_text_2:draw(dst_surface, width / 2, 213)
  192. end
  193.  
  194. function warp_menu:on_finished()
  195.   game:get_map():get_hero():unfreeze()
  196. end
  197.  

Pages: [1] 2 3