The island - An RTS game

User projects written in or related to FreeBASIC.
BasicCoder2
Posts: 3245
Joined: Jan 01, 2009 7:03

Re: The island - An RTS game

Postby BasicCoder2 » Jul 12, 2018 20:45

It's started a few years ago as a Game Maker project, but the result was unplayable because of its slowness.

I wonder why?

I had played with making a FreeBASIC version of the RPG maker.
https://www.rpgmakerweb.com/
As I wrote earlier although you use isometric images your game plan is essentially 2D and indeed the paths are 100% 2D to look at.
This is not a big issue because as I also mentioned changing to a real isometric display isn't hard particularly if you are already using isometric images rather than the 2D images as used in rgp maker as the mechanics of the game code is essentially identical.

Is the Timer function the solving to this question in FreeBasic?

Probably. My main loop usually look like this.

Code: Select all

Dim Start As Double
Start = Timer
Do
    if (Timer-start) > 0.05 then  'every 0.05 seconds
        start = Timer             'reset counter
        'get user input
        'update database of game
        'display game
    end if
    Sleep 1, 1
Loop Until GameOver

On my computer your characters move too fast. Another factor is how many pixels the character moves per cycle.

I would very much like to know why FBIDE should produce the closing glitch after all it is just the editor not the compiler.
I don't think any of my code has had the closing glitch.
Last edited by BasicCoder2 on Jul 14, 2018 22:59, edited 1 time in total.
badidea
Posts: 915
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: The island - An RTS game

Postby badidea » Jul 12, 2018 22:07

ITomi wrote:Perhaps. But I can't really compare to other similar FB games, because I don't know so much.

I can't run the executable (because of linux here) or compile (because of missing linux fmod lib), so I cannot judge how much functionality is in the game now. But if I look at your coding style, I does not look very efficient. I see a lot of almost identical code. Indentation 15 levels deep, quite unusual. As I cannot read Hungarian, it is hard (for me) to figure out what happens where. I am a bit afraid that the game you are trying to make will soon get too complicated for your coding style. I could be wrong however.

ITomi wrote:For example, on a slower computer I should use bigger speed value to a unit to move to achieve the same move than on a modern computer - but it's impossible, because I don't know everybody's computer system in advance. Is the Timer function the solving to this question in FreeBasic?

Solutions I can think of:
A) Limit the frame rate to e.g. 30 Hz. Let objects move a fixed amount of pixels per frame. Make sure 30 Hz is possible on a slow system.
B) Separate graphics update loop (variable rate) from game update loop (fixed rate)
C) Variable frame rate / game update loop. Let objects move a (distance / second) * time_step. Where time_step is determined each loop.
ITomi
Posts: 110
Joined: Jul 31, 2015 11:23
Location: Hungary

Re: The island - An RTS game

Postby ITomi » Jul 13, 2018 8:31

- "It's started a few years ago as a Game Maker project, but the result was unplayable because of its slowness."
- "I wonder why?"

I don't know what was wrong with it, after all I built the code up reasonable, but the game produced 16-18 fps on average. Then I decided, I attempt make it in FreeBasic and miraculously the result was much better than in GM, mainly in respect of speed. Although it is made on the basis of GM version (I can send you the .gmd if you wish).
Thank you for your tips about Timer. I also thought similar solution as badidea's C point: somehow queried the fps of the system in the game and on the basis of this value move the units with some pixels. Although seems to be good the solution that you do in main loop of your programs with "Timer-start" method; I will try it in my next FB game, which is a little first person shooter.

P.S.: this is the exit code when I run the game with FBide and closes: -1073740940
SARG
Posts: 857
Joined: May 27, 2005 7:15
Location: FRANCE

Re: The island - An RTS game

Postby SARG » Jul 13, 2018 11:44

Hi ITomi
Put the -exx option when compiling to trap some reasons of crash (null pointer, out of bound,...)
ITomi
Posts: 110
Joined: Jul 31, 2015 11:23
Location: Hungary

Re: The island - An RTS game

Postby ITomi » Jul 13, 2018 16:33

Hello SARG!

I just now doing that. I found an error in the "kepbetolt.kbt" file, where I had to change number 4 to 2 in the loops from line 390 to line 425 ( for i as ubyte=1 to 2 ) and rewrite the array index above ( dim shared emberdolg(7,0 to 1) as any ptr ).
Now I correcting the errors derive from that (a lot of arrays out of theirs bounds), but I don't understand, what is wrong with this (line 7579, in English):
building1(numofbuildings1).exists=1 : building1(numofbuildings1).xplace= ...
redim preserve building1(numofbuildings1) : numofbuildings1+=1

although the initial value of numofbuildings1 variable is 0 and I get "out of bounds array access" error message yet. Maybe I use redim preserve at wrong place?
BasicCoder2
Posts: 3245
Joined: Jan 01, 2009 7:03

