Knuckle Cracker

Creeper World 3 => The Coder's Corner => Topic started by: robgw3 on June 15, 2014, 08:33:59 PM

Title: Question about controlling screen position
Post by: robgw3 on June 15, 2014, 08:33:59 PM
Just curious, is there any way to fix the position of the screen so the player cant scroll the map? Or a way you could hide units? I was thinking of a map that would require one of those two options, sort of like a game of Battleship. You would have a small grid on your side of the map with a larger grid mirroring it. The enemy would have the same. You would place a tower down on your mini grid somewhere, and it would fire a spore at the corresponding location on the enemies grid where it would destroy something if it's there, and do nothing if there isn't. The enemy would do the same to you. It would of course only work if you couldn't see the enemy units though.
Title: Re: Question about controlling screen position
Post by: planetfall on June 15, 2014, 09:16:05 PM
You can make crpl cores that look like the terrain, then set their Z position so they are in front of the units.
Title: Re: Question about controlling screen position
Post by: Relli on June 16, 2014, 09:28:54 AM
Or you could make those towers CRPLCores directly, and make them invisible through one of several methods, like setting alpha value to 0. I believe you can fix the screen position too, but I think it requires undocumented CRPL features.
I like this idea of yours, and I'd love to see it completed some day. Best of luck to you.
Title: Re: Question about controlling screen position
Post by: stewbasic on June 16, 2014, 10:37:07 AM
You can use

EnableAlternateControlMode(TRUE)
EnableNormalZoomControl(FALSE)
SetCameraZoom(0)

to prevent the player from scrolling or zooming out, but the amount of map visible on the screen still depends on the size of the game window. Hiding the units is a much better option, just use a core and set its image to "None" until you're ready to display it.
Title: Re: Question about controlling screen position
Post by: Flabort on June 16, 2014, 03:23:41 PM
Either SetCameraPosition picks the coordinates of the top left corner of the screen, in which case, use the first script, or else it sets the coords of the middle of the screen, in which case use the second.
0 0 SetCameraPosition

:Awake
TRUE operateWhilePaused
4 SetCameraZoom
FALSE enableNormalZoomControl


MapWidth 2 Div MapHeight 2 Div SetCameraPosition

:Awake
TRUE operateWhilePaused
4 SetCameraZoom
FALSE enableNormalZoomControl


This will freeze the screen to it's position; nothing the player does will be able to move it.
Title: Re: Question about controlling screen position
Post by: robgw3 on June 17, 2014, 03:09:02 AM
Glad to see some interest in this idea, I haven't actually tried coding anything yet, barely even attempted making my own map. But this idea is something similar to what I have done in javascript. The only problem I see with the idea is translating the selected location to the target location. Not sure exactly how that would work because I figure I can get the coordinates of the selected location by having the player put down a tower or something and getting the location from that, but how to change that to the location for the tower to fire to would require somehow matching up the locations. Like if you place a tower at position 1,1 then it fires to position 101,101 just for example.
Title: Re: Question about controlling screen position
Post by: Relli on June 17, 2014, 09:25:37 AM
I have absolutely no experience with them personally, but I think you could use lists to bind together the selected and target locations. Maybe two lists that both hold the coordinates of their respective zones, and when you built something on the select zone, it would look for the same "list element" on the other list for the target zone. Hope that helps you out.
Title: Re: Question about controlling screen position
Post by: robgw3 on June 19, 2014, 02:35:46 PM
I know a couple of ways to do it in other programming languages (I'm a beginner programmer), but not sure if they would work in this language. I could do it with an if statement, but that would be a very long list that would get longer the more locations there is.