The MASM Forum

Projects => Game Development => Topic started by: BugCatcher on May 18, 2018, 02:38:10 AM

Title: Direct2d breakout
Post by: BugCatcher on May 18, 2018, 02:38:10 AM
Decided to have some fun with direct2d. Ive started a 2d game engine and so far Ive got some objects and a menue. Pressing the esc key toggles the menue in and out. I'd be curious if it works on windows xp as I don't have that os anymore.

My ide is radAsm 3.0.0.c and artwork with inkscape. Os is windows 7
Title: Re: Direct2d breakout
Post by: jj2007 on May 18, 2018, 04:54:59 AM
On XP SP3, it says D2D1.dll not found:(

On Win7-64, it shows red squares but CPU usage goes over the top - did you forget the message pump?
Title: Re: Direct2d breakout
Post by: caballero on May 18, 2018, 05:10:57 AM
In my W7 looks nice, but a bit huge and 25% CPU consuming. Did you use the Siekmanski d2d example?
Title: Re: Direct2d breakout
Post by: BugCatcher on May 18, 2018, 06:54:11 AM
Quote
In my W7 looks nice, but a bit huge and 25% CPU consuming. Did you use the Siekmanski d2d example?

No, its all my own stuff.

Code: [Select]
  .WHILE TRUE
invoke PeekMessage, ADDR msg, NULL, 0, 0, PM_REMOVE
.if (eax != 0)
;===================================
; Break if it was the quit messge
;===================================
mov eax, msg.message
.IF eax == WM_QUIT
;======================
; Break out
;======================
jmp shutdown
.endif

;===================================
; Translate and Dispatch the message
;===================================
invoke TranslateMessage, ADDR msg
invoke DispatchMessage, ADDR msg
.endif

invoke OnRender
invoke UpdateMenue
invoke UpdateObjects

.ENDW

I am flipping the screen 34 times a second. Painting the background and all objects.



Title: Re: Direct2d breakout
Post by: jj2007 on May 18, 2018, 06:57:18 AM
Windows doesn't work like that. Use GetMessage instead of PeekMessage...
Title: Re: Direct2d breakout
Post by: Ascended on May 18, 2018, 10:07:27 PM
Windows doesn't work like that. Use GetMessage instead of PeekMessage...

PeekMessage is normal for games. I'd definitely not recommend GetMessage, end user will get all sorts of weird stalls.
Title: Re: Direct2d breakout
Post by: daydreamer on May 19, 2018, 07:17:46 AM
doesnt work on any of my computers :(
Title: Re: Direct2d breakout
Post by: zedd151 on May 19, 2018, 11:07:09 AM
win 10 home 64 bit, 70-80% cpu usage

looks nice so far and the menu works good
Title: Re: Direct2d breakout
Post by: BugCatcher on May 22, 2018, 01:44:25 AM
Fixed the window size problem. Now buttons light up when mouse hovers over them.
Title: Re: Direct2d breakout
Post by: BugCatcher on May 22, 2018, 08:55:45 AM
Buttons now click. Quit button works
Title: Re: Direct2d breakout
Post by: zedd151 on May 22, 2018, 01:09:51 PM
The new 3 state buttons look good, cpu usage is down to 45-46%  a step in the right direction.    :t

Windows 64  Home edition
Title: Re: Direct2d breakout
Post by: LordAdef on May 22, 2018, 02:43:38 PM
Windows doesn't work like that. Use GetMessage instead of PeekMessage...

PeekMessage is normal for games. I'd definitely not recommend GetMessage, end user will get all sorts of weird stalls.
+1 with Ascended: games usually use Peekmessage
Title: Re: Direct2d breakout
Post by: LordAdef on May 22, 2018, 02:46:07 PM
Nice menu man!!!!!!! Classy stuff

win10. CPU at about 18%.

As soon as you sleep the game loop, CPU goes down to a nice %.

Title: Re: Direct2d breakout
Post by: Siekmanski on May 22, 2018, 05:48:16 PM
OS win 8.1

When I click on start, the button flashes but nothing happens.
Or am I doing something wrong?
Title: Re: Direct2d breakout
Post by: BugCatcher on May 23, 2018, 01:22:02 AM
Quote
When I click on start, the button flashes but nothing happens.
Or am I doing something wrong?

Just the quit button works for now. I'm working on a high scores screen right now.
Title: Re: Direct2d breakout
Post by: caballero on May 26, 2018, 06:42:53 AM
-1 :t
Title: Re: Direct2d breakout
Post by: BugCatcher on June 16, 2018, 12:48:04 AM
Updated mouse coordinates on screen resize.
There is a scores screen. -No text yet.
There is a Start game.

Tried to use mouse messages for the paddle,way too herkie jerkie. So I translated DirectInput8,and now the paddle is very smooth and fast.

Need .686 directive for floating point. (?)

Next is the dreaded collision detection. -Gulp                                   -
Title: Re: Direct2d breakout
Post by: Caché GB on June 16, 2018, 01:17:29 AM
Hi BugCatcher

Try this

Code: [Select]
;#############################################################################################################

MsgLoopMain PROC

    Local  wMsg:MSG

       invoke  RtlZeroMemory, addr wMsg, sizeof(MSG)
          mAm  wMsg.hwnd, TheApp.hWind

    .while  true
       invoke  PeekMessage, addr wMsg, null, 0, 0, PM_REMOVE
      .if (eax != 0)
         .break .if (wMsg.message == WM_QUIT)
          invoke  TranslateAccelerator, TheApp.hWind, TheApp.hAccel, addr wMsg
         .if (eax == 0)
             invoke  TranslateMessage, addr wMsg
             invoke  DispatchMessage, addr wMsg
         .endif 
      .else
         invoke  UpdateTimers

         invoke  UpdateDetectInput
         invoke  UpdateCamera     
         invoke  UpdateScene
         invoke  RenderScene

      ;;   For BugCatcher
      ;;              V  V
         invoke  SleepEx, null, false   ;; <-- Give up the rest of your time slice.

      .endif
    .endw
 
       return  wMsg.wParam

MsgLoopMain ENDP

;#############################################################################################################

Title: Re: Direct2d breakout
Post by: BugCatcher on June 16, 2018, 02:25:44 AM
Ok here it is.

Code: [Select]
  .WHILE TRUE
invoke PeekMessage, ADDR msg, NULL, 0, 0, PM_REMOVE
.if (eax != 0)
;===================================
; Break if it was the quit messge
;===================================
mov eax, msg.message
.IF eax == WM_QUIT
;======================
; Break out
;======================
jmp shutdown
.endif

;===================================
; Translate and Dispatch the message
;===================================
invoke TranslateMessage, ADDR msg
invoke DispatchMessage, ADDR msg
.endif

invoke Main_Game_Loop,hWnd
.if PaddleActivated?
invoke DI_Read_Mouse,hWnd
invoke Process_Paddle
.endif

invoke  SleepEx, 0, FALSE   ;; <-- Give up the rest of your time slice.
.ENDW
Title: Re: Direct2d breakout
Post by: Caché GB on June 16, 2018, 02:44:36 AM
Hi BugCatcher.
This looks awesome. I can't wait till it's complete. 
Title: Re: Direct2d breakout
Post by: BugCatcher on July 08, 2018, 04:51:02 AM
Collision detection is finished. Small bug in paddle,no big thing. Bricks light up.

Next is some specialized bricks for more fun.
Finish high score screen.
Title: Re: Direct2d breakout
Post by: felipe on July 08, 2018, 08:16:50 AM
Hey bugcatcher the game is not working all ok by now (at least on my pc  :idea:) but if you can finish it, this will be sure a great game. Congrats. :icon14: