Author |
Topic: Example program challenge (Read 3996 times) |
|
hellomike
Junior Member
member is offline


Gender: 
Posts: 55
|
 |
Re: Example program challenge
« Reply #10 on: Jan 17th, 2017, 7:25pm » |
|
Thanks for the reply. Of course, "RECTANGLE TO". Keep forgetting about its power.
OK, I will give it a try. Where should I post the beta for evaluation?
Mike
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 803
|
 |
Re: Example program challenge
« Reply #11 on: Jan 17th, 2017, 8:10pm » |
|
on Jan 17th, 2017, 7:25pm, hellomike wrote:| Where should I post the beta for evaluation? |
|
I really don't mind. If you have some private webspace (a small amount is often bundled with a broadband package) you can put it there. Or if you've got a cloud storage account (Dropbox, OneDrive, Google Drive, iCloud etc.) they all, I think, provide publicly-accessible spaces - and even if you haven't you can open one for free!
Wherever you choose to put it, just post the URL in a message here so that anybody who wants to can download it.
Richard.
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 803
|
 |
Re: Example program challenge
« Reply #12 on: Jan 18th, 2017, 08:19am » |
|
on Jan 17th, 2017, 7:25pm, hellomike wrote:| Of course, "RECTANGLE TO". Keep forgetting about its power. |
|
I should add that, because it involves 'reading back' from the screen, it shares with POINT and TINT that it is very slow in BBCSDL. If you are wanting to 'animate' a sprite that is easy to redraw (e.g. a BMP image) then you will probably find it faster to redraw it in the new position than to 'copy' it with RECTANGLE TO.
Richard.
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 803
|
 |
Re: Example program challenge
« Reply #13 on: Jan 21st, 2017, 9:45pm » |
|
on Jan 17th, 2017, 7:25pm, hellomike wrote:OK, I will give it a try. Where should I post the beta for evaluation? |
|
Any progress on this front? The next release of BBCSDL is due in only 10 days time so there's a degree of urgency.
For my own peace of mind can you confirm that there are no IPR issues surrounding this game? Obviously I cannot distribute with BBCSDL any program that may raise questions of legality.
Richard.
|
|
Logged
|
|
|
|
hellomike
Junior Member
member is offline


Gender: 
Posts: 55
|
 |
Re: Example program challenge
« Reply #14 on: Jan 23rd, 2017, 2:40pm » |
|
Richard,
Developing the graphical form for the game, I arrived at the infamous last 5% (taking 95% of the time).
Concerning licensing, as per the following Wikipedia link, the concept is free and open-source. "https://en.wikipedia.org/wiki/2048_(video_game)"
I uploaded the unfinished beta for the game to Dropbox. Its location is: https://www.dropbox.com/s/p8hfsq13m6vkn4w/2048beta.bbc?dl=0
Main concern to have this working with BBCSDL, is the font.
The original 2048 game uses open-source font "Clear Sans". I installed that in windows and then in BB4W, the display mimics the original game at https://gabrielecirulli.github.io/2048/ very close, although the score in not kept (yet) nor any animated sliding is implemented. To be SYS "GetTextExtentExPoint" independent, values are kept in the TW&() and TH&() arrays.
The font is at: https://www.dropbox.com/s/k8kyy0gt3zshk78/clearsans-1.00.zip?dl=0 In Windows, when this font isn't installed, the alternative chosen is okay-ish too but BBCSDL just states "No such font".
To overcome the font problem, I could delived a BMP file with the different squares in it and use the same technique as in "PacMan.bbc". However I'm not sure I then can make the deadline.
OK, well that's the current state.
Regards,
Mike
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 803
|
 |
Re: Example program challenge
« Reply #15 on: Jan 23rd, 2017, 6:17pm » |
|
on Jan 23rd, 2017, 2:40pm, hellomike wrote:| Main concern to have this working with BBCSDL, is the font. |
|
The fonts currently supplied with BBCSDL are:
DejaVuSans.ttf DejaVuSansMono.ttf FreeMono.ttf FreeSans.ttf FreeSerif.ttf
I would hope that one of those would be suitable. If not, I would be prepared to include another font but obviously it would need to be 'free' and not governed by licensing conditions that I cannot meet.
You can copy the font-selection code from any of the other examples supplied with BBCSDL to ensure compatibility. There should certainly be no need to resort to a bitmap.
Richard.
|
|
Logged
|
|
|
|
hellomike
Junior Member
member is offline


