| Grids, Backgrounds, Music, Movement, Interaction, and then some. 
 
	 
	
		| Author | Message |   
		| CastlevaniaBird 
 
  
 
 
 | 
			
				|  Posted: Sun Apr 03, 2011 4:59 pm    Post subject: Grids, Backgrounds, Music, Movement, Interaction, and then some. |  |   
				| 
 |  
				| What is it you are trying to achieve? Three years after I took a programming class, I forget ~95% Of my coding.  I am trying to create a game that plays roughly like Pokemon (Yeah, another knock-off.) called "Turingmon".
 Creative, right?
 Well,  that's where Compsci comes in.  I'm going to be hammering away at this, and I will be needing a lot of help.  I figured it's easiest to set up  a thread early, rather than get neck-deep in crud, get mad, and then relay that rage onto all of you.
 
 So, that's what I'll do.
 
 
 What is the problem you are having?
 First Issue to address:
 
 Organization into "for loops", as well as variable fixing.
 
 Describe what you have tried to solve this problem
 Tried a few different placements of "For"  And eventually settled without a loop, thus expanding my code way too much.
 Also, set a bunch of variables, not sure which are correct.
 
 
 Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
 Current looks of the code - yes, it's painful.   Also, tried to indent and got "NOT ENOUGH MEMORY TO INDENT", so sorry. D:
 
 	  | Turing: |  	  | 
var gender : int % Picks your gender
var  name : string % Prompts your name
var  yesno1 : int
var  playerX, playerY : int
const  GRID_SIZE : int := 16
const  MAP_PASSABLE : char := ' '
const  MAP_IMPASSABLE : char := 'X'
var  mapCols, mapRows : int
var  map :array 1 ..mapCols, 1 ..mapRows of char
var  stream : int
open : stream, "mymap", get 
get :  stream, mapCols
get :  stream, mapRows
for  r : 1 ..mapRows
    for  c :1 ..mapCols
    end for
    end for
const  SPEED : int := 5
var  bedroomstart :int := Pic.FileNew ("Bedroom2.jpg")
var  boydown : int := Pic.FileNew ("boydown.jpg")
var  boyleft : int := Pic.FileNew ("boyleft.jpg")
var  boyright : int := Pic.FileNew ("boyright.jpg")
var  boyup : int := Pic.FileNew ("boyup.jpg")
var  girldown : int := Pic.FileNew ("girldown.jpg")
var  girlleft : int := Pic.FileNew ("girlleft.jpg")
var  girlright : int := Pic.FileNew ("girlright.jpg")
var  girlup : int : =Pic.FileNew ("girlup.jpg")
var  chars : array char of boolean
var  bgheight2 : =Pic.Height ( bedroomstart)
var  picwidth1 : =Pic.Width ( boydown)
var  picwidth2 : =Pic.Width ( boyleft)
var  picwidth3 : =Pic.Width ( boyright)  %All of these widths and heights and stuff are here because I want
var  picwidth4 : =Pic.Width ( boyup)     % there to be different sprites used when you are facing
var  picwidth5 : =Pic.Width ( girldown)  % Different directions; for example, if you are going down
var  picwidth6 : =Pic.Width ( girlleft)     % I want you to be looking that way.  I think I did this wrong, no idea.
var  picwidth7 : =Pic.Width ( girlright)
var  picwidth8 : =Pic.Width ( girlup)
var  picheight1 : =Pic.Height ( boydown)
var  picheight2 : =Pic.Height ( boyleft)
var  picheight3 : =Pic.Height ( boyright)
var  picheight4 : =Pic.Height ( boyup)
var  picheight5 : =Pic.Height ( girldown)
var  picheight6 : =Pic.Height ( girlleft)
var  picheight7 : =Pic.Height ( girlright)
var  picheight8 : =Pic.Height ( girlup)
var  bgwidth2 := Pic.Width ( bedroomstart)
var  bgX := ( bgwidth2 -maxx) div 2
var  bgY := ( bgheight2 - maxy) div 2
var  x : int
var  y : int 
x := ( bgwidth2 - picwidth2) div 2 and ( bgwidth2 - picwidth1)div 2 and ( bgwidth2 - picwidth3) div 2 and ( bgwidth2 - picwidth4) div 2 and ( bgwidth2 - picwidth5) div 2 and ( bgwidth2 - picwidth6) div 2 and ( bgwidth2 - picwidth7) div 2 and ( bgwidth2 - picwidth8) div 2 
y := ( bgheight2 - picheight1) div 2 and( bgheight2 - picheight2) div 2 and( bgheight2 - picheight3) div 2 and ( bgheight2 - picheight4) div 2 and ( bgheight2 - picheight5) div 2 and( bgheight2 - picheight6) div 2 and ( bgheight2 - picheight7) div 2 and( bgheight2 - picheight8) div 2
    
