Menu

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.

Show posts Menu

Topics - kamakazieturtle

#1
      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
Does Android have a built in virtual keyboard for touch screen only devices that is accessible?
#3
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
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?
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
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
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
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
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?
2010-Mar-09
Is it possible to open another program from a program.
#11
Is there a way to compile GP2X programs to not only the game extension .gpe but also for the utility extension .gpu?
#12
Is it possible to get values from the numpad with the INPUT command?
#13
GLBasic - en / Help please
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
The poll is only for two days ,because it is for my PowerPoint for Computer Science Class. Please everyone who reads vote! :whip:
#15
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




#16
Very basic example I had laying around, thought I'd share so someone could get some use out of it. I made an additional source for my game and had actual dialog with scenes for reference points written out. Do whatever you want with it.

Code (glbasic) Select

textevent("This is my example","of a text event. I","made it for a 2d","rpg, use/modify as","you wish, no credit","required. :)")

FUNCTION textevent: line1$,line2$,line3$,line4$,line5$,line6$
DRAWRECT 10,10,160,95,RGB(0,0,150)
DRAWLINE 10,9,169,9,RGB(0,0,255)
DRAWLINE 10,105,169,105,RGB(0,0,255)
DRAWLINE 9,10,9,104,RGB(0,0,255)
DRAWLINE 170,10,170,104,RGB(0,0,255)
IF line1$
PRINT line1$,15,15
ENDIF
IF line2$
PRINT line2$,15,30
ENDIF
IF line3$
PRINT line3$,15,45
ENDIF
IF line4$
PRINT line4$,15,60
ENDIF
IF line5$
PRINT line5$,15,75
ENDIF
IF line6$
PRINT line6$,15,90
ENDIF
SHOWSCREEN
KEYWAIT
ENDFUNCTION
#17
GLBasic - en / Camera Help
2009-Apr-13
Ok, so I have been trying to learn how to make a 3rd person camera for like the last 2 weeks :S, and so far no success from the search. So if someone has code for one they wouldn't mind sharing. Or if someone feels like taking the time to explain how rotating a point around another works, I could really use the help.
#18
I'm trying to do something like this, and I know I've done it before but i seem to have lost the source i had. So if someone knows the proper way to define an array like such it would be much appreciated. =D


DIM tile[15][15]
tile[0][0] = 2,tile[1][0] = 6,tile[2][0] = 6,tile[3][0] = 6,tile[4][0] = 6,tile[5][0] = 6,tile[6][0] = 6,tile[7][0] = 6,tile[8][0] = 6,tile[9][0] = 6,tile[10][0] = 6,tile[11][0] = 6,tile[12][0] = 6,tile[13][0] = 6,tile[14][0] = 3
#19
GLBasic - en / Include
2008-Dec-18
Is there any way to include other .gbas files?
#20
Okay so in my side scroller i want to have my sprite collide with a hill and walk up it. I'm not coming up with anything that works :'(. My approach was if player collides with hill move player up, but it didn't seem to work so any suggestions will be appreciated.