November 12, 2019, 11:57:52 AM

Author Topic: [PAID] Screen Framework for AGK?  (Read 1990 times)

Offline Amon.

  • Full Member
  • ***
  • Posts: 143
  • What? There's no ceiling outside?
    • Amon.Pro
[PAID] Screen Framework for AGK?
« on: May 26, 2019, 04:27:52 PM »
I need a basic screen framework like diddy2 but for AGK. I'm willing to pay to get this done for me. If anyone is capable, has the time and is willing can you email me or post here and we can discuss it, includin costs.

Thank you.
Windows 10 Pro - 32GB DDR4 RAM - GEFORCE RTX 2070 8GB - AMD RYZEN 7 8 CORE - WATERCOOLING.

Offline Qube

  • Administrator
  • Hero Member
  • *****
  • Posts: 2191
Re: [PAID] Screen Framework for AGK?
« Reply #1 on: May 26, 2019, 09:27:34 PM »
I'm not familiar with diddy 2 but if you can describe what you'd ideally like then if I already have something similar in my framework I'll send it over to you for free :)
Until the next time...

Offline Derron

  • Hero Member
  • *****
  • Posts: 2567
Re: [PAID] Screen Framework for AGK?
« Reply #2 on: May 26, 2019, 10:06:31 PM »
Screen frameworks usually handle:
- update / render current "screen object"
- transition between "current object" and "last/next screen objects"
- have "prepare/firststart/init/afterXYZ/beforeXYZ" function/hooks which are called in the approbriate situations for screen objects to create objects, clean up, prepare stuff ...

So in essence you create screens for start menus, loading screens, publisher logo, ingame, gameover, ... and then just tell in your logic to go to the screen XYZ. If you are on your "start screen" a "previous screen" command would lead to exiting the app - except you re-wire connections manually.


bye
Ron

Offline blinkok

  • Full Member
  • ***
  • Posts: 128
Re: [PAID] Screen Framework for AGK?
« Reply #3 on: May 26, 2019, 10:48:52 PM »

Offline Amon.

  • Full Member
  • ***
  • Posts: 143
  • What? There's no ceiling outside?
    • Amon.Pro
Re: [PAID] Screen Framework for AGK?
« Reply #4 on: May 26, 2019, 11:36:46 PM »
Derron summed it up perfectly. Do you have anything like this, Qube?
Windows 10 Pro - 32GB DDR4 RAM - GEFORCE RTX 2070 8GB - AMD RYZEN 7 8 CORE - WATERCOOLING.

Offline Qube

  • Administrator
  • Hero Member
  • *****
  • Posts: 2191
Re: [PAID] Screen Framework for AGK?
« Reply #5 on: May 26, 2019, 11:49:14 PM »
Screen frameworks usually handle: ........
Thanks, I guessed as much in regards to what Diddy can do on this side.

I'm thinking it might be this
Yeah, I've heard of Diddy but I've never used Monkey 2 and thus I'm not familiar with all that Diddy does to help with game creation.

Derron summed it up perfectly. Do you have anything like this, Qube?
Oddly enough I don't have a framework for this as I code my games in a fashion where I can call any scene at any time anyway and fade in / out with a simple function call. I can see the benefit of having a more framework approach over a coding approach so it's something I'd be interested in doing along with my updated AGK framework stuff.

When I get around to doing this side and if I can make it separate enough from the rest of the framework then I'll happily provide the code for free. In the meantime if someone offers to code a system up for you then of course feel free to take their offer.
Until the next time...

Offline Amon.

  • Full Member
  • ***
  • Posts: 143
  • What? There's no ceiling outside?
    • Amon.Pro
Re: [PAID] Screen Framework for AGK?
« Reply #6 on: May 27, 2019, 11:48:23 AM »
What you have now sounds pretty cool, Qube. I'd be interested in trying it. :)
Windows 10 Pro - 32GB DDR4 RAM - GEFORCE RTX 2070 8GB - AMD RYZEN 7 8 CORE - WATERCOOLING.