setscreen ("graphics:512,256")
Draw.Box (maxx , 0 , 0 , 100 , black)
locate (11 , 15)
put "Hello! Welcome to the world of TURINGMON."
delay (2000)
locate (12 , 15)
put "My name is ALTU."
delay (2000)
locate (13 , 20)
put "People often refer to me as"
locate (14 ,20)
put "the TURINGMON PROFESSOR!"
delay (4000)
cls
Draw.Box (maxx , 0 , 0 , 100 , black)
locate (11 , 20)
loop
    put "First of all, are you a BOY or a GIRL?"
    locate (12 , 20)
    put "(1)  BOY     (2)  GIRL"
    get  gender
    cls
    Draw.Box (maxx , 0 , 0 , 100 , black)
    locate (11 , 20)
    if  gender = 1 then
        put "So you're a boy?"
        delay (1000)
        put "(1)  YES     (2)  NO"
        get  yesno1
        if  yesno1 = 1 then
            exit
        elsif  yesno1 = 2 then
        end if
    elsif  gender = 2 then
        put "So you're a girl?"
        delay (1000)
        put "(1)  YES     (2)  NO"
        get  yesno1
        if  yesno1 = 1 then
            exit
        else 
            yesno1 := 2
        end if
    end if
end loop
if  gender = 1 then
    cls
    Draw.Box (maxx , 0 , 0 , 100 , black)
    locate (11 , 20)
    put "Okay, so you're a boy!"
elsif  gender = 2 then
    cls
    Draw.Box (maxx , 0 , 0 , 100 , black)
    locate (11 , 20)
    put "Okay so you're a girl!"
    delay (2000)
    cls
end if
locate (11 , 20)
put "What's your name?"
get  name
locate (12 , 20)
put  name, ", Eh?  That's a funny name.  Oh well."
delay (2000)
cls
Draw.Box (maxx , 0 , 0 , 100 , black)
locate (11 , 20)
put  name, ", you're about to embark"
locate (12 , 20)
put "on a wonderful journey!"
locate (13 , 20)
put "Make us proud!"
delay (3000)
cls
colorback (31)
cls
delay (50)
colorback (30) %needs
cls
delay (50)
colorback (29)  %more
cls
delay (50)
colorback (28)  %for
cls
delay (50)
colorback (27) %loop
cls
delay (50)
colorback (26)
cls
delay (50)
colorback (25)
cls
delay (50)
colorback (24)
cls
delay (50)
colorback (23)
cls
delay (50)
colorback (22)
cls
delay (50)
colorback (21)
cls
delay (50)
colorback (20)
cls
delay (50)
colorback (19)
cls
delay (50)
colorback (18)
cls
delay (50)
colorback (16)
cls
delay (3000)
cls
colorback (white)
cls
if  gender = 1 then
loop 
loop
cls
Pic.Draw ( bedroomstart, -bgX, -bgY, picCopy)
Pic.Draw ( boydown, x-bgX, y-bgY, picMerge)
View.Update
if hasch then
    var  ch : string (1)
    getch ( ch)
    if  ch = KEY_UP_ARROW then 
    y +=  SPEED
    if  y - bgY + picheight1 > maxy then 
        bgY :=  y + picheight1 - maxy
        end if
        elsif  ch = KEY_DOWN_ARROW then 
        y -=  SPEED
        if  y < bgY then 
        bgY :=  y
        end if
        elsif  ch = KEY_LEFT_ARROW then 
        x -=  SPEED
        if  x < bgX then 
            bgX :=  x
            end if
            elsif  ch = KEY_RIGHT_ARROW then 
            x +=  SPEED
            if  x - bgX + picwidth1 > maxx then 
            bgX :=  x + picwidth1 - maxx
            end if
            end if
            end if
            end loop
    
end loop
elsif  gender = 2 then
loop
Pic.Draw ( bedroomstart, -bgX, -bgY, picCopy)
Pic.Draw ( girldown, x-bgX, y-bgY, picMerge)
View.Update
if hasch then
    var  ch : string (1)
    getch ( ch)
    if  ch = KEY_UP_ARROW then 
    y +=  SPEED
    if  y - bgY + picheight1 > maxy then 
        bgY :=  y + picheight1 - maxy
        end if
        elsif  ch = KEY_DOWN_ARROW then 
        y -=  SPEED
        if  y < bgY then 
        bgY :=  y
        end if
        elsif  ch = KEY_LEFT_ARROW then 
        x -=  SPEED
        if  x < bgX then 
            bgX :=  x
            end if
            elsif  ch = KEY_RIGHT_ARROW then 
            x +=  SPEED
            if  x - bgX + picwidth1 > maxx then 
            bgX :=  x + picwidth1 - maxx
            end if
            end if
            end if
            end loop
          
