Anyone steer me in the right direction?

Previous topic - Next topic

PeeJay

Hi guys!

Okie dokie, I'm looking to start coding again, but before I do, I'm wondering if anyone has any advice / code snippets to help with the following (bear in mind I have been out of the scene for a couple of years, so I'm more than a little rusty!)

Running my previous games on my shiny new huge monitor looks really shit, because of the stretching to full screen on a widescreen display (native resolution on this screen is 1920x1080). I know there was some discussion on solving this issue at http://www.glbasic.com/forum/index.php?topic=5006.msg38597#msg38597 which is a nice workaround, but as I understand it, it will only work with Windoze (thus negating the idea of having one source code for all platforms)

Has anyone resolved this problem yet, or have new GLB versions got swanky new features to address this issue?

Any help / pointers would be very much appreciated
www.peejays-remakes.co.uk
For games, remakes, and GL Basic Tutorials
Artificial Intelligence is no match for Natural Stupidity

Ian Price

I presume you want the game to run full screen and not in a window? Will your game be exclusively for Windows or are you planning to attack mobile/Android/iOs too?
I came. I saw. I played.

PeeJay

Well, previously I have released my efforts on both Windoze and Linux (making that routine only half useable) but since I now have an Android phone (albeit a basic Wildfire) then that is also a good option for me (with appropriate scaling, of course). I know I could run stuff in a window and immediately solve the problem, but I have always felt that games should really run full screen so you haven't got the distractions of icons ticking away all around! Also, it would be nice to be able to have borders which fill the screen without needing the monitor to scale the image (thus making graphics look a bit tacky - I have enough problem with getting graphics to look good as it is!)  =D
www.peejays-remakes.co.uk
For games, remakes, and GL Basic Tutorials
Artificial Intelligence is no match for Natural Stupidity

Ian Price

#3
There are several possible things you can do then - some you won't like!

1. Draw your game at full screen from the off - 1920x1080 is an awful lot of drawing though.

2. You might be better off sticking to a "standard" sized screen and using that as a virtual screen then display that centred in the middle of the full screen. So you'd do something like this (non-tested code)

Code (glbasic) Select

GLOBAL actual_x, actual_y
GLOBAL required_x, required_y

required_x=XXX
required_y=YYY

GETDESKTOPSIZE actual_x, actual_y

CREATESCREEN  1,999,required_x, required_y

WHILE TRUE

USESCREEN 1 - Virtual screen

// Draw all your stuff

USESCREEN -1 - Actual screen

DRAWSPRITE 999,(actual_x-required_x)/2,(actual_y-required_y)/2 //(or use POLYVECTORS)

SHOWSCREEN

WEND


That should (not tested, maths could be shonky) draw everything to the virtual screen (number 1 - sprite number 999) and then display it on the actual screen, centred.

If you use the POLYVECTOR method (which would be advisable), then you can scale down the actual screen to fit ANY device and it should be pretty smooth too, as well as fast. It will also do the opposite too, and allow you to scale up your screen (although scaling up alwayss looks worse than scaling down).

[EDIT] Made the main loop clearer.
I came. I saw. I played.

PeeJay

Thanks Ian, but therein lies the rub, as the bard would tell us. The big issue (no, not the rag sold by the great unwashed) is to establish what the current resolution of the monitor is before then doing any calculations, and for it to be cross platform compatible (unlike the windoze only calls from the previous thread)
www.peejays-remakes.co.uk
For games, remakes, and GL Basic Tutorials
Artificial Intelligence is no match for Natural Stupidity

kanonet

If i understand it right, thats what GETDESKTOPSIZE is for. If you use it before you got to fullscreen with SETSCREEN (so dont set fullscreen in the project options), you get the screensize of the current desktop, what should be the native resolution of the monitor. This should at least work on the big desktop platforms, dont know what you get with GETDESKTOPSIZE on mobile platforms, never developed on them.
But you still have the possibility to let the user decide what screensize he uses. I prefer keeping the ration, but i know others that prefer to get the full screen filed... so maybe its better just to ask the user.
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

PeeJay

Aha, thanks hugely kanonet - that's the command that will solve the problems in an instant - obviously something that has been added since I updated last (which was version 8.078!!!!)  Like I said, it's been a while .....  ;)
www.peejays-remakes.co.uk
For games, remakes, and GL Basic Tutorials
Artificial Intelligence is no match for Natural Stupidity

Ian Price

Yep, that's what it does and that's why it's in the code above :)
I came. I saw. I played.

PeeJay

