Pool table tutorial question

SingleSparqSingleSparq Member Posts: 1,339
edited November -1 in Working with GS (Mac)
Hi, (codemonkey) I tried to apply what you have done on the pool table tutorial for my game but am having issues.

I've added the actors for Arrow, Reticule and Connector (BTW - should these be actual image represented actors?) and the cueball but I see a line or arrow showing up and all I'm getting is that it takes a few mouse clicks on the ball that makes it go back and forth one direction - I have no drag direction control.

The only clue to an where the issue lies is in cueball where the change velocity setting is vectorToAngle( game.CueX - game.ReticuleX , game.CueY - game.ReticuleY ) seems to have the same effect as if it were just 0 - putting a number like 30 at lease changes the ball to move that direction but not exactly what were trying to achieve here.

As I have poured over the code to see what I may have put in wrong I can see no issues.

Note in the tutorial it says:
'CueX : Cueball's X position (real type)
CueY : Cueball's Y position (real type)
SettingShot : Boolean signifying if you are lining up your shot
ReticuleX : X Position of the mouse at all times (real type)
ReticuleY : Y Position of the mouse at all times (real type)'

I'm assuming were not changing the values there unless instructed.

Any thought to what the problem might be?

Comments

  • ktfrightktfright Member Posts: 964
    try to download the pool table file if you didn't already, and see what is there.
  • SingleSparqSingleSparq Member Posts: 1,339
    The only downloadable file is the game - not the Game Salad file where it can be opened up in Game salad (unless you know something I don't)
  • ktfrightktfright Member Posts: 964
    When you find the games that have that download file ( a blue button when you are playing in the games section) right click and download linked file. When you downloaded it, change the end from .game to .zip, and it will change to a zip file. Open up the zip, and you should have a .gameproj file or something like that. Open it and you are good to go. Hoped I helped a bit.
  • SingleSparqSingleSparq Member Posts: 1,339
    Thanks!!! That is very good info I had not heard I will try that. Thanks again.
  • SingleSparqSingleSparq Member Posts: 1,339
    Okay now that I got that straightened out, I have a new problem. The pool demo is in a controlled dimensional area (480 x 320) if I make the area bigger (1000h x 600 w) and add a follow camera to the ball it puts the whole mechanics of the pull string on ball out of whack.

    The arrow, connector and crosshair stay stationary and need to move to the position that the ball ends up (I think) to avoid the problem. Any thoughts on how this could be achieved?
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
  • SingleSparqSingleSparq Member Posts: 1,339
    Thanks - this is helping. The mechanics of the ball is working just haven't got the instances of the arrow, crosshair and connector to follow just yet. Will keep fiddling and see. Thanks again.
  • SingleSparqSingleSparq Member Posts: 1,339
    Well been trying to figure this out but as coding is not my thing have been failing miserably. I have uploaded a test ( http://gamesalad.com/game/play/25746) with the ball going beyond it's normal screen area (unlike the set scene area of a pool table). Anyone care to figure out how to keep the ball, crosshair, connector and arrow to all follow together wherever the ball lands (and to act as it should each time - not having the connector stretched out etc.)?

    I played around with Current Scene → Camera → Origin on the actors independent of the prototype but it went all bad.
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    Okay, so if you are just taking my Pool table example, it does not account for the position of the camera.

    Take a look at this expression that was in the reticule actor:
    game.CueX +min(100, magnitude( game.CueX - game.Mouse.Position.X , game.CueY - game.Mouse.Position.Y ))*cos( vectorToAngle( game.Mouse.Position.X - game.CueX , game.Mouse.Position.Y - game.CueY ))

    Assuming your mouse is always in the viewable area of the screen, its values area always between 0 and 480 on the X axis and 0 and 320 on the Y axis.

    Now if you take the instructions from the link I sent in a previous reply, use the OffsetX and OffsetY defined there in the expression so it looks like:

    game.CueX +min(100, magnitude( game.CueX - game.Mouse.Position.X + game.OffsetX , game.CueY - game.Mouse.Position.Y+game.OffsetY ))*cos( vectorToAngle( game.Mouse.Position.X + game.OffsetX - game.CueX , game.Mouse.Position.Y + game.OffsetY - game.CueY ))

    I think that should work.
  • SingleSparqSingleSparq Member Posts: 1,339
    Thanks for your reply - So in the reticule actor it currently has 4 constrain attributes - game.reticuleX/Y and self.positionX/Y. So I am to add 2 more constraints with offsetX/Y as the tutorial suggests or alter one of the current sets?

    Then add the formula you suggest above to the offset constraints? Does this only apply to the reticule or must it be applied to other actors like cueball/arrow/connector?

    Thanks for your help on this (once this is working it should be posted as a possible tutorial - good for larger scroll field games like a sim soccer or sim football)
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    It might be better to have a separate actor instance control the constrains of the camera position so you can know which actor will be the modified instance and easily find it. If you modify the instance of the reticule, any changes you make to the prototype will not happen, and you'd need fix that actor again.

    Once you have game attributes that contain the camera offset, modify any actor that may require the mouse position for expressions.
  • SingleSparqSingleSparq Member Posts: 1,339
    Yeah I'm still not getting it, hopefully we'll see a published book for Game Salad some day so fuffs like me can grasp the concepts better. I'm going to stop and maybe come back to it when I have more experience. I have another "engine" that's starting to work so I'll concentrate on that for now. I do thank you for your time and help CodeMonkey.
Sign In or Register to comment.