end if | 
 
 Please specify what version of Turing you are using
 4.1.1
 |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| Sponsor Sponsor
 
  
   |  |   
		|  |   
		| Raknarg 
 
  
 
 
 | 
			
				|  Posted: Sun Apr 03, 2011 5:59 pm    Post subject: RE:Grids, Backgrounds, Music, Movement, Interaction, and then some. |  |   
				| 
 |  
				| 1: Your picwidth and picheight are redundant, as you can call them as they are in your variable settings. Instead of having a vairable for picheight1, you could just call Pic.Height (picture). 2: Instead of having a different variable for every picture, use one string. Remember that the Pic.FileNew is asking for a string, so you can replace that with a variable. To do that, you would just call a new picture every time the direction changes, and replace the string with the new picture
 3: I see you use (bgwidth2 - picwidth2) div 2 and (bgwidth2 - picwidth1)div 2 and.... so on. I don't think you can do that; if you're trying to add them, use +.
 
 I would fix those things first.
 |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| CastlevaniaBird 
 
  
 
 
 | 
			
				|  Posted: Sun Apr 03, 2011 6:06 pm    Post subject: RE:Grids, Backgrounds, Music, Movement, Interaction, and then some. |  |   
				| 
 |  
				| Well, the movement works so far, so I think that coding works, but yes, it's ugly as sin. 
 Also, all of that picheight variable-ism isn't needed?  I can just take it all out?
 
 Finally, I don't remember enough from class two years ago to call a picture from a string.  Any reminders?
 
 Thanks.
 |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| Raknarg 
 
  
 
 
 | 
			
				|  Posted: Sun Apr 03, 2011 6:11 pm    Post subject: RE:Grids, Backgrounds, Music, Movement, Interaction, and then some. |  |   
				| 
 |  
				| kk. So no, you don't need a variable for Pic.Height. You can I suppose, but that's why there's a predefined function for it.
 
 And calling a picture is generally something people don't teach it seems, I thought of it myself (though obviously I don't take credit for inventing it, I'm sure others have discovered it
  ) 
 Ex.
 var picname : string := "Bedroom2.jpg"
 var pic : int := Pic.FileNew (picname)
 
 That way you only need 2 variables: one for the picture name and one for the actual picture.
 |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| Tony 
 
  
 
 
 | 
			
				|  Posted: Sun Apr 03, 2011 6:14 pm    Post subject: RE:Grids, Backgrounds, Music, Movement, Interaction, and then some. |  |   
				| 
 |  
				| You can catch up on Turing with The Turing Walkthrough. It will definitely be helpful. 
 Reconsider your design. It would be very helpful to have the game be driven by a single "main loop" and have various levels of abstraction. You'd definitely want to have things like dialogs to be coming from data files rather than code.
 |  
				|  Tony's programming blog. DWITE - a programming contest. |  |   
		|  |  |  
	  
		|  |   
		| CastlevaniaBird 
 
  
 
 
 | 
			
				|  Posted: Sun Apr 03, 2011 6:19 pm    Post subject: RE:Grids, Backgrounds, Music, Movement, Interaction, and then some. |  |   
				| 
 |  
				| Now mentioning that dialog from separate files does sound a lot easier - I don't recall them teaching me that when I took the course - but that was also two years ago.  Looking at what I'm reading, It sounds easier to scrap the code I've got now and start from scratch. 
 On that note, the Turing Tutorial link is what got me to where I was in my program, haha.  A bit to wrap my head around in two hours, but still, I bookmarked the link for when I either restart or progress on my program.
 |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| Tony 
 
  
 
 
 | 
			
				|  Posted: Sun Apr 03, 2011 6:33 pm    Post subject: RE:Grids, Backgrounds, Music, Movement, Interaction, and then some. |  |   
				| 
 |  
				| Strong suggestion for such a large project -- set yourself up with source control system. GitHub has free accounts for students -- https://github.com/edu 
 It might be some work to set it up and get used to the workflow, but it's basically a requirement in real world, and will save your project when you accidentally overwrite a file, or your hard-drive crashes.
 |  
				|  Tony's programming blog. DWITE - a programming contest. |  |   
		|  |  |  
	  
		|  |   
		| CastlevaniaBird 
 
  
 
 
 | 
			
				|  Posted: Sun Apr 03, 2011 6:35 pm    Post subject: RE:Grids, Backgrounds, Music, Movement, Interaction, and then some. |  |   
				| 
 |  
				| Thanks for the suggestion. I'll check it out.  +Karma.  (at least, +Karma when I get 25 points.  Hahaha.) |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| Sponsor Sponsor
 
  
   |  |   
		|  |   
		|  |  
 |