Offline Qube

  • Administrator
  • Hero Member
  • *****
  • Posts: 2191
Re: [PAID] Screen Framework for AGK?
« Reply #7 on: May 27, 2019, 10:39:26 PM »
What you have now sounds pretty cool, Qube. I'd be interested in trying it. :)
This is probably not what you're after but is roughly what I do in my games to change between scenes and menus. Anyway, hope some part of it is of use.

Attached is a full project you can load straight into AGK and test ( use the latest version of AGK Classic )

Instructions of what this does as a scene change example.

1.. Fades in and out of each section
2.. Press SPACE to go from Main Menu to Main Game
3.. Press SPACE in Main Game to change level
4.. Press M in Main Game to change to a Mini Game
5.. Press SPACE in a Mini Game to return to the Main Game
6.. Press ESC in the Main Game or Mini Game to return to the Main Menu
7.. Press ESC on the Main Menu to QUIT

Source ( included in the attachment ) :

Code: [Select]
Global screenWidth As Float = 1024
Global screenHeight As Float = 576

SetWindowTitle( "Scene Test" )
SetWindowSize( screenWidth, screenHeight, 0 )
SetWindowPosition( ( GetMaxDeviceWidth() - GetWindowWidth() ) / 2, ( ( GetMaxDeviceHeight() - GetWindowHeight() ) / 2 ) )
SetWindowAllowResize( 0 )
SetVirtualResolution( screenWidth, screenHeight )
SetDisplayAspect( screenWidth / screenHeight )
SetOrientationAllowed( 0, 0, 1, 1 )
EnableClearColor( 1 )
SetRandomSeed( GetUnixTime() )
SetRandomSeed2( GetUnixTime() )
SetRawMouseVisible( 0 )
SetVsync( 1 )
SetClearColor( 0, 0, 0 )
UseNewDefaultFonts( 1 )

Global targetFrameRate As Float = 60.0
Global gameAtlas As Integer, deltaTime As Float, gameScene As String, gameWorld As Integer, gameLevel As Integer, nextScene As String
Global fadeMode As Integer, fadeValue As Float, fadeStage As Integer, fadeAction As String

Global spritePixel, spriteBall, spriteMenu, spriteGame, spriteMini
Global ballAngle As Float

Dim numbers[ 9 ]
 
Variables()
PrepareMedia()

gameScene = "Main Menu"
fadeMode = 0 // start with fading in

//
// MAIN LOOP
//

Do
// SCENES

If gameScene = "Main Menu" Then MainMenu()
If gameScene = "Game" Then MainGame()
If gameScene = "Mini Game" Then MiniGame()

// CHANGING OF SCENES

If fademode = -1
If GetRawKeyPressed( KEY_SPACE )
If gameScene = "Main Menu"
gameLevel = 1
ChangeScene( "Game", "" )
EndIf

If gameScene = "Game"
ChangeScene( "Game", "Next Level" )
EndIf

If gameScene = "Mini Game" Then ChangeScene( "Game", "" )
EndIf

If GetRawKeyPressed( KEY_M )
If gameScene = "Game" Then ChangeScene( "Mini Game", "" )
EndIf

If GetRawKeyPressed( KEY_ESCAPE ) And gameScene <> "Main Menu" Then ChangeScene( "Main Menu", "" )
If GetRawKeyPressed( KEY_ESCAPE ) And gameScene = "Main Menu" Then END
EndIf

// FADING AND ACTIOND AFTERWARDS

If fadeMode = 0 Then FadeIn( fadeAction )
If fadeMode = 1 Then FadeOut( fadeAction )

// SWAP AND REPEAT

Swap()
GetDeltaTime()
Loop

//
// MAIN MENU
//

Function MainMenu()
Sprite( spriteMenu, screenWidth / 2 ,screenHeight / 2, 255, 255, 255, 255, 1 )
EndFunction