Gender: 
Posts: 55
|
 |
Re: Example program challenge
« Reply #16 on: Jan 24th, 2017, 08:04am » |
|
This is where I got the font from: https://01.org/clear-sans
It does state that it is free to use. To mimic the original gameplay as close as possible, including the font would help.
One of the BBCSDL font supplied might serve as an alternative, so I wouldn't mind having to add code similar to Code:IF (INKEY(-256) == &57) GUIFONT$="Clear Sans Bold" ELSE GUIFONT$="FreeSans"
However I can't seem to get it to work. In SDLIDE version 0.15a, I can change the display font without a problem (Options -> Set Font...) to e.g. FreeSans,Regular,18.
But when I run the following program I get a "No such font" error.
Code:
Mike
|
|
Logged
|
|
|
|
hellomike
Junior Member
member is offline


Gender: 
Posts: 55
|
 |
Re: Example program challenge
« Reply #17 on: Jan 24th, 2017, 08:14am » |
|
Oh wait.... Code: OSCLI "FONT """ + @lib$ + "DejaVuSansMono.ttf"", 18" PRINT "TEST"
OK, that works.
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 803
|
 |
Re: Example program challenge
« Reply #18 on: Jan 24th, 2017, 08:52am » |
|
on Jan 24th, 2017, 08:04am, hellomike wrote:| But when I run the following program I get a "No such font" error. |
|
As I've explained before, there is no standardised font repository (comparable with the Windows Fonts folder) across the range of Operating Systems supported by BBCSDL. So, unlike in Windows, BBC BASIC does not know where to 'look' for a font, if you simply specify it by name. Also, as far as I know, the other OSes do not have anything like Windows' 'font mapper' that can locate a font without you having to know its exact filename.
So in BBCSDL the *FONT command requires you to specify the full path and filename of the .ttf file, so that it knows what to look for and where to find it. To reiterate, you only need to look in any of the supplied example programs that change the font (and several do) to discover the code you need.
One day I hope that BBCSDL will have its own dedicated documentation which will cover differences of this sort, but I am absolutely determined not to write this myself! I have asked, and I will continue to ask, for other people to take on various aspects of the development of BBCSDL, and documentation is one of them. Because of my 'waning powers' I must focus my efforts on things that only I can do.
As far as the specific typeface that you mention is concerned, the zip file to which you linked (ClearSans) actually contains eight different TTF files, for various weights and italic etc. Would you say that there is a sufficient difference between that typeface and the ones that are already supplied with BBCSDL to justify the inclusion of another 2 Megabytes of files in the distribution?
I notice that ClearSans doesn't support Arabic or Hebrew alphabets. That's not necessarily serious, but I'm uneasy about adding font files to the BBCSDL distribution that aren't reasonably 'international'.
Richard.
|
|
Logged
|
|
|
|
hellomike
Junior Member
member is offline


Gender: 
Posts: 55
|
 |
Re: Example program challenge
« Reply #19 on: Jan 24th, 2017, 7:06pm » |
|
Since I have hardly any experience coding in BBCSDL, I indeed didn't know that the *FONT command required that.
By no means should you include the font just for the sake of this game.
As I mentioned before, using ClearSans just makes the game looks like a more exact clone than without. I added the "ClearSans-Bold.ttf" font to @lib$ myself, which size is 264K, not 2MB.
"2048" also works using the FreeSans.ttf supplied font. In that case, I will have to make slight changes to certain values in order for the characters to align correctly.
To the Dropbox cloud I uploaded a new beta. Apart from internal modifications, with the corrected *FONT statement it now works in BBCSDL and I have added the score to be displayed.
https://www.dropbox.com/s/p8hfsq13m6vkn4w/2048beta.bbc?dl=0
I hope you find it useful.
Mike
PS. I think, maybe I should add some kind of start screen mentioning its goal and how to play it.
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 803
|
 |
