Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1] 2

Author Topic: Empi: Ruby Edition (v0.25)  (Read 5818 times)

Detros

  • Bay Watcher
    • View Profile
Empi: Ruby Edition (v0.25)
« on: April 12, 2016, 06:51:25 am »

While learning Ruby I have found there seems to be not much, if any, strategic game. So this should be Ruby version of Classic Empire, wargame from old times.
I thought some of you may be interested in game development in Ruby. So I will post occasional updates here.

I am using Ruby 1.9.3 with Gosu 0.10.5.
I have found so far Developing Games With Ruby as the most complete tutorial for game development in Gosu though most of time I use just generic Ruby documentation.
Have any of you ever tried writing games in Ruby? Would you have tips for that?

EDIT:
====================================
https://rubygems.org/gems/empi
See lower at reply #4 for how to run it
====================================


v1-v13
=========
- towns and armies
- functions none and sentry
- armor and movement points
- movement of units
- rudimentary terrain checking after move
- capturing of units
- turn and score counting
- commmand line and screen text output
- next avaiable unit / freeroam cursor

wishlist
=======
! no panning of map
! no destruction of units
! no building of units
! no victory conditions
! attacker always wins
! player playing both factions at once
! hardcoded starting scenario
! no fog of war
! no saving
! no loading
! no title screen
! no highscore screen
! no settings
! no sound, no music

(! thing to fix, !x fixed thing)
« Last Edit: September 12, 2021, 06:14:10 pm by Detros »
Logged
Beside other things, bay12forums is also the leader website in calculations of saguaro wood density.
(noted by jwoodward48df)

Detros

  • Bay Watcher
    • View Profile
Re: Empi: Ruby Edition
« Reply #1 on: April 12, 2016, 06:52:50 am »

Loading of units and terrain from file completed. Next is unit construction.

v15 dev
=========
- units referenced only from map
  fixed: no destruction of units
- loading of units from file
  fixed: no loading
- checks of loaded terrain tiles and units
- map stored as [row, column], not [xx, yy]

v14 dev
=========
- loading of terrain tiles from file
  fixed: hardcoded starting scenario
! hardcoded save file name
! hardcoded map size

TODO
===========
old wishes
! no panning of map
!x no destruction of units
! no building of units
! no victory conditions
! attacker always wins
! player playing both factions at once
!x hardcoded starting scenario
! no fog of war
! no saving
!x no loading
! no title screen
! no highscore screen
! no settings
! no sound, no music

new problems
! hardcoded save file name
! hardcoded map size

(! thing to fix, !x fixed thing)
Logged
Beside other things, bay12forums is also the leader website in calculations of saguaro wood density.
(noted by jwoodward48df)

sambojin

  • Bay Watcher
  • Three seconds to catsplosion and counting.......
    • View Profile
Re: Empi: Ruby Edition
« Reply #2 on: April 12, 2016, 08:31:13 pm »

Any d/l links for potential alpha testers? I'm kind of a fan of little strategy games, and usually don't care about graphics if the gameplay's solid.
Logged
It's a game. Have fun.

a1s

  • Bay Watcher
  • Torchlight Venturer
    • View Profile
Re: Empi: Ruby Edition
« Reply #3 on: April 14, 2016, 03:02:05 am »

Any d/l links for potential alpha testers? I'm kind of a fan of little strategy games, and usually don't care about graphics if the gameplay's solid.
This. I can also promise quality bug reports.
Logged
I tried to play chess but two of my opponents were playing competitive checkers as a third person walked in with Game of Thrones in hand confused cause they thought this was the book club.

Detros

  • Bay Watcher
    • View Profile
Re: Empi: Ruby Edition
« Reply #4 on: April 14, 2016, 07:56:33 pm »

Create new file, call it empitest.rb or something like that and put this content into it:
Code: [Select]
require 'empi'

Empi::GameWindow.initialize

Calling
Code: [Select]
ruby empitest.rb from command line in the folder you create that little file should run it. Press "h" for ingame help.

---

I have added building of new units. But because new units were told to note class Map where are they located, freshly created units in fact managed to entirely delete the town that created them. So I needed to store these new units somewhere. So I got to another thing that would I need to get to one way or another anyway: transporting of other units. One of core elements of gameplay should be managing of your transport ships because there rarely be dry way connecting all parts of map. So now towns put new units into their inventory (tested), units next to town can go through town (tested) and even those (in testing maps so far unused) ships should be able to carry other units (not tested yet).

I have never made a gem before. The biggest trouble was not in fact the building and uploading of gem itself but pathing. I have been always running the game from its main folder so "current folder" was the same as "game folder". But when I installed the game and tried to run it my relative links to images and saves files broke. Thus full absolute paths are used now. But figuring it took me from core 0.16 up to 0.16.6.


v16 dev
=========
- units on sentry duty say so when functioning
- neutral units can't have functions
- links to media and save files use full path
- towns build armies
  fixed: no building of units
! hardcoded unit type to be built
- units can transport other units
- newly built units are stored in town instead of map
  fixes: new units are saved in map instead of the towns that built them
! transported units are not drawn
! transported units show info of their transport instead when selected
! all units can capture and visit towns

file changes
--------------
map
  initialize() uses full paths to files
  all_units renamed to all_map_units() - Return only units directly on map
  +all_transported_units() - Return only units transported by other units
  +all_units() - Return both map units and transported units
  draw_units() draws only map units

unit
  +@cargo, @cargo_max
  +can_transport?() - Unit is able to both transport other units and currently has some space left
  set_function() checks for @faction == 0
  checking of movement separated from update()
  +check_movement() - Processes move of unit and takes care of its (un)loading or attack
  capture() makes newly captured towns start building

town
  initialize() uses full path to file
  +parts_built
  +@cargo_max set to 10

army
  initialize() uses full path to file

ship
  initialize() uses full path to file
  +@cargo_max set to 3

unitFunction
  +FUNCBUILD case in func!()
  FUNCSENTRY case in func!() sets "ret" even when unit keeps sentrying


TODO
===========
old wishes
! no panning of map
!x no destruction of units
!x no building of units
! no victory conditions
! attacker always wins
! player playing both factions at once
!x hardcoded starting scenario
! no fog of war
! no saving
!x no loading
! no title screen
! no highscore screen
! no settings
! no sound, no music

new problems
! hardcoded save file name
! hardcoded map size
! hardcoded unit type to be built
! transported units are not drawn
! transported units show info of their transport instead when selected
! all units can capture and visit towns

(! thing to fix, !x fixed thing)
Logged
Beside other things, bay12forums is also the leader website in calculations of saguaro wood density.
(noted by jwoodward48df)

Detros

  • Bay Watcher
    • View Profile
Re: Empi: Ruby Edition
« Reply #5 on: April 18, 2016, 07:26:43 am »

:o
Oh, already up to 125 downloads? But chm, why no response? Have any of you managed to run the game? Is that gem working for you?
Logged
Beside other things, bay12forums is also the leader website in calculations of saguaro wood density.
(noted by jwoodward48df)

a1s

  • Bay Watcher
  • Torchlight Venturer
    • View Profile
Re: Empi: Ruby Edition
« Reply #6 on: April 18, 2016, 07:30:21 am »

Could you make an .exe for the terminally lazy?
Logged
I tried to play chess but two of my opponents were playing competitive checkers as a third person walked in with Game of Thrones in hand confused cause they thought this was the book club.

Detros

  • Bay Watcher
    • View Profile
Re: Empi: Ruby Edition
« Reply #7 on: April 18, 2016, 10:26:21 am »

Could you make an .exe for the terminally lazy?
Ruby is an interpreted language so it needs its environment to run. But I have found there are several tools that should be able to pack the ruby code in such way that when you run it, it installs temporary Ruby, runs the program and deletes the installation. OCRA and so on. There seems to be multiple people talking about bugs and abandoned projects around there, though.

For installation of Ruby on Windows there is also Ruby Installer that should work via a setup wizard and and not a command line.
Logged
Beside other things, bay12forums is also the leader website in calculations of saguaro wood density.
(noted by jwoodward48df)

Detros

  • Bay Watcher
    • View Profile
Re: Empi: Ruby Edition (v0.17)
« Reply #8 on: April 19, 2016, 05:25:00 pm »

I have kept on separating parts of code to new classes but there are still few more planned. Object design must be had!
Transport ships were added to one of maps and now they generally work. If you load armies in and set them to sentry note you can't target them via freeroam cursor (for now) so you can't set them back to none. You need to get that ship next to some neutral or enemy units and wake those armies up that way. If you capture enemy town make sure there are no enemy units hiding inside as those are (for now) not affected by that capturing.

---

This can be used to run the game when you have installed multiple versions of one gem. If you leave it as it is is loads the last version. If you uncomment one of those first lines it loads given version.
Code: [Select]
# gem 'empi', '=0.16.6'
# gem 'empi', '=0.17'

require 'empi'
Save as "SOMENAME.rb" and run as "ruby SOMENAME.rb". Or other name :D .


