Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - kamakazieturtle

Pages: [1] 2
1
GLBasic - en / Window Maximize Button
« on: 2013-Sep-29 »
      This code enables the maximize button, as well as scaling, to a "Windowed Mode" window on the "Windows OS." It will add an ".ini" file to your programs directory to store all necessary data, such as restoring the window to the last known size, and maximizing the window on program start. The code is not perfect, there are a few workarounds I'd like to eliminate. Anyone who would like to help test this out on different versions of Windows, it would be much appreciated. The best way to test is to make an image the size of your desktop and draw it in the main loop. Okay, the only thing I would like to update in the future is the buffer being refreshed during scaling, but I'm happy with it for now.

                                                                                                                                                                   WARNING!
                                                                                                                               Your program must support changes to window resolution!

Main File:
Code: (glbasic) [Select]
// ---------------------------------------------- //
// Project: Window Maximize Button\Window Scaling //
// File: Main.gbas                                //
// Start: Sunday, September 28, 2014              //
// IDE Version: 10.283                            //
// ---------------------------------------------- //

StartUp()

Main:
CLEARSCREEN

Update()

SHOWSCREEN
GOTO Main

SUB GLB_ON_QUIT:
INIPUT "Window","X","("+Window.X+")"
INIPUT "Window","Y","("+Window.Y+")"
INIPUT "Window","Width",Window.Width
INIPUT "Window","Height",Window.Height
INIPUT "Window","Mode",Window.Mode
INIPUT "Window","Style$",Window.Style$
INIPUT "Gui","Width",Gui.Width
INIPUT "Gui","Height",Gui.Height
INIPUT "Gui","Mode",ISFULLSCREEN()
ENDSUB

Source File: Add to program in the files tab, on the right-hand side of the IDE.
Code: (glbasic) [Select]
// ---------------------------------------------- //
// Project: Window Maximize Button\Window Scaling //
// File: Inine.gbas                               //
// Start: Sunday, September 28, 2014              //
// IDE Version: 10.283                            //
// ---------------------------------------------- //

GLOBAL DesktopWidth,DesktopHeight

TYPE WindowType
X
Y
Width
Height
Mode
Style$
ENDTYPE

GLOBAL Window AS WindowType

TYPE GuiType
X
Y
Width
Height
PrevX
PrevY
PrevWidth
PrevHeight
Mode
ENDTYPE

GLOBAL Gui AS GuiType

INLINE
}
struct RECT{int Left,Top,Right,Bottom;};

extern "C"
{
int __stdcall GetWindowLongA(void*, int);
int __stdcall SetWindowLongA(void*, int, int);
int __stdcall SetWindowPos(void*, int, int, int, int, int, int);
int __stdcall GetWindowRect(void*, void*);
const int Style=0;
}

#define WS_SIZEBOX       0x00040000L
#define WS_MAXIMIZEBOX   0x00010000L
#define WS_MAXIMIZE         0x01000000L
#define SWP_FRAMECHANGED    0x0020
#define SWP_SHOWWINDOW      0x0040
#define SWP_NOMOVE          0x0002
#define GWL_STYLE           (-16)

