simple games

Game development specific discussions.
BasicCoder2
Posts: 3906
Joined: Jan 01, 2009 7:03
Location: Australia

simple games

Post by BasicCoder2 »

While searching the net for ideas and techniques for platform games I came across,
http://www.lessmilk.com/game/dark-blue/
So you don't need difficult to draw graphics and he also explains how he comes up with his ideas.
lizard
Posts: 440
Joined: Oct 17, 2017 11:35
Location: Germany

Re: simple games

Post by lizard »

This guy knows how it works: "Summary: use constraints, start right away, and keep iterating." I would ask him how much money he earns with it.

Mastership shows itself in constraints, that's what i found out myself. Like Carlos Santana. He plays a few tones and people are thinking : "Wow". He don't needs millions of of tones, dozens of guitars or an amp with full distortion and volume . And that's mastership of programming, too. You don't need a dozen libraries. Do it alone with FreeBASIC, make the best use of it and people are thinking: "Wow".

https://www.youtube.com/watch?v=DWO_eojWezg
MrSwiss
Posts: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: simple games

Post by MrSwiss »

lizard wrote:You don't need a dozen libraries. Do it alone with FreeBASIC, make the best use of it ...
Well, it is somewhat of a contradiction in itself because, some of the quoted libraries,
might be written in pure FB, too. (I've made some: latest SevenSegment static lib.)

But I agree in so far, as one or two usually suffice, plus maybe a include with "common"
defines, macros, formulas, randomizers, etc. ... e.g. my GFX_MATH.bi in Tips & Tricks.
(Basically, just a collection of stuff, I don't want to reinvent again, for every new program.)
lizard
Posts: 440
Joined: Oct 17, 2017 11:35
Location: Germany

Re: simple games

Post by lizard »

Somehow i was aware writing nonsense from the beginning, because many things are not available from pure FreeBASIC, like Sounds, .png support etc.

For a GUI i am experimenting with "Simple GUI", looks interesting. Menubar is missing, but it is pure FB. I feel it is an advantage to work with only one programming system.
BasicCoder2
Posts: 3906
Joined: Jan 01, 2009 7:03
Location: Australia

Re: simple games

Post by BasicCoder2 »

Libraries are a weakness with FreeBASIC because they need a community capable of keeping them up to date and to provide the .bi files required. This is a strength for the high level Python with its large active community. It makes more sense to me to use libraries instead of innate commands but they have to be easy to import and the .bi files up to date along with FreeBASIC examples of sufficient number to act as a tutorial for using the library.
MrSwiss
Posts: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: simple games

Post by MrSwiss »

BasicCoder2 wrote:Libraries are a weakness with FreeBASIC because they need a community capable of keeping them up to date and to provide the .bi files required.
Excuse me for saying so but, I don't at all, share your sentiments, regarding libraries.
(Which are, in any case only relevant, if the lib. written, uses non-FB coding language.)

On the contrary, one of FB's strengths is, that you can write any library, you may require,
yourself, either in FB or in any other "language of choice".
(I understand your negative attitude towards libraries, since you've never even attempted,
to get in any way "involved", with them! I've offered help, you declined, always!)


BTW: comparing FB with Python is a joke, because Python is a scripting language, whereas
FB is compiled code (binary)!
BasicCoder2
Posts: 3906
Joined: Jan 01, 2009 7:03
Location: Australia

Re: simple games

Post by BasicCoder2 »

MrSwiss wrote:... one of FB's strengths is, that you can write any library, you may require, yourself.
In theory yes, but in practice many people could not, they simply don't have the knowledge and skills required.

Perhaps I should have indicated clearly that I was referring to the casual not advanced programmer's ability to produce a working program.

Take a GUI for example. How easy it was to write a GUI interface with Visual BASIC!!

FreeBASIC has its place and compares well I think with C or a version of C++ but it really depends on what your goals are and how much time you have to implement them. The time I spent writing game writing tools would have probably been more productive learning to use Unity.

Here for example was an attempted start at an editor for the dark blue games.

Code: Select all

screenres 800,600,32
color rgb(0,0,0),rgb(255,255,255)
cls

dim shared as integer mx,my,mb

const TILEW = 32  'in pixels
const TILEH = 32
const MAPW = 60   '
const MAPH = 20   ' size of map in tiles

dim shared as ulong colors(0 to 5)
colors(0)=rgb(100,100,255)  'blank
colors(1)=rgb(255,255,255)  'walls
colors(2)=rgb(255,255,0)    'money
colors(3)=rgb(255,0,0)      'lava
colors(4)=rgb(0,0,0)        'player
dim shared as integer playerID  'flag if player has been placed
playerID = 0

dim shared as integer tileID 
tileID = 1

dim shared as integer WINW,WINH,WINX,WINY  'displayed area of bitmap

WINX = 0
WINY = 0
WINW = 640   
WINH = 384

dim shared as integer map32(MAPW,MAPH)
dim shared as string filename
filename = "XXX"

'hold whole display as bitmap
dim shared as any ptr DISPLAY
DISPLAY = imagecreate(MAPW*TILEW,MAPH*TILEH,rgb(100,100,255))

'holds whole display as bitmap with tiles reduced to pixel size
dim shared as any ptr DISPLAY2
DISPLAY2 = imagecreate(MAPW,MAPH,rgb(100,100,255))  'pixel per tile display

sub tileMapToBitMap(flag as integer)
    
    dim as integer tileID,x,y
    for j as integer = 0 to MAPH-1
        for i as integer = 0 to MAPW-1
            tileID = map32(i,j)
            line DISPLAY,(x*TILEW,y*TILEH)-step(TILEW-1,TILEH-1),colors(tileID),bf  'draw tile
            pset DISPLAY2,(x,y),colors(tileID)
        next i
    next j
    
    'grid over bitmap
    if flag = 0 then
        for j as integer = 0 to MAPH-1
            for i as integer = 0 to MAPW-1
                line DISPLAY,(i*TILEW,j*TILEH)-(i*TILEW+TILEW-1,j*TILEH+TILEH-1),rgb(127,127,127),b
            next i
        next j
    end if
    
end sub

sub update()
    screenlock()
    cls
    'draw tiles buttons
    line (300,400)-step(32,32),rgb(255,255,255),bf   'walls/floors
    line (300,400)-step(32,32),rgb(0,0,0),b
    line (332,400)-step(32,32),rgb(255,255,0),bf     'money
    line (332,400)-step(32,32),rgb(0,0,0),b
    line (364,400)-step(32,32),rgb(255,0,0),bf       'lava
    line (364,400)-step(32,32),rgb(0,0,0),b
    line (396,400)-step(32,32),rgb(0,0,0),bf         'player
    line (396,400)-step(32,32),rgb(0,0,0),b

    put (0,0),DISPLAY,(WINX,WINY)-(WINX+WINW-1,WINY+WINH-1),trans
    line(0,0)-step(WINW,WINH),rgb(255,0,0),b
    
    'draw tile display which can be edited with mouse

    'show position and size of display in whole of tile map
    line (190,417)-(MAPW+190,MAPH+417),rgb(100,100,255),bf  'clear background
    put (190,417),DISPLAY2,trans
    line (190,417)-(MAPW+190,MAPH+417),rgb(0,0,0),b
    line (190+WINX/TILEW,417+WINY/TILEH)-(190+WINX/TILEW+WINW/TILEW,417+WINY/TILEH+WINH/TILEH),rgb(255,0,0),b
    
    draw string (20,500),"Use arrow keys to scroll."
    draw string (20,532),"Left button to draw tiles, right mouse button to erase tiles."
    draw string (20,564),"Click color squares for wall, money, lava or player tile"
    screenunlock()
end sub

'create a basic DATA list
sub saveMap2(filename as string)
    Open filename  For Output As #1
    for j as integer = 0 to MAPH-1
        print #1,"DATA ";chr(34);
        for i as integer = 0 to MAPW-1
            if len(hex(map32(i,j)))< 2 then
                print #1,"0";
            end if
            print #1, hex(map32(i,j));
        next i
        print #1,chr(34)
    next j
    print #1,
    Close #1
end sub

sub saveMap(filename as string)
    Open filename  For Output As #1
    for j as integer = 0 to MAPH-1
        for i as integer = 0 to MAPW-1
            print #1, map32(i,j);
        next i
        print #1,
    next j
    Close #1
end sub

sub loadMap(filename as string)
    Open filename  For Input As #1
    for j as integer = 0 to MAPH-1
        for i as integer = 0 to MAPW-1
            input #1, map32(i,j)
        next i
    next j
    Close #1
end sub


'========================= MAIN ====================

update()

dim as string key
dim as integer ascKey
dim as integer x,y

loadMap(filename & ".txt")
tileMapToBitMap(0)

do
    key = inkey

    if asc(key)=255 then
        ascKey = asc(mid(key,2,1))

        'SCROLLS WINDOW
        
        if ascKey = 77 then
            if WINX < MAPW*TILEW - WINW then
                WINX = WINX + 8
            end if
        end if
        
        if ascKey = 75 then
            if WINX > 0 then
                WINX = WINX - 8
            end if
        end if
        
        if ascKey = 80 then
            if WINY < MAPH*TILEH - WINH then
                WINY = WINY + 8
            end if
        end if
        
        if ascKey = 72 then
            if WINY > 0 then
                WINY = WINY - 8
            end if
        end if
    end if
    
    getmouse mx,my,,mb
    
    if mb=1 then        
        'over display area
        if mx<640 and my<384 then
            x = (mx+WINX)\TILEW
            y = (my+WINY)\TILEH
            line DISPLAY,(x*TILEW,y*TILEH)-step(TILEW-1,TILEH-1),colors(tileID),bf  'draw tile
            pset DISPLAY2,(x,y),colors(tileID)
            map32(x,y)=tileID
        end if
        'over tiles?
        if mx>300 and mx<300+160 and my>400 and my<432 then
            tileID = (mx-300)\32+1
        end if
    end if
    
    if mb=2 then        
        'over display area
        if mx<640 and my<384 then
            x = (mx+WINX)\TILEW
            y = (my+WINY)\TILEH
            line DISPLAY,(x*TILEW,y*TILEH)-step(TILEW,TILEH),rgb(100,100,255),bf  'draw tile
            pset DISPLAY2,(x,y),rgb(100,100,255)
            map32(x,y)=0
        end if
    end if
    
    update()
    sleep 2
loop until multikey(&H01)

saveMap(filename & ".txt") 'save background as an array of tile id numbers
saveMap2(filename & ".bas") 'generate DATA statements of tile numbers for use in a program
Last edited by BasicCoder2 on Mar 04, 2018 4:43, edited 1 time in total.
MrSwiss
Posts: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: simple games

Post by MrSwiss »

BasicCoder2 wrote:In theory yes, but in practice many people could not, they simply don't have the knowledge and skills required.
As usual, you are referring to yourself only, the remainder is camouflage.

You don't seem to see, where your real problem is situated.
I'll tell you straight: your unwillingness, to learn anything new (since QB, I guess).

Example: your just posted code, containing uncountable "shared" variables, arrays etc.
(I happen to know for sure, that you can do better, if only you wanted! In particular:
procedures with parameters, instead of all that shared nonsense!)
BasicCoder2
Posts: 3906
Joined: Jan 01, 2009 7:03
Location: Australia

Re: simple games

Post by BasicCoder2 »

MrSwiss wrote:I'll tell you straight: your unwillingness, to learn anything new (since QB, I guess).
Actually I never really used QB much. Back in those days it was all Assembler until someone put me onto Turbo C.
For the last few months I have spent a lot of time learning new things I don't write about here and with regards to programming it is mainly learning to be better at programming with Python because it and C is used a lot in the electronic projects that interest me. The code you were critical of was just a tweak of something I wrote some time ago as for a moment I thought there was some interest in game programming. I drop into this forum now and then while on the computer as a bit of nostalgia for the years I spent using FB to see if anything interesting or exciting is happening.
MrSwiss
Posts: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: simple games

Post by MrSwiss »

@BasicCoder2,

just let me make below (apparently, difficult to comprehend, remark), cristal clear to you:
MrSwiss ... wrote:I'll tell you straight: your unwillingness, to learn anything new (since QB, I guess). <-- old
modified, for clarity's sake:
MrSwiss wrote:I'll tell you straight: your unwillingness, to learn anything new in FreeBASIC (since QB, I guess). <-- new
FreeBASIC is the one and only language of interest, in this forum, which you seem to
permanently and conveniently, to forget.
Main point of critique, about your code samples is "antiquated/outdated coding style".
(even in FreeBASIC, nowadays ...)

I don't give a hoot about what you do, elsewhere / with other languages ...
BasicCoder2
Posts: 3906
Joined: Jan 01, 2009 7:03
Location: Australia

Re: simple games

Post by BasicCoder2 »

MrSwiss wrote:FreeBASIC is the one and only language of interest, in this forum, which you seem to permanently and conveniently, to forget.
How about the inline assembler?
My response wasn't about other languages it was about your derogatory attack saying I had an unwillingness, to learn anything new just because I didn't dedicate more time to learning more about FreeBASIC. It is simply a incorrect statement to say I forget the purpose of the forum. By all means attack my code but I would suggest your personal attacks show poor form and are not part of talking about the language.
MrSwiss
Posts: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: simple games

Post by MrSwiss »

BasicCoder2 wrote:How about the inline assembler?
Part of the language, but incomatible (somewhat at least), with a "stand alone Assembler",
like: TASM/MASM/NASM e.t.c. (sorry, no points made).
BasicCoder2 wrote:By all means attack my code but I would suggest your personal attacks show poor form and are not part of talking about the language.
Coding style, happens to be a part, of learning/using (any) language. You are teaching
noobs/beginners, what can only be be called: bad habits! Those are later on, when trying
to advance oneself, a massive hindrance! Since, one has to rid oneself of them first!

Why do I say so?
I've started, by using your stuff and, this cost me dearly (far more time, than learning it
correctly, the first time around), later in the process of learning, more advanced
language constructs and/or techniques!


Bottom line is: please refrain fom posting such "oldfashioned" code, in future. Thanks.

Btw: how can this be "not personal"? (Btw: Not the first time, I'm writing this, actually!)
BasicCoder2
Posts: 3906
Joined: Jan 01, 2009 7:03
Location: Australia

Re: simple games

Post by BasicCoder2 »

MrSwiss wrote:Bottom line is: please refrain from posting such "old fashioned" code, in future. Thanks.
Essentially you are saying don't post code. Regardless of what you believe, it was the best I could do given the time and academic limitations I have to indulge my interest. The dilemma for me is if I hadn't posted my old fashioned code I would not have received any help with my programming projects or been able to exchange ideas with others.
MrSwiss
Posts: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: simple games

Post by MrSwiss »

Essentially you are saying don't post code.
No, it is by far not the same, as: "don't post oldfashioned code".

Referring to: using available techniques/constructs, as current FreeBASIC permits, instead of:
code, as written 10 years ago (causing all the mentioned problems!).
FreeBASIC has advanced by now, far beyond its starting point: QB, in 2005!
BasicCoder2 wrote:... given the time and academic limitations I have to indulge my interest.
Nope, yet another "smoke-screen", to hide behind (you seem to just love, to do that).

If you, instead of switching "languages" whenever you hit some resistance, would have stayed
with FB, and worked the problems out ... (and, advanced yourself, in the process!).
(IMHO, just a tactical choice, that didn't work out, in the long run!)
BasicCoder2
Posts: 3906
Joined: Jan 01, 2009 7:03
Location: Australia

Re: simple games

Post by BasicCoder2 »

MrSwiss wrote:
Essentially you are saying don't post code.
No, it is by far not the same, as "don't post oldfashioned code".
Old fashioned code is what I write so it does amount to saying don't post old fashioned code.
FreeBASIC has advanced by now, far beyond its starting point: QB, in 2005!
And far beyond what I use. I honestly find the advanced coding techniques most of the posters post now as unreadable.
If you, instead of switching "languages" whenever you hit some resistance, would have stayed with FB, and worked the problems out ... (and, advanced yourself, in the process!). (IMHO)
The same could have been said with regards to C++. The little I knew about C++ was sufficient for my needs. I have no motivation to become an expert in C++ with its templates and iterators or whatever. I took on FreeBASIC because I found the "old fashioned" version easy to read and understand and it came with innate graphic commands. At the time I was struggling getting SDL to work with DevC++. I haven't switched to Python as a FreeBASIC replacement it just happens to be the language that others are using in the projects that interest me so I really have no choice.
Post Reply