Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Platformer Demo (OpenGL)


  • Please log in to reply
29 replies to this topic
GuiUser
  • Guests
  • Last active:
  • Joined: --

Yeah, that's something I've been trying to get rid of, but then you wouldn't be able to use the mouse properly after Alt + Tabbing to another window.

Just do it this way:

ForceCursorToWindow := 1

Window_Create:
  Gui, 1:Color, 000000, 000000
  Gui, 1:+LastFound +LabelWindow_
  Gui, 1:Show, w640 h480, Window

  Window_Hwnd := WinExist()

  GoSub, Window_Timers
  Return

Window_Timers:
  SetTimer, Window_Active, 1
  Return

Window_Active:
  If (WinExist("A") = Window_Hwnd && ForceCursorToWindow = 1) {
    WinGetPos, X, Y, W, H, % "ahk_id " Window_Hwnd
    DllCall("SetCursorPos","Int",X + (W / 2),"Int",Y + (H / 2))
  }
  Return

Window_Escape:
Window_Close:
  ExitApp

F1::ForceCursorToWindow := !ForceCursorToWindow


GuiUser
  • Guests
  • Last active:
  • Joined: --
Hiding the window when the game window's active would probably a good idea as well:

ForceCursorToWindow := 1

Window_Create:
  Gui, 1:Color, 000000, 000000
  Gui, 1:+LastFound +LabelWindow_
  Gui, 1:Show, w640 h480, Window

  Window_Hwnd := WinExist()

  GoSub, Window_Timers
  Return

Window_Timers:
  SetTimer, Window_Active, 1
  Return

Window_Active:
  If (WinExist("A") = Window_Hwnd && ForceCursorToWindow = 1) {
    WinGetPos, X, Y, W, H, % "ahk_id " Window_Hwnd
    DllCall("SetCursorPos","Int",X + (W / 2),"Int",Y + (H / 2)),DllCall("ShowCursor","Int",0)
  } Else DllCall("ShowCursor","Int",1)
  Return

Window_Escape:
Window_Close:
  ExitApp

F1::ForceCursorToWindow := !ForceCursorToWindow


Uberi
  • Moderators
  • 1119 posts
  • Last active: May 02 2015 06:05 PM
  • Joined: 23 Aug 2010
GuiUser: Done, thanks for the suggestions!

Update: Field of view wider, dynamic clipping distance, and a new level! Also, see the first post for information about creating levels. Also, there's an awesome new default level included!

GuiUser
  • Guests
  • Last active:
  • Joined: --
Another improvement would be to limit the camera movement on the Y-axis (currently the player can rotat his head 360°), just put:

RotY := ((RotY := RotY * 120) > 90) ? 90 : (RotY < -90) ? -90 : RotY

after:

GetMouseMovement(RotX,RotY), RotX := (RotX * 120) + StartingRotation

In the Draw() function.

Uberi
  • Moderators
  • 1119 posts
  • Last active: May 02 2015 06:05 PM
  • Joined: 23 Aug 2010
Done. Rotation along the Y axis is now restricted (technically, it's the X axis though).

Also, the camera has been modified to be in the center of it's collision rectangle, for more intuitive usage and elimination of camera glitches.

iwanttolearnahk
  • Guests
  • Last active:
  • Joined: --
this is really interesting but there are some glitches :/ this is an example of how i entered one of the blocks

Posted Image

Uberi
  • Moderators
  • 1119 posts
  • Last active: May 02 2015 06:05 PM
  • Joined: 23 Aug 2010
Yes, the physics engine definitely could use some improvements. I'm nearly certain that these glitches are in how it handles collisions when you are at the exact corner of a bounding box, but I haven't been able to confirm this yet. Some new prototypes are in the works, but they are not fully functional at this time.

IsNull
  • Moderators
  • 990 posts
  • Last active: May 15 2014 11:56 AM
  • Joined: 10 May 2007

IsNull: Those tutorials were a great resource. Would you know where I could find an english version?

Currently there are just the German versions, but I already talked to Bentschi to translate some of them :)

Btw, some notes about your physics:
Find out if a collision occured is just one part, the other one - much complexer one - is to handle this collisions and glitch out the objects which are inside others, reverse movement vectors and so on.
Preview collisions can also help to avoid some lockings where the player/moveable objects never can come out.
:)

I really love this kind of programming tass but I leaved AHK in terms of makings games, as without multi threading I'm not able to separate phyiscs / rendering and gamelogic enough. I'm not the type of programmer who can handle all those different things in one Master Function :p You can see my attempts in my signature link

Uberi
  • Moderators
  • 1119 posts
  • Last active: May 02 2015 06:05 PM
  • Joined: 23 Aug 2010
I didn't have a chance to work on the physics yet, but the script has been updated on the OpenGL front, with an OpenGL status display replacing the tooltip, as well as drawing and performance improvements.

The goal graphic has also been modified. The "Goal.jpg" image will need to be deleted if you wish to have the graphic updated.

Also, scoring is working :D.