Author Topic: Lander project  (Read 4593 times)

0 Members and 1 Guest are viewing this topic.

Offline FellippeHeitor

  • QB64 Developer
  • Forum Resident
  • Posts: 2825
  • Let it go, this too shall pass.
    • QB64.org
Re: Lander project
« Reply #15 on: June 05, 2018, 01:50:25 AM »
Awesome job translating your game to this new approach, bplus! I'm glad to see you understood the idea of not having a main loop but being able to use the BeforeUpdateDisplay event as a main loop of sorts. I'm also happy to see you using BeginDraw and EndDraw successfully. I hope the experience was smooth using InForm.

PS: Great idea using the ProgressBar for fuel!

Offline Ashish

  • Forum Resident
  • Posts: 652
  • Burning Alone
Re: Lander project
« Reply #16 on: June 05, 2018, 07:04:32 AM »
Nice game, bplus! and Nice use of Inform!
if (Me.success) {Me.improve()} else {Me.tryAgain()}


My Projects - https://github.com/AshishKingdom?tab=repositories
OpenGL tutorials - https://ashishkingdom.github.io/OpenGL-Tutorials

Offline bplus

  • Forum Resident
  • Posts: 6303
  • What could possibly go wrong?
Re: Lander project
« Reply #17 on: June 05, 2018, 09:04:33 AM »
Thanks Fellippe and Ashish

Quote
'You can change the update frequency by calling SetFrameRate DesiredRate%
Dang! I am poor reader. Missed this all yesterday! So I didn't have to change the numbers, probably...

Here are my notes in .bas file for those who might want some hints for using InForm:
Quote
' notes: Do not use _display or _delay in screen repaints!
' Do not remove empty subs for form events created by UiEditor.
' Due to very fast screen updates:
' I had to reduce gravity and speeds to 1/10th except thruster acceleration.
' I had to go back and change numbers for controls so just used the updated form file.
' Also modified crash report again.
' Added code to draw flash of thruster at same time as drawing rest of scene.

Improvements using InForm:
+ Nice Fuel Gage = Progress Bar
+ Accurate response to mouse click of Buttons
+ Much easier tracking events.
+ Layout is independent and in separate file of run time workings. I was able to go back and modify numbers in the Frm file many times. Such would be OK as long as new Controls aren't added.

Designing Form:
Since I am familiar with VB the automatic naming of controls was a hindrance, I'd set the name change numbers and the name would be changed with new suffix...

When I changed font size, the width and height for label control changed and sometimes to weird numbers.

Still have not mastered how to grab control to move it around, I had numbers preplanned and just punched them in.

Oh, I am still trying to get use to pressing enter to set a control number.

To Do For Project:
Try and get original numbers working by changing frame rate.
Do something better with terrain making.
Make it more a game by possibly landing and taking off from different sites like delivering supplies across a moon.
So points for speed of getting route finished quickly with extra points for low fuel usage...
« Last Edit: June 05, 2018, 09:26:30 AM by bplus »

Offline FellippeHeitor

  • QB64 Developer
  • Forum Resident
  • Posts: 2825
  • Let it go, this too shall pass.
    • QB64.org
Re: Lander project
« Reply #18 on: June 05, 2018, 09:42:32 AM »
Quote
'You can change the update frequency by calling SetFrameRate DesiredRate%
Dang! I am poor reader. Missed this all yesterday! So I didn't have to change the numbers, probably...
The thing here is: you can increase the frame rate, but not make it less than 30fps. InForm won't allow you, especially as that would harm the interface repaints - something that's not bad if the refresh rate is higher but it's dreadful if it's lower. That said, you probably went the right route by adapting your physics.

Quote
the automatic naming of controls was a hindrance
Options -> Untick "Auto-name controls"

Quote
When I changed font size, the width and height for label control changed and sometimes to weird numbers.
Auto-sizing for labels was a feature request from TempodiBasic that I finally got around to adding in this latest beta, but I do recognize it is annoying sometimes and that's why Beta 8 will likely have an easy way to turn it off or bypass it too.

Quote
Still have not mastered how to grab control to move it around
Here you got me lost: what's to master?

Thanks a bunch and please keep the feedback coming, that's vital for a project like InForm.

Offline bplus

  • Forum Resident
  • Posts: 6303
  • What could possibly go wrong?
Re: Lander project
« Reply #19 on: June 05, 2018, 10:08:57 AM »
Hi Fellippe,

Sorry I forgot to mention, I did find the turn off switch to auto-naming and meant to praise you for that!

BTW, I lost contact with Label2 when I set the caption to "" and had background same as form, there was nothing to click and  or grab on to change it's settings even when I figured I could tab to it but not get the properties window to see it to change it. (I had it near the left edge of screen and somehow boggled the x to a negative?)
Wait... it probably came up when I tabbed to it... just didn't see...

Yes, a turn off switch for auto-sizing while designing, but isn't there a handy auto-size property in VB?

Also I am not seeing mouseX and mouseY locations in a Picture Box, this would be needed for board games like Battleship.
I would think if Slider bars can catch the mouse so can Picture Box, maybe more Global Variables. (True, I am not seeing allot of things that might be around somewhere.)
« Last Edit: June 05, 2018, 10:22:11 AM by bplus »

Offline bplus

  • Forum Resident
  • Posts: 6303
  • What could possibly go wrong?
Re: Lander project
« Reply #20 on: June 05, 2018, 10:28:09 AM »
Oh, I reread #18, I can't reduce the frame rate to less than 30 per second. Well that saved me some time and testing, thanks. I am glad I reread that.

But you can refresh even faster!

Offline FellippeHeitor

  • QB64 Developer
  • Forum Resident
  • Posts: 2825
  • Let it go, this too shall pass.
    • QB64.org