Ah, I'm a muppet, aren't I? (hence the avatar!) Thanks to both of you guys - that should help out enormously. Looks as though my old projects won't compile now due to changes to commands :( so it looks as though the first tasks are to work out what has altered, and what's totally new. I've figured out the extra paramater on the PLAYMUSIC command (a welcome addition, that one!)
www.peejays-remakes.co.uk
For games, remakes, and GL Basic Tutorials
Artificial Intelligence is no match for Natural Stupidity

Ian Price

Your old programs may not need updating - I suspect it's just the new Explicit Declarations for your variables - Go into options and turn them off, or start using global/local variables in your code. :)
I came. I saw. I played.

PeeJay

I tried that, but doesn't seem to have solved the problem - error message at compile time on Manic Miner is thus:

*** Configuration: WIN32 ***
precompiling:
GPC - GLBasic Precompiler V.10.104 SN:f3546c43 - 3D, NET
Wordcount:2087 commands
compiling:
C:\DOCUME~1\PeeJay\LOCALS~1\Temp\glbasic\gpc_temp0.cpp: In function `DGInt __GLBASIC__::LoadHiScore()':
C:\DOCUME~1\PeeJay\LOCALS~1\Temp\glbasic\gpc_temp0.cpp:5595: error: invalid initialization of reference of type 'DGNat&' from expression of type 'DGInt'
C:/Program Files/GLBasic/Compiler/platform/Include/glb.h:1110: error: in passing argument 2 of `void __GLBASIC__::READWORD(DGNat, DGNat&)'
*** FATAL ERROR - Please post this output in the forum

The code is as follows:-

Code (glbasic) Select
FUNCTION LoadHiScore:

IF DOESFILEEXIST("hiscore.dat")
OPENFILE(0,"hiscore.dat",TRUE)
READWORD 0,hiscore
CLOSEFILE 0
ELSE
hiscore=0
ENDIF

ENDFUNCTION


The only variable used there is hiscore, which is declared globally (but I haven't used any explicit declaration on it as an integer) - guess I'm going to do quite a bit of tweaking under the hood ..... unless anyone has any other ideas?
www.peejays-remakes.co.uk
For games, remakes, and GL Basic Tutorials
Artificial Intelligence is no match for Natural Stupidity

Kitty Hello

READWORD expects an integer variable byref. So, do:
LOCAL hiscore% // integer with the %
READWORD 0, highscrore

Gary

Quote from: PeeJay on 2011-Dec-20

The code is as follows:-

Code (glbasic) Select
FUNCTION LoadHiScore:

IF DOESFILEEXIST("hiscore.dat")
OPENFILE(0,"hiscore.dat",TRUE)
READWORD 0,hiscore
CLOSEFILE 0
ELSE
hiscore=0
ENDIF

ENDFUNCTION



Aww dont tease like that, GLB manic Miner is one program I would love to see the source for, i.e. how to code a classic old school platformer with a modern language :)

Good to see you getting back into coding again though

PeeJay

Ah, maybe one day I will release the source, but to be honest, I am very tempted to use the engine again ...

As for getting back to coding, I have a rough idea for another "original" game (by "original" you can read "a mishmash of cliches thrown together under some premise of being unique - so kinda like every game you come across these days!) but it's going to be one step at a time - my first challenge being to come to terms with the screen handling and how best to do it (after all, if I have a 800x600 "game window" surrounded by a black border, whilst it will look best due to not having distortion on widescreen displays and not having doubling up of pixels on LCD/LED screens, it will just look like a postage stamp on HD systems ...... I need to give that some thought)

I wonder if someone could answer a quick query. On mobile devices (iPhone, iPad, Android) does GLB support input using the accelerometer? If so, is there an input system that could be employed on Windoze to emulate this for development and testing?

Also, and this is a cheeky one – I currently have to use a proxy to access the forum at work (thanks to the net nannies) and all the ones I tried are also blocked, so I made my own using Glype 1.2 which, whilst circumventing the company lockdown effectively, sadly does not allow me to post to the forum. Anyone know whether there is a trick I need to use in Glype to get round this? Or whether there is another alternative proxy script I could upload that would allow posting? Not that I would condone skiving off work to browse forums, you understand – oh no no no no no!  =D
www.peejays-remakes.co.uk
For games, remakes, and GL Basic Tutorials
Artificial Intelligence is no match for Natural Stupidity

PeeJay

Aha, found it in the help (for the iPhone at least) - accelerometer control by polling GEYJOYX(0), GETJOYY(0) and GETJOYZ(0). Could be interesting trying to do similar under Windoze, as I don't actually own a joystick  =D
www.peejays-remakes.co.uk
For games, remakes, and GL Basic Tutorials
Artificial Intelligence is no match for Natural Stupidity