RECT Rect;
namespace __GLBASIC__ {
ENDINLINE

FUNCTION StartUp:
GETDESKTOPSIZE DesktopWidth,DesktopHeight
LOCAL A=DOESFILEEXIST("Settings.ini")
IF A=0
INIOPEN "Settings.ini"
Window.Width=648
Window.Height=514
Window.X=((DesktopWidth-Window.Width)/2)
Window.Y=((DesktopHeight-Window.Height)/2)
Gui.Width=640
Gui.Height=480
Gui.Mode=0
Gui.PrevWidth=Gui.Width
Gui.PrevHeight=Gui.Height

SETSCREEN Gui.Width,Gui.Height,Gui.Mode

INLINE
Window.Style_Str=::GetWindowLongA(GLBASIC_HWND(),GWL_STYLE);
::SetWindowLongA(GLBASIC_HWND(),GWL_STYLE,Window.Style_Str|WS_SIZEBOX|WS_MAXIMIZEBOX);
::SetWindowPos(GLBASIC_HWND(),0,Window.X,Window.Y,Window.Width,Window.Height,SWP_FRAMECHANGED);
ENDINLINE
ELSEIF A=1
INIOPEN "Settings.ini"
Window.X=INIGET$("Window","X")
Window.Y=INIGET$("Window","Y")
Window.Width=INIGET$("Window","Width")
Window.Height=INIGET$("Window","Height")
Window.Mode=INIGET$("Window","Mode")
Window.Style$=INIGET$("Window","Style$")
Gui.Width=INIGET$("Gui","Width")
Gui.Height=INIGET$("Gui","Height")
Gui.PrevWidth=Gui.Width
Gui.PrevHeight=Gui.Height
Gui.Mode=INIGET$("Gui","Mode")

SETSCREEN Gui.PrevWidth,Gui.PrevHeight,Gui.Mode

INLINE
::SetWindowLongA(GLBASIC_HWND(),GWL_STYLE,Window.Style_Str);
::SetWindowPos(GLBASIC_HWND(),0,Window.X,Window.Y,Window.Width,Window.Height,SWP_FRAMECHANGED);
ENDINLINE
ENDIF
ENDFUNCTION

FUNCTION Update:
LOCAL Flag

IF Window.X=0 AND Window.Y=0 AND Window.Mode=0
Window.X=((DesktopWidth-Window.Width)/2)
Window.Y=((DesktopHeight-Window.Height)/2)
INLINE
::SetWindowPos(GLBASIC_HWND(),0,Window.X,Window.Y,Window.Width,Window.Height,SWP_SHOWWINDOW);
ENDINLINE
ENDIF

INLINE
::GetWindowRect(GLBASIC_HWND(),&Rect);

Window.Width=(Rect.Right-Rect.Left);
Window.Height=(Rect.Bottom-Rect.Top);
Window.X=Rect.Left;
Window.Y=Rect.Top;

Window.Style_Str=::GetWindowLongA(GLBASIC_HWND(),GWL_STYLE);

if(Window.Style_Str&WS_MAXIMIZE){
Window.Mode=1;}
else{
Window.Mode=0;}
ENDINLINE

Gui.Width=(Window.Width-8)
Gui.Height=(Window.Height-34)
IF Gui.Width>Gui.PrevWidth OR Gui.Width<Gui.PrevWidth THEN Flag=1
IF Gui.Height>Gui.PrevHeight OR Gui.Height<Gui.PrevHeight THEN Flag=1

IF Flag=1
VIEWPORT 0,(Gui.PrevHeight-Gui.Height),Gui.Width,Gui.Height
Flag=0
ENDIF
ENDFUNCTION

