• Dear Cerberus X User!

    As we prepare to transition the forum ownership from Mike to Phil (TripleHead GmbH), we need your explicit consent to transfer your user data in accordance with our amended Terms and Rules in order to be compliant with data protection laws.

    Important: If you accept the amended Terms and Rules, you agree to the transfer of your user data to the future forum owner!

    Please read the new Terms and Rules below, check the box to agree, and click "Accept" to continue enjoying your Cerberus X Forum experience. The deadline for consent is April 5, 2024.

    Do not accept the amended Terms and Rules if you do not wish your personal data to be transferred to the future forum owner!

    Accepting ensures:

    - Continued access to your account with a short break for the actual transfer.

    - Retention of your data under the same terms.

    Without consent:

    - You don't have further access to your forum user account.

    - Your account and personal data will be deleted after April 5, 2024.

    - Public posts remain, but usernames indicating real identity will be anonymized. If you disagree with a fictitious name you have the option to contact us so we can find a name that is acceptable to you.

    We hope to keep you in our community and see you on the forum soon!

    All the best

    Your Cerberus X Team

How do I use SetDeviceWindow: Void (width:Int, height:Int, flags:Int)

Int means, that you hand the function a number. For example you write SetDeviceWindow(800,600,0)

The word after the function name and the ":" is the kind of value you get as a result from that function. The "void" here just means, that there is no resulting value.

@MikeHart We definitely need a beginners section in the forum. A place where you can ask everything you don't know about Cerberus or programming itself.
 
Ok, if you both feel that it could be useful then I will open a new subforum and move your post over there.
 
Thank you for making that new subforum. Now I'm trying to work out where do I put SetDeviceWindow. I tried to put it to onRender and it end up with screen spasm, which was pretty funny. Now I found where to put it, but now I need to work out how to code butonpressed x = exit. I'll try to find it myself so thankls for setdevicewindow help :)
 
Now I'm trying to work out where do I put SetDeviceWindow.
If you want to set it at the start of your game, then do it inside OnCreate. If you want to switch it during the game, place it inside OnUpdate.
Actually inside OnRender could work too, but don't call it at every frame. I could imagine that it looks weird then.
 
Well I used Function ExitApp:Int() on all of them and none liked function :/
 
Basically, I am still using time code to test all my things and for some reason none of functions are allowed. I tried before class, inside class, after class, in main functuion, in all onrend, create, update.
 
Please post your code so I can see. And which Target do you want to use?
 
Code:
Strict

Import mojo



Class CGame Extends App
'timer
    Field lastTick:Int
    Field secs:Int
    Field mins:Int
    Field hrs:Int
    Field dys:Int
 
  'resources
    Field wood:Float
     Field loopedtimeforwood:Int
    
'character
     Field characters_front:Image
     Field characters_back:Image
     Field characters_look_left:Image
     Field characters_look_right:Image
     Field characters_walk_left:Image
     Field characters_walk_right:Image
    Field x:Float
    Field y:Float
     Field character:Image
     Field p1:CGame
    

   
   
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    Method OnCreate:Int()
        SetUpdateRate(0)
        lastTick = Millisecs()
        loopedtimeforwood = 0
        wood = 0
       
        SetDeviceWindow(1600,1500,1)
       
   
       
        'character
        character = LoadImage("character_front.png")
        SetUpdateRate 60
        Return 0
       
    End Method
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
    Method OnUpdate:Int()
        Local tick:Int = Millisecs()
        If tick>=(lastTick+1000)
            lastTick = tick
            secs += 1
            loopedtimeforwood+=1
        Endif
        If secs > 59 Then
            secs = 0
            mins +=1
            If mins > 59 Then
                mins = 0
                hrs +=1
                If hrs > 23 Then
                    hrs = 0
                    dys += 1
                Endif
            Endif
        Endif
       
       If loopedtimeforwood >= 20
               wood+=1
               If KeyDown (KEY_A) Then wood+=1
           loopedtimeforwood =0
        End
       
       
       If KeyDown (KEY_LEFT) Then x = x - 4
       If KeyDown (KEY_RIGHT) Then x = x + 4
       If KeyDown (KEY_UP) Then y = y-4
       If KeyDown (KEY_DOWN) Then y = y +4
        Return 0
    End Method
    Method OnRender:Int()
       
        Cls 24, 234, 75
        DrawText("Mins: "+secs, 200, 200)
        DrawText("Min: "+mins, 570, 10)
        DrawText("Hour: "+hrs, 510, 10)
        DrawText("Day: "+dys, 460, 10)''''''''''''''''
        DrawText("Wood: "+wood, 100, 100)
       
       
       
        DrawImage character, x, y
        Return 0
       
    End Method
   

   
End Class


Function Main:Int()
    New CGame()
          
   
       Return 0
End Function

By target d you mean device/operating system? if so im doing windows pc
 
only bug I could see (apart from that on mine mins went up every second!) was character_front.png is not loaded and leads to a null object, is it being loaded correctly from the <project name>.data directory?

edit: ah, mins doesn't go up every second but the line
DrawText("Mins: "+secs, 200, 200)

makes it look so!
 
By target d you mean device/operating system? if so im doing windows pc

No, I ment which platform do you target when you build your app? SetDeviceWindow works only on the Desktop platform.

So from what I see in your code....

you want to create a fullscreen with a resolution of 1600x1500? :eek: Maybe your monitor supports that, I don't know. Mine doesn't and I never heard of such a fullscreen resolution. I wouldn't be surprised if it doesn't run because of that or looks weird at least.

Well I used Function ExitApp:Int() on all of them and none liked function :/

Please next time post this in a new topic as it isn't related to SetDeviceWindow. I assume that you want to target the desktop platform. To use this command, you need to import another module at the beginning of your code, below or above the Import mojo line.
Import either the OS module or the BRL module. Both have implemented the ExitApp function. But both only work on the Desktop or C++ target.
 
Hi.
I place in (Method OnCreate)
SetDeviceWindow(800,600,1)
or
SetDeviceWindow(1024,768,1)
result 640х480 (DeviceWidth x DeviceHeight)

I try DisplayModes ()
I receive the array long in 0
(checked on two different computers and browsers)
Firefox, Opera, Edge
same result (((
 
I guess you are compiling for html target and as far as I know SetDeviceWindow only works on desktop target. If you want to change the size in html you have to edit the CerberusGame.html file in the build folder and change these lines:
var CANVAS_WIDTH=640;
var CANVAS_HEIGHT=480;
not tested recently ;-)
 
Thanks! It's a go. I will dig further, but already it to be pleasant to me! (I ask to forgive my English, the translator)
 
Back
Top Bottom