v17 dev
=========
- selected map: m02
- terrain stuff separated to Tile class
! units are still stored via Map class instead of Tile one
! units are still accessed via Window class instead of Cursor one
- removed debug printout from Unit class
- moving transports don't leave their cargo behind
- capturing done only by armies
  fixed: all units can capture towns (armies visiting towns are left allowed for now)
- only towns can be captured, other units do battle
  fixed: battling units capture instead of damaging
! capturing town with units leaves those enemy units inside
! damaged units are destroyed
- printouts tweaked
  fixed: transported units show only info of their transport instead when selected
! transported units show in infopane info of their transport instead when selected
! destroyed transport ships don't give points for their lost cargo

file changes
--------------
empi.rb
  cursor prints out info() even for not moved units
  (say, when friend unit without avaiable cargo capacity was on the destination tile)
  added PROMPT to responding printouts

cursor.rb
  info() shows info of transported units too

map.rb
  TILE constants moved to tile.rb
  initialize() sets tile and leaves processing of loaded symbol to it
  tile() returns object of tile instead directly its terrain type
  +all_tiles - Return all tiles
  draw_tiles

unit.rb
  removed debug printout used for checking of units leaving towns
  added PROMPT to responding printouts
  check_movement() makes sure cargo is moved too
  check_movement() checks if moved unit has enough move points
  check_movement() print outs are more detailed
  tile_check() doesn't check terrain type for transported units
  info() print outs also max cargo capacity
  fixed comparing of functions in set_function()
  +can_capture?
  +can_be_captured?
  can_move() renamed to can_move?()
  reset_moves() renamed to reset_moves!()

army.rb
  can capture

town.rb
  can be captured
   
save/m02.esf
  +two ships, one for each faction

tile.rb

TODO
===============
old wishlist
! no panning of map
!x no destruction of units
!x no building of units
! no victory conditions
!x battling units capture instead of damaging
! attacker always wins
! player playing both factions at once
!x hardcoded starting scenario
! no fog of war
! no saving
!x no loading
! no title screen
! no highscore screen
! no settings
! no sound, no music

new problems
! hardcoded save file name
! hardcoded map size
! hardcoded unit type to be built
! transported units are not drawn
!x transported units show only info of their transport instead when selected
!x all units can capture and visit towns
! units are still stored via Map class instead of Tile one
! units are still accessed via Window class instead of Cursor one
! damaged units are destroyed
! transported units show in infopane info of their transport instead when selected
! capturing town with units leaves those enemy units inside

(! thing to fix, !x fixed thing)
Logged
Beside other things, bay12forums is also the leader website in calculations of saguaro wood density.
(noted by jwoodward48df)

sambojin

  • Bay Watcher
  • Three seconds to catsplosion and counting.......
    • View Profile
Re: Empi: Ruby Edition (v0.17)
« Reply #9 on: April 19, 2016, 06:01:29 pm »

Cool, it's all actually in .tar ball format, unencrypted, so we can find out what makes it work and offer suggestions. Just rename the file to .zip and let your archiver program work it out. It might be useful for you Detros for more input, but it's handy for me to learn stuff too. I've never touched Ruby language before.

Think of it as "helping". Or opening the game up to modding.


Still having a hard time getting it to run under Ruboto on Android, but I'll get there. The program really wasn't made for running ruby gems (or anything with Java dependencies) normally anyway, so it's cool. I should be able to dump in the correct files into the right paths. Maybe. I'll play around on my desktop pc soon, which will be a heap easier anyway.
« Last Edit: April 19, 2016, 06:22:55 pm by sambojin »
Logged
It's a game. Have fun.

Detros

  • Bay Watcher
    • View Profile
Re: Empi: Ruby Edition (v0.18)
« Reply #10 on: December 01, 2019, 05:23:35 am »

I got back to this after more than three years. This update is mostly to wrap up the changes that were waiting for deployment all those years. Parts of codes moved around, all keys should now be shown in help (though after all that time I do not even remember what was missing) and units getting loaded into transporters use all their left moves doing so. if you exit out of freeroaming (J) on an empty tile the cursor jumps back to the last selected unit.

In the meantime Imgur seems to have started distinguishing more between images and posts. I could not find a way how to edit description of uploaded file, it seems you now just need to make a post and do it there. Here you can see the game in progress: each side has capture extra town, ships are slowly moving in. Selected yellow one has one army inside, red one has two and was recently selected. Printouts show the same situation, with few extra debugging lines about "current unit" so that I check if cursor behaves properly.