//
// GAME
//

Function MainGame()
For i = 0 To 359 Step 20
Sprite( spriteBall, ( screenWidth / 2 ) + Cos( i + ballAngle ) * screenHeight / 2.2, ( screenHeight / 2 ) + Sin( i - ballAngle * 2 ) * screenHeight / 2.2, 255, 255, 255, 255, 1 )
Next

Inc ballAngle, 1 * deltaTime
If ballAngle >= 360 Then Dec ballAngle, 360

Sprite( spriteGame, screenWidth / 2 ,screenHeight / 2, 255, 255, 255, 255, 1 )

Sprite( numbers[ gameLevel ], screenWidth / 2, ( screenHeight / 2 ) + 50, 255, 255, 255, 255, 1 )
EndFunction

//
// MINI GAME
//

Function MiniGame()
For i = 0 To 359 Step 30
Sprite( spriteBall, ( screenWidth / 2 ) + Cos( i + ballAngle ) * screenHeight / 2.2, ( screenHeight / 2 ) + Sin( i + ballAngle ) * screenHeight / 2.2, 255, 155, 155, 255, 1 )
Next

Inc ballAngle, 1 * deltaTime
If ballAngle >= 360 Then Dec ballAngle, 360

Sprite( spriteMini, screenWidth / 2 ,screenHeight / 2, 255, 255, 255, 255, 1 )
EndFunction

//
// SETUP TO CHANGE SCENE
//

Function ChangeScene( fScene As String, fAction As String )
nextScene = fScene
fadeAction = fAction
fadeMode = 1
EndFunction

//
//  FADE IN
//

Function FadeIn( fAction As String )
// init the fade

If fadeStage = 0
fadeStage = 1
fadeValue = 255
EndIf

// do the fade

Dec fadeValue, 3 * deltaTime
If fadeValue <= 0
fadeValue = 0
fadeStage = 0
fadeMode = -1

// any actions to take after fading?
EndIf

// draw super zoomed sprite

Sprite( spritePixel, 0, 0, 0, 0, 0, fadeValue, 0 )
EndFunction

//
// FADE OUT
//

Function FadeOut( fAction As String )
// init the fade

If fadeStage = 0
fadeStage = 1
fadeValue = 0
EndIf

// do the fade

Inc fadeValue, 5 * deltaTime
If fadeValue >= 255
fadeValue = 255
fadeStage = 0
fadeMode = 0

If nextScene > "" Then gameScene = nextScene
nextScene = ""

// any actions to take after fading?

If fAction = "Next Level"
Inc gameLevel
If gameLevel > 9 Then gameLevel = 1
EndIf
EndIf

// draw super zoomed sprite

Sprite( spritePixel, 0, 0, 0, 0, 0, fadeValue, 0 )
EndFunction

//
// PREPARE MEDIA
//

Function PrepareMedia()
gameAtlas = LoadImage( "media.png" )

temp = LoadSubImage( gameAtlas, "whitepixel.png" )
spritePixel = CreateSprite( temp )
SetSpriteSize( spritePixel, screenWidth, screenHeight )

temp = LoadSubImage( gameAtlas, "ball.png" )
spriteBall = CreateSprite( temp )

temp = LoadSubImage( gameAtlas, "mainmenu.png" )
spriteMenu = CreateSprite( temp )

temp = LoadSubImage( gameAtlas, "gamelevel.png" )
spriteGame = CreateSprite( temp )

temp = LoadSubImage( gameAtlas, "minigame.png" )
spriteMini = CreateSprite( temp )

For i = 0 To 9
temp = LoadSubImage( gameAtlas, Str( i ) + ".png" )
numbers[ i ] = CreateSprite( temp )
Next
EndFunction

//
// SPRITE FUNCTION
//

