Posted: Tue Jan 04, 2011 6:31 pm Post subject: (URGENT) Need help closing window and continuing.
What is it you are trying to achieve?
I want to be able to close the console cheat engine and be able to continue the game with the cheat applied.
What is the problem you are having?
I am currently making a platform based game, but I am unable to continue to game when my console cheat feature closes. I understand that my code is still inefficient, but if you want you can comment on that too. I would upload my source code with all the pictures, however my level map itself is 88.3mb(due to its large size).
Describe what you have tried to solve this problem
I am still a noob(newcomer) to turing, however I still know things. I have tried basic stuff like exit commands, Window methods, and procedures.
Turing:
%Platformer
%Imports Classes %import TitlePageCl in "titlePage.t", DeadPageCl in "deadpage.t", WinPageCl in "winpage.t"
% Creates a window var winID :int:=Window.Open("graphics: 595;400, offscreenonly,nobuttonbar, title: Square?")
/*Creates variables for classes
var TitlePage1 : ^TitlePageCl
new TitlePage1
var DeadPage1 : ^DeadPageCl
new DeadPage1
var WinPage1 : ^WinPageCl
new WinPage1*/
% Type used for points and vectors to track type Vector : record
x :real
y :real endrecord
% Picture(s) used for background and collision detection var platform1 :int:=Pic.FileNew("platform1.bmp") var platform2 :int:=Pic.FileNew("platform2.bmp")
% Holds keyboard data var chars :arraycharofboolean var pressedChars :arraycharofboolean Input.KeyDown(chars)
pressedChars := chars
% Position and velocity of the player var pos : Vector
pos.x :=150;
pos.y :=175 var vel : Vector
vel.x :=0;
vel.y :=0
% Position of the camera var cam : Vector
cam.x :=0;
cam.y :=0
% Size of the player var size : Vector
size.x :=15;
size.y :=15
% Collision booleans and directions var isTouchingGround :boolean:=false var isTouchingWall :boolean:=false var wallDir :int:=0
%Score var scoreSeconds :int:=0
%Pause Key Variable var PauseKey :char
%Font Varialbes var font1 :int:=Font.New("Fixedsys:30") var font2 :int:=Font.New("Fixedsys:12")
%Variables for level changing var level1b :boolean:=true var level2b :boolean:=false
%Console Window and Settings(code)
var console :int:=Pic.FileNew("console.jpg") var consoleText :string var x, y, mouse :int var consoleTextFont :int:=Font.New("Arial:9") var realCommand :boolean:=false
proc consoleWindow
var winID2 :int:=Window.Open("graphics: 370;340,nobuttonbar, title: Console")
% If moving right elsif(round(vel.x) > 0)then % Does the player hit a wall? if(whatdotcolour(round(pos.x + vel.x + size.x + cam.x),round(pos.y - size.y + cam.y))=blackorwhatdotcolour(round(pos.x + vel.x + size.x + cam.x),round(pos.y + size.y +
cam.y))= black)then % Find where the player hit the wall
isTouchingWall :=true
wallDir := -1
%If Dead if pos.y - size.y < -50then %DeadPage1 -> deadPage endif
% If moving down if(vel.y < 0)then % Does the player hit a floor? if(whatdotcolour(round(pos.x - size.x + cam.x),round(pos.y + vel.y - size.y + cam.y))=blackorwhatdotcolour(round(pos.x + size.x + cam.x),round(pos.y + vel.y - size.y +
cam.y))= black)then % Find where the player hit the floor for i :round(vel.y).. 0 if(whatdotcolour(round(pos.x - size.x + cam.x),round(pos.y + i - size.y + cam.y)) ~=blackandwhatdotcolour(round(pos.x + size.x + cam.x),round(pos.y + i -
size.y +
cam.y))
~=black)then % Move the player there
pos.y :=round(pos.y) + i;
endif endfor
isTouchingGround :=true
vel.y :=0 else
pos.y += vel.y
endif % If moving up elsif(vel.y > 0)then % Does the player hit a ceiling? if(whatdotcolour(round(pos.x - size.x + cam.x),round(pos.y + vel.y + size.y + cam.y))=blackorwhatdotcolour(round(pos.x + size.x + cam.x),round(pos.y + vel.y + size.y +
cam.y))= black)then % Find where the player hit the ceiling for decreasing i :round(vel.y).. 0 if(whatdotcolour(round(pos.x - size.x + cam.x),round(pos.y + i + size.y + cam.y)) ~=blackandwhatdotcolour(round(pos.x + size.x + cam.x),round(pos.y + i +
size.y +
cam.y))
~=black)then % Move the player there
pos.y :=round(pos.y) + i;
endif endfor
vel.y :=0 else
pos.y += vel.y
endif endif
% Move camera to center it on the player
cam.x -=round((pos.x + cam.x - maxx / 2) / 10)
cam.y -=round((pos.y + cam.y - maxy / 2) / 10)
% Move downward to simulate gravity, less when against a wall if(isTouchingWall and vel.y < 0)then
vel.y -=9.8 / 30 else
vel.y -=9.8 / 10 endif
% Set a maximum speed, less against a wall if(isTouchingWall)and(vel.y < -10)then
vel.y := -10 endif
var backgroundTitle :int:=Pic.FileNew("title.jpg") var backgroundInstruction :int:=Pic.FileNew("instructions.jpg") var backgroundPassword :int:=Pic.FileNew("password.jpg") var password1 :string
loop View.Set("offscreenonly") Mouse.Where(x, y, mouse) Pic.Draw(backgroundTitle, 0, 0, picCopy) if x > 100and x < 250and y > 200and y < 230and mouse =1then
level
endif
if x > 100and x < 550and y > 140and y < 180and mouse =1then
instruction
View.Update
endif
if x > 100and x < 500and y > 80and y < 120and mouse =1then
password
View.Update exit endif View.Update endloop
end titlePage
titlePage
Please specify what version of Turing you are using
Turing 4.1.1
Sponsor Sponsor
rdrake
Posted: Tue Jan 04, 2011 6:58 pm Post subject: RE:(URGENT) Need help closing window and continuing.
Deleted your duplicate thread. Please use the edit button when possible.
kartikitrak
Posted: Tue Jan 04, 2011 7:05 pm Post subject: RE:(URGENT) Need help closing window and continuing.
I'm sorry. I just want some help with this.
TokenHerbz
Posted: Tue Jan 04, 2011 7:11 pm Post subject: RE:(URGENT) Need help closing window and continuing.
Try closing the Cheat window instead of hiding it.
Replace "Window.Hide(windowID)" from your cheat proc with "Window.Close(windowID)"
kartikitrak
Posted: Tue Jan 04, 2011 7:13 pm Post subject: RE:(URGENT) Need help closing window and continuing.
Thanks Token for the advice, however I have tried that and it doesn't seem to work. It actually seems worse than the hide because it glitches and still doesn't work.
Tony
Posted: Tue Jan 04, 2011 7:16 pm Post subject: RE:(URGENT) Need help closing window and continuing.
What kind of "unable to continue to game" are you experiencing? It might be that you are not returning the focus to the main window.
Some other notes: you are just hiding console windows, they are still there. And you are creating a new one, every time.
Also, I don't understand why you have a bunch of loops with a tail-end exit -- they never loop; seems unnecessary.
Posted: Tue Jan 04, 2011 7:18 pm Post subject: RE:(URGENT) Need help closing window and continuing.
thanks tony. However, I am unable to re-write what you said to me just know it code. I understand somewhat, what you are saying.
Also. This is what is happening. I enter console, and then I enter a cheat or just a random text and it should close automatically, however when it closes, you can't resume the actually game play. It just freezes up.
kartikitrak
Posted: Tue Jan 04, 2011 7:20 pm Post subject: RE:(URGENT) Need help closing window and continuing.
When I replace the Window.Hide with Window.Close (winID2), I get an error saying "Close of closed stream number 2" What does this mean?
Sponsor Sponsor
ClayWall
Posted: Tue Jan 04, 2011 7:21 pm Post subject: Re: (URGENT) Need help closing window and continuing.
Take Window.Hide (winID2) out of the loop and put it at the very end of the proc, and if I remember right you will have to use Window.Update on your other window if you are using offscreenonly.
Also, why do you have loops with an exit with no exit clause, this makes those loops useless.
TokenHerbz
Posted: Tue Jan 04, 2011 7:22 pm Post subject: RE:(URGENT) Need help closing window and continuing.
Yes, As tony pointed out, you have alot of un needed code in it.
Anyways, right at the END of that procedure for your cheat, try to Window.SetActive(mainWINDOW) and let me know what happens,
I'll attempt to syphon threw some of this code looking for the error, hope i dont over look it, as its not the easiest to read
kartikitrak
Posted: Tue Jan 04, 2011 7:24 pm Post subject: RE:(URGENT) Need help closing window and continuing.
thanks guy for your constructive criticism.
kartikitrak
Posted: Tue Jan 04, 2011 7:26 pm Post subject: RE:(URGENT) Need help closing window and continuing.
Okay. Token with your tips. Sadly nothing actually changes. I'm sorry if this code is messed up. I'm still a newb at turing.
kartikitrak
Posted: Tue Jan 04, 2011 7:28 pm Post subject: RE:(URGENT) Need help closing window and continuing.
good news guys. I removed the loops and the exits in the console procedures and its resuming. I'm just going to test out if the cheats apply.
Anyway. Now please comment on the GUI. and simplifing the code.
kartikitrak
Posted: Tue Jan 04, 2011 7:32 pm Post subject: RE:(URGENT) Need help closing window and continuing.
OMFG!! YOU GUYS ARE THE BEST PEOPLE EVER! IT WORKS PERFECTLY! THANKS TO TOKENHERBZ ,TONY AND CLAYWALL
Tony
Posted: Tue Jan 04, 2011 7:38 pm Post subject: RE:(URGENT) Need help closing window and continuing.
Runtime error I'm getting is "Keyboard input from invisible window is now allowed"
TokenHerbz @ Tue Jan 04, 2011 7:22 pm wrote:
Anyways, right at the END of that procedure for your cheat, try to Window.SetActive(mainWINDOW) and let me know what happens
I've tried this out, it works.
Turing 4.1 through CrossOver.
----
Edit: I seem to be off my game today. I think it's time for a nap.