v18 dev
=========
- help is now listing all keys
- help shown after the first load of new map
- units use all left moves when loaded, unless they are loaded into towns
- even units with 0 moves left show their moves in their info
- added "End of turn" marker
- added licensing/contact info also to this info file and not just to gem specs
- several exception handlers added to Cursor
- units stored in Tile class
  fixed: units are still stored via Map class instead of Tile one
- movement and function keys processed in Cursor, movement checked in Unit
  fixed: units are still accessed via Window class instead of Cursor one
- moving of cursor stores the current unit so it can possibly get moved (again)
- function setting of units separated to its own method
- autodisabling of freeroam mode on each end of turn moved to the start of next turn

newly found issues
--------------------
! help should be shown after each load of new map
! transported units can't get commands from freeroaming cursor
! transported units don't function properly, their transports secretly function instead of them
! unit info shown twice at the start of the first turn
! units which can't build can still have function set to build (though they do protest)

file changes
--------------
empi.rb
  help shown at the start of game
  "End of turn" marker
  removed calling of @map.draw_units
  removed search for next movable unit

map.rb
  all_map_units() uses indirect access via get_unit()
  get_unit(), set_unit() access given coordinates of @tiles
  draw_units() and @units removed

unit.rb
  removed processing of movement and function keys
  info() uses @moves_max > 0 instead of can_move()
  check_movement() sets @moves_left to 1 when unit is loaded so it then gets lowered to 0

cursor.rb
  switch_freeroam() renamed to switch_freeroam!()
  +move! - Move by given change of coordinates
  +to_next_unit! - Find next unit to target with cursor
  @unit
  +set_function_to_unit(func) - Tries to set function <func> to currently selected unit

tile.rb
  @unit

infopane.rb
  removed one space from score output

docu/Empi v18.png
docu/Empi v18 - printouts.png

current state
===============
old wishlist
! no panning of map
!x no destruction of units
!x no building of units
! no victory conditions
!x battling units capture instead of damaging
! attacker always wins
! player playing both factions at once
!x hardcoded starting scenario
! no fog of war
! no saving
!x no loading
! no title screen
! no highscore screen
! no settings
! no sound, no music

new problems
! hardcoded save file name
! hardcoded map size
! hardcoded unit type to be built
! transported units are never drawn
!x transported units show only info of their transport instead when selected
!x all units can capture and visit towns
!x units are still stored via Map class instead of Tile one
!x units are still accessed via Window class instead of Cursor one
! damaged units are destroyed
! transported units show in infopane info of their transport instead when selected
! capturing town with units leaves those enemy units inside
! help should be shown after each load of new map
! transported units can't get commands from freeroaming cursor
! transported units don't function properly, their transports secretly function instead of them
! unit info shown twice at the start of the first turn
! units which can't build can still have function set to build (though they do protest)

(! thing to fix, !x fixed thing)
Logged
Beside other things, bay12forums is also the leader website in calculations of saguaro wood density.
(noted by jwoodward48df)

Detros

  • Bay Watcher
    • View Profile
Re: Empi: Ruby Edition (v0.19)
« Reply #11 on: December 03, 2019, 07:43:43 pm »

Now I am using Ruby 2.5 and Gosu 0.14.5, not for specific new parts but just that they were the newest versions available after those years. In the meantime some graphic ways seem to have been deprecated, I will try to address this during next update. This one was mostly about bug fixing and preliminary work for setting of what do you want to build. Town and UnitFunction got new variables to store the desired project and to track its progress, player input will be a separate task as that will interrupt the current input flow. I will try not showing file changes here any more (but they can still be found in docu/info in the gem) and also probably start removing new problems which have already been fixed. Or start using some proper bug tracker if I am really getting back into this...

v19 dev
=========
- units which can't build will not only protest against such function but also not set it
  fixed: units which can't build can still have function set to build
- added link to the gem page to the header of this Info file
- defenders of capturable units need to be dealt with before it can be captured
  fixed: capturing town with units leaves those enemy units inside
- destroyed transporters first destroy their cargo
  fixed: destroyed transport ships don't give points for their lost cargo
- apparently fixed in v0.18 with storing of last unit in cursor
  fixed: transported units show in infopane info of their transport instead when selected
- cargo part of info shown even for empty transporters
- UnitFunction stores its unit
  fixed: transported units don't function properly, their transports secretly function instead of them
- preliminary work done on setting build projects
- towns say what their project and its progress are
- parts are first build and then checked so building process takes one less turn now
- captured towns have their build process reset
- reworded function parts of unit info

current state
===============
old wishlist
! no panning of map
!x no destruction of units
!x no building of units
! no victory conditions
!x battling units capture instead of damaging
! attacker always wins
! player playing both factions at once
!x hardcoded starting scenario
! no fog of war
! no saving
!x no loading
! no title screen
! no highscore screen
! no settings
! no sound, no music