Function Sprite( fImage, fXPos As Float, fYPos As Float, fRed, fGreen, fBlue, fAlpha, fHandle )
If GetSpriteExists( fImage ) = 0 Then ExitFunction

SetSpriteColor( fImage, fRed, fGreen, fBlue, fAlpha )

If fHandle = 0 Then SetSpritePosition( fImage, fXPos, fYPos ) // top left handle
If fHandle = 1 Then SetSpritePosition( fImage, fXPos - ( GetSpriteWidth( fImage ) / 2.0 ),fYPos - GetSpriteHeight( fImage ) / 2.0 ) // center handle

DrawSprite( fImage )
EndFunction

//
// DELTA TIME - super cheap method
//

Function GetDeltaTime()
deltaTime = GetFrameTime() * targetFrameRate
EndFunction

//
// SETUP VARIABLES
//

Function Variables()
fadeMode = -1
fadeStage = 0

#constant    KEY_BACK         8
#constant    KEY_TAB          9
#constant    KEY_ENTER        13
#constant    KEY_SHIFT        16
#constant    KEY_CONTROL      17
#constant    KEY_ESCAPE       27
#constant    KEY_SPACE        32
#constant    KEY_PAGEUP       33
#constant    KEY_PAGEDOWN     34
#constant    KEY_END          35
#constant    KEY_HOME         36
#constant    KEY_LEFT         37
#constant    KEY_UP           38
#constant    KEY_RIGHT        39
#constant    KEY_DOWN         40
#constant    KEY_INSERT       45
#constant    KEY_DELETE       46
#constant    KEY_0            48
#constant    KEY_1            49
#constant    KEY_2            50
#constant    KEY_3            51
#constant    KEY_4            52
#constant    KEY_5            53
#constant    KEY_6            54
#constant    KEY_7            55
#constant    KEY_8            56
#constant    KEY_9            57
#constant    KEY_A            65
#constant    KEY_B            66
#constant    KEY_C            67
#constant    KEY_D            68
#constant    KEY_E            69
#constant    KEY_F            70
#constant    KEY_G            71
#constant    KEY_H            72
#constant    KEY_I            73
#constant    KEY_J            74
#constant    KEY_K            75
#constant    KEY_L            76
#constant    KEY_M            77
#constant    KEY_N            78
#constant    KEY_O            79
#constant    KEY_P            80
#constant    KEY_Q            81
#constant    KEY_R            82
#constant    KEY_S            83
#constant    KEY_T            84
#constant    KEY_U            85
#constant    KEY_V            86
#constant    KEY_W            87
#constant    KEY_X            88
#constant    KEY_Y            89
#constant    KEY_Z            90
#constant    KEY_F1           112
#constant    KEY_F2           113
#constant    KEY_F3           114
#constant    KEY_F4           115
#constant    KEY_F5           116
#constant    KEY_F6           117
#constant    KEY_F7           118
#constant    KEY_F8           119
#constant    KEY_S1           186   
#constant    KEY_S2           187
#constant    KEY_S3           188
#constant    KEY_S4           189
#constant    KEY_S5           190
#constant    KEY_S6           191
#constant    KEY_S7           192
#constant    KEY_S8           219
#constant    KEY_S9           220
#constant    KEY_S10          221
#constant    KEY_S11          222
#constant    KEY_S12          223
EndFunction
Until the next time...

Offline Amon.

  • Full Member
  • ***
  • Posts: 143
  • What? There's no ceiling outside?
    • Amon.Pro
Re: [PAID] Screen Framework for AGK?
« Reply #8 on: May 28, 2019, 07:08:38 AM »
That's pretty much what I needed. Thank you, Qube. :)
Windows 10 Pro - 32GB DDR4 RAM - GEFORCE RTX 2070 8GB - AMD RYZEN 7 8 CORE - WATERCOOLING.

Offline Qube

  • Administrator
  • Hero Member
  • *****
  • Posts: 2191
Re: [PAID] Screen Framework for AGK?
« Reply #9 on: May 28, 2019, 06:41:53 PM »
That's pretty much what I needed. Thank you, Qube. :)
Cool, so long as it’s of some use or points you in the direction you want.

When I redo my framework it’ll be a much neater system and I’ll no longer need to code in things like the above or pausing a game / music & sounds etc. Just straight to coding the game ;D
Until the next time...

Offline Amon.

  • Full Member
  • ***
  • Posts: 143
  • What? There's no ceiling outside?
    • Amon.Pro
Re: [PAID] Screen Framework for AGK?
« Reply #10 on: May 28, 2019, 07:10:12 PM »
That's pretty much what I needed. Thank you, Qube. :)
Cool, so long as it’s of some use or points you in the direction you want.

When I redo my framework it’ll be a much neater system and I’ll no longer need to code in things like the above or pausing a game / music & sounds etc. Just straight to coding the game ;D
Now that would be cool. What you have sorted for us so far is still good so thanks for that and I  look forward to the next framework. :)
Windows 10 Pro - 32GB DDR4 RAM - GEFORCE RTX 2070 8GB - AMD RYZEN 7 8 CORE - WATERCOOLING.

Offline Qube

  • Administrator
  • Hero Member
  • *****
  • Posts: 2191
Re: [PAID] Screen Framework for AGK?
« Reply #11 on: May 28, 2019, 07:56:00 PM »
Now that would be cool. What you have sorted for us so far is still good so thanks for that and I  look forward to the next framework. :)
Ah, that'll be for internal use and not a freebie, sorry :( :P
Until the next time...

Offline Amon.

  • Full Member
  • ***
  • Posts: 143
  • What? There's no ceiling outside?
    • Amon.Pro
Re: [PAID] Screen Framework for AGK?
« Reply #12 on: May 28, 2019, 08:08:13 PM »
Now that would be cool. What you have sorted for us so far is still good so thanks for that and I  look forward to the next framework. :)
Ah, that'll be for internal use and not a freebie, sorry :( :P
HOW DARE YOU DENY ME DA CODEZ! :)
One quick question: What is the best way to display text using the Print function when using Swap() instead of Sync()?
Windows 10 Pro - 32GB DDR4 RAM - GEFORCE RTX 2070 8GB - AMD RYZEN 7 8 CORE - WATERCOOLING.

Offline Qube

  • Administrator
  • Hero Member
  • *****
  • Posts: 2191
Re: [PAID] Screen Framework for AGK?
« Reply #13 on: May 28, 2019, 11:03:52 PM »
Quote
HOW DARE YOU DENY ME DA CODEZ! :)
Sure, OK, I'll just slave away and provide everything you need :))

Quote
One quick question: What is the best way to display text using the Print function when using Swap() instead of Sync()?
Never used the Print command and I can't see how to render it without Sync() :o

However you could use the other built in commands for text ( more flexible ). You could also wrap up a Function to work like Print.

If I'm ever using the built in text commands then I cheat a little by reassigning the text of a Global variable or else you're supplying one variable per line of text and I think that's just silly.

Like so :

Code: [Select]
Global myText As Integer

CreateText( myText, "" )
SetTextSize( myText, 50 )

Do
SetTextString( myText, "Hello" )
SetTextPosition( myText, 100, 100 )
DrawText( myText )

SetTextString( myText, "World!" )
SetTextPosition( myText, 140, 140 )
DrawText( myText )

Swap()
Loop
Until the next time...

Offline LineOf7s

  • Jr. Member
  • **
  • Posts: 69
    • LineOf7s Entertainment
Re: [PAID] Screen Framework for AGK?
« Reply #14 on: May 29, 2019, 12:15:13 AM »
Now that would be cool. What you have sorted for us so far is still good so thanks for that and I  look forward to the next framework. :)
Ah, that'll be for internal use and not a freebie, sorry :( :P

Sell it.