                                                                                                         Please give credit if used. I've worked very hard on this for a long time now. Anyways, enjoy!

2
GLBasic - en / Android Keyboard
« on: 2011-Oct-30 »
Does Android have a built in virtual keyboard for touch screen only devices that is accessible?

3
GLBasic - en / Window Resizing
« on: 2011-Aug-07 »
So I really want to be able to re-size the window with the Maximize button and Restore buttons, unfortunately I am no in-line coder. I was hoping someone could either point me in the right direction of where I can learn to achieve this. Or if someone has some spare code I would greatly appreciate it. Either way I am eager to learn this and would also like to be able to re-size with the edges of the window.

4
Announcements / Dev Tool
« on: 2011-Jul-16 »
I finally posted a video of my Tilemap Editor, tell me what you think. Its definitely still a work in progress.


5
Bug Reports / INPUT?
« on: 2011-Jun-09 »
I see the INPUT command now has access to the NumPad.  =D But now when I have entered what I want to INPUT, to enter the information you must press "Enter + Ctrl," was wondering if this was a bug or if its intentional. I used to only have to press "Enter" when I was done inputing to INPUT. Thanks in advance.

6
GLBasic - en / Controling System Mouse?
« on: 2011-Jan-01 »
I know if I disable system mouse I can set the mouse for whatever I want. But is it possible to set coordinates for the system mouse? For example I don't want to let the mouse go beyond a certain point while the left button is pressed, but still want to use the system mouse.

7
GLBasic - en / Windowed Mode Question
« on: 2010-Nov-19 »
I searched the forum but couldn't find any answers. Is there a way to make a program in windowed mode that can be maximized and even adjusted in the bottom right corner?

8
GLBasic - en / Quick Question
« on: 2010-Nov-15 »
Just wondering, never really have had an official answer on this. Whats the difference between "IF" and "SELECT?" I have often wondered this, is there anything different I can do with one or the other? Also if anyone knows, is one of them faster? Thanks in advance.

9
GLBasic - en / Saving Images and Data
« on: 2010-Oct-18 »
Is it possible to save a file that stores and image, as well as data to be read when loading? If so how would I do it?

10
GLBasic - en / Question?
« on: 2010-Mar-09 »
Is it possible to open another program from a program.

11
GLBasic - en / GP2X Utility .gpu
« on: 2010-Jan-05 »
Is there a way to compile GP2X programs to not only the game extension .gpe but also for the utility extension .gpu?

12
Bug Reports / Numpad in INPUT
« on: 2009-Dec-31 »
Is it possible to get values from the numpad with the INPUT command?

13
GLBasic - en / Help please
« on: 2009-Dec-18 »
I searched the forum but couldn't find anything I could understand. Is it possible to save an image as a .png file? If so how would I? O_O

14
GLBasic - en / How did you learn to program?
« on: 2009-Dec-07 »
The poll is only for two days ,because it is for my PowerPoint for Computer Science Class. Please everyone who reads vote! :whip:

15
Code Snippets / Pixel Perfect Collision
« on: 2009-Nov-20 »
A little example I threw together last night. Been using it for a while thought others may like it.

Code: (glbasic) [Select]
SETSCREEN 640,480,0
LIMITFPS 60

GLOBAL Walls = 1
LOADSPRITE "Walls.png",Walls

TYPE BallType
Image
Speed
X
Y
US
RS
DS
LS
ENDTYPE

GLOBAL Ball AS BallType

Ball.Image = 2
LOADSPRITE "Ball.png",Ball.Image
Ball.Speed = 2
Ball.X = 164
Ball.Y = 124
Ball.US = 0
Ball.RS = 0
Ball.DS = 0
Ball.LS = 0


Main:
BLACKSCREEN

Movement()
Collision()
Draw()

SHOWSCREEN
GOTO Main


FUNCTION Movement:
IF KEY(200) AND Ball.US = 1
Ball.Y = Ball.Y - Ball.Speed
ENDIF

IF KEY(205) AND Ball.RS = 1
Ball.X = Ball.X + Ball.Speed
ENDIF

IF KEY(208) AND Ball.DS = 1
Ball.Y = Ball.Y + Ball.Speed
ENDIF

IF KEY(203) AND Ball.LS = 1
Ball.X = Ball.X - Ball.Speed
ENDIF
ENDFUNCTION


FUNCTION Collision:
FOR A = 0 TO Ball.Speed
IF SPRCOLL(Ball.Image,Ball.X,Ball.Y - Ball.Speed,Walls,0,0)
Ball.US = 0
Ball.Y = Ball.Y - (A - 1)
ELSE
Ball.US = 1
ENDIF

IF SPRCOLL(Ball.Image,Ball.X + Ball.Speed,Ball.Y,Walls,0,0)
Ball.RS = 0
Ball.X = Ball.X + (A - 1)
ELSE
Ball.RS = 1
ENDIF

IF SPRCOLL(Ball.Image,Ball.X,Ball.Y + Ball.Speed,Walls,0,0)
Ball.DS = 0
Ball.Y = Ball.Y + (A - 1)
ELSE
Ball.DS = 1
ENDIF

IF SPRCOLL(Ball.Image,Ball.X - Ball.Speed,Ball.Y,Walls,0,0)
Ball.LS = 0
Ball.X = Ball.X - (A - 1)
ELSE
Ball.LS = 1
ENDIF
NEXT
ENDFUNCTION


FUNCTION Draw:
DRAWSPRITE Walls,0,0
DRAWSPRITE Ball.Image,Ball.X,Ball.Y
ENDFUNCTION




Pages: [1] 2