|
Post by n00b on Jan 31, 2018 13:35:37 GMT -6
Try this code and see if it fixes the problem. Update does not clear the window surface but Cls does. I actually did not realize it until I looked at the source for the CLS function (I wrote most of the graphics routines over 3 years ago so I don't remember every line of code).
WindowOpen(0, "", 600, WINDOWPOS_CENTERED, 800, 600, 0) CanvasOpen(0, 800, 600, 0, 0, 800, 600, 0) ClearCanvas() SetColor(RGB(0, 0, 0)) RectFill(0, 0, 400, 400)
LoadImage(2, "arrow.png")
dim NewX dim NewY
Finish = 0
While Not Key(K_SPACE)
If Key(K_F1) Then SetWindowFullscreen(0, 1) Cls Finish = 0 ElseIf Key(K_F2) Then SetWindowFullscreen(0, 0) Cls Finish = 0 End If If Finish = 0 Then NewX = 1 NewY = 1 For a = 1 to 10 DrawImage(2, NewX, NewY) NewX = NewX + 60 NewY = NewY + 60 Next Finish = 1 End If
Update() Wend
Waitkey End
|
|
|
Post by kennn on Jan 31, 2018 20:05:23 GMT -6
Hi, thank you very much!!!!! I have tested your code. Succeeds. The fullscreen bug does not appear any more. However, I still have a question. Do you want to make the SetWindowFullscreen function becomes "change the game screen to full screen + remove all the old graphics on the game screen"? I understand. You use CLS in your new code make me remember your original suggestion in the thread: "Try Clearing the window with the CLS function after going fullscreen. Also it would help out a lot if you would upload the code with the image in the future that way I don't have to retype it. There is an option for entering code in the text options for the forum." I added the CLS in my code and tested and told you that the bug still existed in my old post: WindowOpen(0, "", 600, WindowPos_Centered, 800, 600, 0) CanvasOpen(0, 800, 600, 0, 0, 800, 600, 0) ClearCanvas() SetColor(RGB(0, 0, 0)) RectFill(0, 0, 400, 400) LoadImage(2, "arrow.png") NewX = 1 NewY = 1 Finish = 0 while not key(K_space) if key(K_f1) then SetWindowFullscreen (0, 1) CLS() elseif key(K_F2) then SetWindowFullscreen (0, 0) CLS() end if if Finish = 0 then for a = 1 to 10 DrawImage(2, NewX, NewY) NewX = NewX + 60 NewY = NewY + 20 update() next Finish = 1 end if update wend waitkey End Since this code doesn't need to draw the arrows again after each full screen changing, I think that it is worthwhile to test this code again. Thus I test this code today. In fact, the following code nearly succeeds. I did not describe accurately in my old post: "Hi, this problem still exists after I add CLS" I am not careful enough. There is only a very strange problem on the game screen. After I press F1 and F2 for several times, grey colour(belongs to the Windows desktop's status bar) outside the game window becomes a part of the game screen! I hope that the above information can give you more ideas to make RC BASIC better. Thanks again! ok, I will capture some screenshots later. Then you will understand clearly.
|
|
|
Post by kennn on Jan 31, 2018 20:23:24 GMT -6
Here:
|
|
|
Post by n00b on Jan 31, 2018 20:32:26 GMT -6
This is actually a problem that several games have in general. Most games solve this by requiring the user to restart the game after changing resolutions. That way the operating system can free memory being allocated by the backend renderer before initializing a renderer for a new window.
|
|
|
Post by kennn on Feb 1, 2018 0:20:39 GMT -6
This is actually a problem that several games have in general. Most games solve this by requiring the user to restart the game after changing resolutions. That way the operating system can free memory being allocated by the backend renderer before initializing a renderer for a new window. ....I see.
|
|
|
Post by kennn on Feb 4, 2018 10:37:02 GMT -6
Hi, noob, I want to report an important thing: Your code given to me last time does not work every time. Yes, in fact, I test again and again. This code: WindowOpen(0, "", 600, WINDOWPOS_CENTERED, 800, 600, 0) CanvasOpen(0, 800, 600, 0, 0, 800, 600, 0) ClearCanvas() SetColor(RGB(0, 0, 0)) RectFill(0, 0, 400, 400) LoadImage(2, "arrow.png") dim NewX dim NewY Finish = 0 While Not Key(K_SPACE) If Key(K_F1) Then SetWindowFullscreen(0, 1) Cls Finish = 0 ElseIf Key(K_F2) Then SetWindowFullscreen(0, 0) Cls Finish = 0 End If If Finish = 0 Then NewX = 1 NewY = 1 For a = 1 to 10 DrawImage(2, NewX, NewY) NewX = NewX + 60 NewY = NewY + 60 Next Finish = 1 End If Update() Wend Waitkey End The above code sometimes work, but sometimes does not work. This full screen problem makes me mad. When this code doesn't work. The game screen is: I try to use ClearCanvas() to replace Cls. The game screen is still not normal but the game screen is not exactly the same as the above game screen. These: Finally, I try to use both ClearCanvas() and Cls together. That means: WindowOpen(0, "", 600, WINDOWPOS_CENTERED, 800, 600, 0) CanvasOpen(0, 800, 600, 0, 0, 800, 600, 0) ClearCanvas() SetColor(RGB(0, 0, 0)) RectFill(0, 0, 400, 400) LoadImage(2, "arrow.png") dim NewX dim NewY Finish = 0 While Not Key(K_SPACE) If Key(K_F1) Then SetWindowFullscreen(0, 1) ClearCanvas() Cls Finish = 0 ElseIf Key(K_F2) Then SetWindowFullscreen(0, 0) ClearCanvas() Cls Finish = 0 End If If Finish = 0 Then NewX = 1 NewY = 1 For a = 1 to 10 DrawImage(2, NewX, NewY) NewX = NewX + 60 NewY = NewY + 60 Next Finish = 1 End If Update() Wend Waitkey End I have tested the above code many, many times. The above code is absolutely okay. The game screen is always normal. I hope that the above report can help you to make RC BASIC better. I still don't know why both ClearCanvas() and Cls are also required to make the above code work. Do you know the reason?
|
|
|
Post by n00b on Feb 4, 2018 12:10:08 GMT -6
To tell the truth I am not sure why. This problem only seems to occur on windows xp as far as I know. But I think what I am going to do is have setWindowFullscreen call cls and clearcanvas itself. Thanks for the bug report. Since I am only able to test on hardware I have this helps alot.
|
|
|
Post by kennn on Feb 4, 2018 17:59:02 GMT -6
ok, I see.
|
|