Re: The island - An RTS game

Postby BasicCoder2 » Jul 13, 2018 21:12

ITomi wrote: I will try it in my next FB game, which is a little first person shooter.

So no more work on The Island?
I had toyed with the idea of reproducing your game using my own coding.
I spent some time trying to track down why it suddenly stops working but without success.
Another glitch is when making a path the path tile does not always click exactly in place.
Image
ITomi
Posts: 110
Joined: Jul 31, 2015 11:23
Location: Hungary

Re: The island - An RTS game

Postby ITomi » Jul 14, 2018 12:23

"So no more work on The Island?"

On the contrary, after all I just now find the errors with -exx option. That FPS will be totally different game, but first I try to correct the glitches of the RTS.

"I had toyed with the idea of reproducing your game using my own coding."

You may use from my games what you wish. I will help you with pleasure, if you wish. E.g. what is what in the source code.

"Another glitch is when making a path the path tile does not always click exactly in place."

Yes, it's sometimes happen. In this case you need to set the road precisely. This is the piece of code (8388-8422 lines) that set the road and buildings to proper places:

Code: Select all

herex=viewx+mousex : herey=viewy+mousey
       
        (...)
        if (herex mod 32<>0) and (herey mod 32<>0) then
            if frac(herex/32)>=0.5 then
                while not(herex mod 32=0)
                    herex+=1
                wend
            else
                while not(herex mod 32=0)
                    herex-=1
                wend
            end if
            if frac(herey/32)>=0.5 then
                while not(herey mod 32=0)
                    herey+=1
                wend
            else
                while not(herey mod 32=0)
                    herey-=1
                wend
            end if
        end if
       
        herex=herex-viewx : herey=herey-viewy
        put (herex,herey),building.itssprite,pset
        herex=herex+viewx : herey=herey+viewy
ITomi
Posts: 110
Joined: Jul 31, 2015 11:23
Location: Hungary

Re: The island - An RTS game

Postby ITomi » Jul 15, 2018 14:29

Hello everybody!

Here is the game, without errors. At least it works correctly on my computer. The URL already known:
http://www.programozzunk.ucoz.hu/fbjatekok/sziget.zip

Enjoy! :-)
BasicCoder2
Posts: 3245
Joined: Jan 01, 2009 7:03

Re: The island - An RTS game

Postby BasicCoder2 » Jul 16, 2018 22:34

This is clearly a very simplified version of such games. As I haven't played Settlers or any of the other similar games a full explanation of how to play your simplified version would be helpful.

So I get you make paths and place buildings next to the path. Then a little guy appears, hammers away and then vanishes. Then a blue guy comes along and burns the place down while any tower rains arrows down onto him. What else can the game do?

I tried to get some idea what they do by looking for tutorials for the Settlers game.
I found this utube description interesting however I could not figure out how to play an online version of Settlers so clearly a manual is required. For example with the online game I couldn't even make the paths connect so it is far from a set of intuitive actions.
https://www.youtube.com/watch?v=927naY2huCw
I see Settlers 2 is where you got your intro image.
ITomi
Posts: 110
Joined: Jul 31, 2015 11:23
Location: Hungary

Re: The island - An RTS game

Postby ITomi » Jul 17, 2018 12:44

Hello BasicCoder2!

I hope, you didn't run into serious glitches in the game.
Its goal to annihilate all the other units and buildings on the island. If you find it too hard, try to build first a barrack ("Laktanya") and train warriors from it, just click on a barrack and the icon of the warrior. Organize the defence of your settlement.
The little guys with hammer do their works automatically, but the warriors go to the place what you give to them by mouse clicking.
Otherwise The settlers 2 is my favourite RTS, but I have derive ideas from my other favourite: Warcraft.
https://www.youtube.com/watch?v=_UnGOuSWsl0&t=0s&list=PL8EEB4A96283FB8CF&index=2
BasicCoder2
Posts: 3245
Joined: Jan 01, 2009 7:03

Re: The island - An RTS game

Postby BasicCoder2 » Jul 21, 2018 7:38

My main attraction to this kind of program was the idea of writing a program where the characters lived their own lives without a player intervention.
I wouldn't have the time or patience to play a full game of Settlers or Warcraft.
I got a bit sick of the "Yes my Lord" while watching the utube demo.
ITomi
Posts: 110
Joined: Jul 31, 2015 11:23
Location: Hungary

Re: The island - An RTS game

Postby ITomi » Jul 21, 2018 9:15

Unfortunately I also have no time to play with these games, but since I started to programming, I realized that making games and other programs are much better than just play.
Programming is my main gratification. And it seems I have grew up - unfortunately: I would like be forever young. :-)

Return to “Projects”

Who is online

Users browsing this forum: No registered users and 1 guest