Re: Lander project
« Reply #21 on: June 05, 2018, 10:35:48 AM »
Use __UI_MouseLeft and __UI_MouseTop for x/y mouse locations. These are direct translations of _MOUSEX/_MOUSEY (which you shouldn't be probing yourself). To know the exact click location within a picturebox control, just subtract its .left and .top properties:

    pbMouseX = __UI_MouseLeft - Control(PictureBox).Left
    pbMouseY = __UI_MouseTop - Control(PictureBox).Top

Offline bplus

  • Forum Resident
  • Posts: 6303
  • What could possibly go wrong?
Re: Lander project
« Reply #22 on: June 05, 2018, 11:31:18 AM »
Thanks Fellippe, the mouse stuff is good to know for future board games.

Now I am trying to use Johnno's stars.png for a background image and draw lander on top.

Dang! cls clears the stars image, I hope _put works.

UPDATE: Oh here we go, LoadImage Control(controlID) , ImageFile$

OMG that sure slowed things down!!! and it appears the image rescaled the x, y dimensions as when the lander is upright it is wider than when lander is at 90 degrees

Image looks nice though!
« Last Edit: June 05, 2018, 11:53:29 AM by bplus »

Offline FellippeHeitor

  • QB64 Developer
  • Forum Resident
  • Posts: 2825
  • Let it go, this too shall pass.
    • QB64.org
Re: Lander project
« Reply #23 on: June 05, 2018, 12:13:36 PM »
LoadImage is supposed to be used for when you want to have static image to be shown inside a PictureBox control. It'll be stretched if the .Stretch property of the PictureBox control is set to true. If not stretched, it'll be centered, but then it can be aligned using the .Align property (that can be set to __UI_Left, __UI_Center or __UI_Right) and the .VAlign property (that can be set to __UI_Top, __UI_Middle or __UI_Bottom).

The LoadImage method can also be used to load an image to be used as an icon for a Button or MenuItem control, but then again it's a once at startup thing, not to be used in a loop.

If you want to use Johnno's bg for the game, just load it once using regular _LOADIMAGE and then, once you BeginDraw to the picturebox's surface, use _PUTIMAGE as you would in a non-InForm program.

Offline bplus

  • Forum Resident
  • Posts: 6303
  • What could possibly go wrong?
Re: Lander project
« Reply #24 on: June 05, 2018, 12:22:07 PM »
Thanks Fellippe,

What is destination handle, 0 or picture box handle, maybe none needed?

I will experiment...

Offline FellippeHeitor

  • QB64 Developer
  • Forum Resident
  • Posts: 2825
  • Let it go, this too shall pass.
    • QB64.org
Re: Lander project
« Reply #25 on: June 05, 2018, 12:23:10 PM »
None needed. What BeginDraw does is setting the proper _DEST, so you don't need to specify it. What EndDraw does is reset _DEST to the proper one and trigger a .Redraw (If you set the .Redraw property of a control to True you force InForm to redraw its surface, which may be needed in rare occasions. To trigger a global redraw set __UI_ForceRedraw = True - usually rarely needed too).
« Last Edit: June 05, 2018, 12:26:52 PM by FellippeHeitor »

Offline bplus

  • Forum Resident
  • Posts: 6303
  • What could possibly go wrong?
Re: Lander project
« Reply #26 on: June 05, 2018, 12:52:15 PM »
OK got it!

I had to load file somewhere else than what I first tried, so under the _LOAD event.

Then I did need to say _SOURCE star& before _PUTIMAGE without any arguments.

Then I still got scale changes with x, y when drawing.

So I loaded Johnno's stars into Paint stretched it to 1190 wide my Picture Box.
Then I cropped to 600 high to match my Picture Box Height.

Then saved the reconfigured image under same old name and ran with that.

Looks good so far:

Update: OH! I have to remove the old image from the frm designed file because getting missing file screen.

hmm... I could not remove the file image from Picture Box, it would not accept or change with an empty box when I hit enter.
So, I deleted the control and started over with all the old names and numbers except I changed alignments to top, left.
« Last Edit: June 05, 2018, 01:15:26 PM by bplus »

Offline FellippeHeitor

  • QB64 Developer
  • Forum Resident
  • Posts: 2825
  • Let it go, this too shall pass.
    • QB64.org
Re: Lander project
« Reply #27 on: June 05, 2018, 01:28:27 PM »
hmm... I could not remove the file image from Picture Box, it would not accept or change with an empty box when I hit enter.
So, I deleted the control and started over with all the old names and numbers except I changed alignments to top, left.

Noted. I'll look into that. As an alternative, you could have removed the LoadImage line from the .frm file.

Offline bplus

  • Forum Resident
  • Posts: 6303
  • What could possibly go wrong?
Re: Lander project
« Reply #28 on: June 05, 2018, 01:58:12 PM »
Ah, I have not looked inside a frm file, just a normal text, I will assume.

I may also have been screwed up because the Save Frm only option was using the Form name listed in the Form properties box.

I was loading a renamed frm file and wondering why my changes weren't being saved, they were but under original name in frm properties... which I hadn't changed. Yikes what a run around that was until I figured it out.

PS I think Johnno's Planet will make a great image for restart button! It would be nice if all the buttons were pictures, the universal language.
« Last Edit: June 05, 2018, 02:01:34 PM by bplus »

Offline johnno56

  • Forum Resident
  • Posts: 999
  • Live long and prosper.
Re: Lander project
« Reply #29 on: June 05, 2018, 06:14:17 PM »
Oh my... Squish the planet down to a size as to fit inside the button? That is a 600x600 image down to a maximum size of 20x20... I think my editor may "down tools" in protest... lol

I will give it a try and post it... Pictures on 'all' the buttons? Oh my... Pictures at 20 pixels in height will have little to no detail. You may get away with a silhouette-type image... Suggestions for images?

Stay tuned...
Logic is the beginning of wisdom.