new problems
! hardcoded save file name
! hardcoded map size
! hardcoded unit type to be built
! transported units are never drawn
!x transported units show only info of their transport instead when selected
!x all units can capture towns
!x all units can visit towns
!x units are still stored via Map class instead of Tile one
!x units are still accessed via Window class instead of Cursor one
!x capturing town with units leaves those enemy units inside
! damaged units are destroyed
!x transported units show in infopane info of their transport instead when selected
!x destroyed transport ships don't give points for their lost cargo
! help should be shown after each load of new map
! transported units can't get commands from freeroaming cursor
!x transported units don't function properly, their transports secretly function instead of them
! unit info shown twice at the start of the first turn
!x units which can't build can still have function set to build
! passing a Window to Image.from_text has been deprecated since Gosu 0.9
! Fontconfig error: failed reading config file
! no way to list cargo in loaded maps
! units loaded from tile can spawn on unsuitable terrain

(! thing to fix, !x fixed thing)
Logged
Beside other things, bay12forums is also the leader website in calculations of saguaro wood density.
(noted by jwoodward48df)

Detros

  • Bay Watcher
    • View Profile
Re: Empi: Ruby Edition (v0.20)
« Reply #12 on: January 25, 2020, 06:33:56 pm »

I have created a new repo in GitLab to get to another level. There you can find all the code and it comes with bug tracker included. I have even gone through my local archives and rebuild the history since the first version. That was quite an interesting adventure on itself, with opening issues only so that they can be closed again with a fix/feature update one uploads just few minutes later. You can find the summary of changes in the new CHANGELOG so there is no need to list them all here.

The rest of the old info file was moved into README. There one can now also find a  documentation on how to install Empi, how to control it and which gameplay rules are used. I am considering adding at least one more section with a dictionary of terms I am using here: unit function, moveable unit, transporter... Other than that, with all this documentation stuff I didn't want to start on something big but at least added support for numpad keys and fixed a few technical debt bugs.

Next goal is to finish setting of build projects of towns by player so that ships one can finally order some ships. That asks for a way to process some non-standard user input and should lead to new possibilities of UI, with multiple game states with different controls, e.g. title screen or confirmation of the closing of game window.
Logged
Beside other things, bay12forums is also the leader website in calculations of saguaro wood density.
(noted by jwoodward48df)

Detros

  • Bay Watcher
    • View Profile
Re: Empi: Ruby Edition (v0.21)
« Reply #13 on: February 13, 2020, 06:29:50 pm »

v21, 2020-02-13 (README, CHANGELOG)

The main GameWindow was split into part which shows the window and the gameplay part. This lead to creaton of separate game states, each with different control set, with current state stored in a form of a global variable in GameWindow, at least for now. Thanks to that towns can build also ships and player can select which build project should each town work on. One of the four Current imperfections listed in README was thus removed. Additionaly, closing the whole game now asks for confirmation so no more can one key press lead to unwanted losing of game in progress.

With game states in place, nearby versions will probably include ability to select starting scenario and more details stored in save files so that eventually there is a save and load ability. I would also like to get to start working on separating the factions so that player doesn't play for both of them at once and add some basic victory conditions. But first there needs to be a release mostly about bug clearing as this release lead to identifying quite a few of them.
Logged
Beside other things, bay12forums is also the leader website in calculations of saguaro wood density.
(noted by jwoodward48df)

Detros

  • Bay Watcher
    • View Profile
Re: Empi: Ruby Edition (v0.22.3)
« Reply #14 on: July 05, 2020, 07:58:22 am »

v22.3, 2020-07-05 (README, CHANGELOG)

This update concentrated on documentation and fixing of few things which could lead to crashes. One of the few additions was build progress which is now always shown in the build screen. It also means towns can safely temporary stop working on their project for a turn or two, to confuse the opponent. On the other side, to lower the possible confusion of all involved, ships can no longer be loaded into same-size ships like some water matryoshka dolls, now they fit only in towns or in (some future) bigger transporters.

README now includes list of units with both their stats and abilities. Several new issue labels were added so that one can see what area that issue is about (game mechanics, UI, documentation...). Files were distributed into folders but that lead to problems when building the gem as I forgot to update the list of folders with code in the gemspec file at first. So after 0.16.6 where I was building the gem for the first time, there is again a version with long version number.
Logged
Beside other things, bay12forums is also the leader website in calculations of saguaro wood density.
(noted by jwoodward48df)
Pages: [1] 2