Re: Example program challenge
« Reply #20 on: Jan 24th, 2017, 7:32pm » |
|
on Jan 24th, 2017, 7:06pm, hellomike wrote:| I added the "ClearSans-Bold.ttf" font to @lib$ myself, which size is 264K, not 2MB. |
|
If you just want the bold variant, yes, but if it was to be decided that the ClearSans typeface has some advantage over the existing supplied set, justifying its inclusion, I would expect to provide the full set.
Quote:| In that case, I will have to make slight changes to certain values in order for the characters to align correctly. |
|
So long as you don't mind doing that I'll assume that's the way we'll proceed.
Quote: Thanks. The only obvious current issue is that it seems to require a keyboard (at least, if it can be driven using a mouse or touchscreen it isn't obvious how). As stated in the original requirements spec the program must "Be usable with a small touch screen, such as may be found on an Android phone or tablet".
But with that change it looks very promising.
Quote:| I think, maybe I should add some kind of start screen mentioning its goal and how to play it. |
|
That would be nice, but a lower priority than the mouse/touch interface and there's only a week left!
Richard.
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 803
|
 |
Re: Example program challenge
« Reply #21 on: Jan 25th, 2017, 10:29am » |
|
on Jan 24th, 2017, 7:32pm, Richard Russell wrote:| The only obvious current issue is that it seems to require a keyboard |
|
So I could do some testing on Android devices I used this code as a quick hack:
Code: Direction = INKEY(1) - 135 : REM Or "Direction = RND(4)" to simulate MOUSE X%, Y%, B% IF B% THEN X% -= WW/2 : Y% -= WH/2 CASE TRUE OF WHEN X%<Y% AND Y%<-X% Direction = 1 WHEN X%>Y% AND Y%>-X% Direction = 2 WHEN X%>Y% AND Y%<-X% Direction = 3 WHEN X%<Y% AND Y%>-X% Direction = 4 ENDCASE ENDIF Polling the mouse like that isn't ideal, because you can miss very short clicks, but it does the job and is easier than using ON MOUSE.
Richard.
|
|
Logged
|
|
|
|
hellomike
Junior Member
member is offline


Gender: 
Posts: 55
|
 |
Re: Example program challenge
« Reply #22 on: Jan 25th, 2017, 12:16pm » |
|
Wow, yes, that's fine. Indeed it now also works using the mouse although it is rather sensitive.
Adding this line of code before the ENDIF seems to solve that.
Code: ... REPEAT MOUSE X%, Y%, B% : UNTIL B% = 0 ENDIF
Would this hack also trap swiping on an Android phone or tablet? I have no idea or means of testing that.
Mike
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 803
|
 |
Re: Example program challenge
« Reply #23 on: Jan 25th, 2017, 1:03pm » |
|
on Jan 25th, 2017, 12:16pm, hellomike wrote:| Adding this line of code before the ENDIF seems to solve that. |
|
OK, but it's really adding a hack on top of a hack! It would be better to use ON MOUSE, which detects the click/tap event rather than polling the state. This solves both the failure to detect a short click and the over-sensitivity to a long click.
Quote:| Would this hack also trap swiping on an Android phone or tablet? |
|
I did wonder whether a 'swipe' would be more acceptable than a 'tap'; how do other versions work in that regard? If so, please feel free to make the necessary changes. As far as is possible, considering the short timescale, I would like the program to work in an 'optimum' fashion.
I see from the Wikipedia page that the original author is happy for people to create their own versions so long as they "add new, creative modifications to the game". Ending up with an inferior version is neither in the spirit of that desire, nor good for the reputation of BBC BASIC!
Quote:| I have no idea or means of testing that. |
|
You certainly have the means: swiping with a finger is no different from swiping with the mouse! If you really have no idea, can I suggest that calculating the direction and distance from where the mouse button is pressed to where it is released ought to give you the information you need.
The only touchscreen actions which you cannot test with a mouse are 'multi-touch' gestures such as a pinch or a two-fingered drag: obviously a mouse cannot be in two positions at once! But I doubt that you would be wanting to use such gestures in the 2048 program.
Richard.
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 803
|
 |
Re: Example program challenge
« Reply #24 on: Jan 25th, 2017, 2:11pm » |
|
on Jan 25th, 2017, 1:03pm, Richard Russell wrote:| I did wonder whether a 'swipe' would be more acceptable than a 'tap' |
|
I've now modified it for swiping using the method I described, and I think it is better.
Richard.
|
|
Logged
|
|
|
|
|