Ren'Py Stellar Crossroads - Space Combat Simulator

Xavster

Well-Known Member
Game Developer
Mar 27, 2018
1,243
7,551
I think the mini game is largely done prior to implementation into the main game at a later stage. Feel free to take a look at the current implementation and code and make suggestions.

Would like the interface to show damage incurred during the round itself, however have been unable to determine a way of accomplishing this. Just can't get the screen to update whilst the game is running through the battle round definition.

A couple of things I will do when I get it implemented in the overall game:
- A range of different space backgrounds
- An animation prior to the battle start
- A summary screen at the conclusion of the battle
- Inclusion of larger ships and space stations (likely to enemy wing 2)
Whilst the mini game has the fleet creation / management and the battle all meshed into one. The actual game will have the battle play out separately. Hence you will send a specific fleet away on a mission. Once it reaches the destination, the battle will commence. Thus you won't be able to add ships or reconfigure wing assignments when it is on a mission.
 

gojira667

Member
Sep 9, 2019
252
229
Would like the interface to show damage incurred during the round itself, however have been unable to determine a way of accomplishing this. Just can't get the screen to update whilst the game is running through the battle round definition.
A single call screen likely works better with CDDs. Instead rewrite it some to use a loop approach similar to what Anne used above (label combat:).

Have your battle round button action [Call('battle_round')], a normal Ren'Py label. Convert at least the init & outer loop of def battle_round_player() to Ren'Py code. E.G.
Python:
label battle_round:
   python:
    attacks = 0
    hits = 0
    misses = 0
    battle_index += 1
    armour_damage = 0
    plating_damage = 0
    hull_damage = 0
    renpy.dynamic("fleet_row")
    fleet_row = 0
    fleet_rows = len(fleet01.player_wing)
   while fleet_rows:
        $ battle_round_player_row(fleet01.player_wing[fleet_row], fleet_row) #########
        $ fleet_row += 1
        $ enemy_row = 0
        python:
         for target_row in enemy.enemy_wing:
            for target in target_row.ships:
                if (target.hull.current_hp / target.hull.max_hp) < 0.1:
                    enemy.enemy_wing[enemy_row].remove_ship(target)
            enemy_row += 1
        $ enemy_ships = []
        python:
         for wing in enemy.enemy_wing:
            enemy_ships.extend(wing.ships)
        if len(enemy_ships) == 0:
            $ Show("player_wins")
            $ store.battle_win = "Player"
        $ fleet_rows -= 1
        $ renpy.pause(0.7) #Screen updates...
   $ battle_round_enemy() #unroll enemy outer loop here...
   return
You don't have permission to view the spoiler content. Log in or register now.
You may want to have screen sc_battle_hud which you show at the start with all the visuals and have screen sc_battle with the control buttons. Then a jump/label combo in start ala:
Python:
label start:
...
    show screen sc_battle_hud
label sc_battle_loop:
    call screen sc_battle
    if battle_win == 'No':
        jump sc_battle_loop
    #jump sc_battle_loop
    pause
    return
 
  • Like
Reactions: Xavster

Xavster

Well-Known Member
Game Developer
Mar 27, 2018
1,243
7,551
A single call screen likely works better with CDDs. Instead rewrite it some to use a loop approach similar to what Anne used above (label combat:).

Have your battle round button action [Call('battle_round')], a normal Ren'Py label. Convert at least the init & outer loop of def battle_round_player() to Ren'Py code. E.G.
Python:
label battle_round:
   python:
    attacks = 0
    hits = 0
    misses = 0
    battle_index += 1
    armour_damage = 0
    plating_damage = 0
    hull_damage = 0
    renpy.dynamic("fleet_row")
    fleet_row = 0
    fleet_rows = len(fleet01.player_wing)
   while fleet_rows:
        $ battle_round_player_row(fleet01.player_wing[fleet_row], fleet_row) #########
        $ fleet_row += 1
        $ enemy_row = 0
        python:
         for target_row in enemy.enemy_wing:
            for target in target_row.ships:
                if (target.hull.current_hp / target.hull.max_hp) < 0.1:
                    enemy.enemy_wing[enemy_row].remove_ship(target)
            enemy_row += 1
        $ enemy_ships = []
        python:
         for wing in enemy.enemy_wing:
            enemy_ships.extend(wing.ships)
        if len(enemy_ships) == 0:
            $ Show("player_wins")
            $ store.battle_win = "Player"
        $ fleet_rows -= 1
        $ renpy.pause(0.7) #Screen updates...
   $ battle_round_enemy() #unroll enemy outer loop here...
   return
You don't have permission to view the spoiler content. Log in or register now.
You may want to have screen sc_battle_hud which you show at the start with all the visuals and have screen sc_battle with the control buttons. Then a jump/label combo in start ala:
Python:
label start:
...
    show screen sc_battle_hud
label sc_battle_loop:
    call screen sc_battle
    if battle_win == 'No':
        jump sc_battle_loop
    #jump sc_battle_loop
    pause
    return
I tried the use of a label in order to do the indexing of the player attacks and tried show and call screen within that system. Whilst the combat system still functioned as before, the screen still did not show progressive updates. I may have done something wrong in my coding or there may be some other issue at play. As it is only a 'nice to have' and I can't work it out, I'm going to shelve it for now.

If someone wants to download and make the code changes and confirm it works. please feel free to do so and share your findings. To reiterate, the goal is to show the whittling away of the ship heath bars. Hence screen would update after every ship has completed its attack. Hence if there were 16 player ships and 14 enemy ships the screen update would occur 34 times each round. I was nominally thinking of about 0.1 second delay per ship, hence a round in the conditions above would play out over ~3.4 seconds.
 

gojira667

Member
Sep 9, 2019
252
229
I tried the use of a label in order to do the indexing of the player attacks and tried show and call screen within that system. Whilst the combat system still functioned as before, the screen still did not show progressive updates. I may have done something wrong in my coding or there may be some other issue at play.
If you are still using a single screen for everything than at the start of battle_round_player add
Python:
label battle_round_player:
   show screen sc_battle
And remove modal True from the screen itself. Also, I was testing this with renpy-8.0.3-sdk.
sc_scs.gif
If someone wants to download and make the code changes and confirm it works. please feel free to do so and share your findings. To reiterate, the goal is to show the whittling away of the ship heath bars. Hence screen would update after every ship has completed its attack. Hence if there were 16 player ships and 14 enemy ships the screen update would occur 34 times each round. I was nominally thinking of about 0.1 second delay per ship, hence a round in the conditions above would play out over ~3.4 seconds.
If you want per damage updates per ship attack then you need to move that second for loop to label battle_round:
Code:
    def battle_round_player_row(row, fleet_row):
            for ship in row.ships: #this one
Anyway this would be simpler if you have this as public ...
 
  • Like
Reactions: Xavster

Xavster

Well-Known Member
Game Developer
Mar 27, 2018
1,243
7,551
If you are still using a single screen for everything than at the start of battle_round_player add
Python:
label battle_round_player:
   show screen sc_battle
And remove modal True from the screen itself. Also, I was testing this with renpy-8.0.3-sdk.
View attachment 3056641
If you want per damage updates per ship attack then you need to move that second for loop to label battle_round:
Code:
    def battle_round_player_row(row, fleet_row):
            for ship in row.ships: #this one
Anyway this would be simpler if you have this as public ...
If you are able to upload the script.rpy and the battle.rpy files for the above changes it would be appreciated.
 
  • Like
Reactions: gojira667

gojira667

Member
Sep 9, 2019
252
229
If you are able to upload the script.rpy and the battle.rpy files for the above changes it would be appreciated.
I did a fresh download so to actually have it in VC. Turns out the changes are quite trivial when you aren't busy flailing around. Seems I forgot retest after removing modal True from the screen...

Tested with renpy-8.1.3-sdk (vastly improved VP9/VP8 video playback...*cough*).
 
  • Red Heart
Reactions: Xavster

Xavster

Well-Known Member
Game Developer
Mar 27, 2018
1,243
7,551
I did a fresh download so to actually have it in VC. Turns out the changes are quite trivial when you aren't busy flailing around. Seems I forgot retest after removing modal True from the screen...

Tested with renpy-8.1.3-sdk (vastly improved VP9/VP8 video playback...*cough*).
Works like a charm and the changes are way less than I was expecting.
 

Xavster

Well-Known Member
Game Developer
Mar 27, 2018
1,243
7,551
Just a heads up for those still following this thread, the space combat simulator has been incorporated into Stellar Crossroads v0.50. Please feel free to have a play and view the implementation of the code for which assistance was provided in this thread.
 
  • Like
Reactions: osanaiko