Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Weird Little Problem
Index -> Programming, Turing -> Turing Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
TheFerret




PostPosted: Sat Feb 21, 2004 12:28 am   Post subject: Weird Little Problem

In my program (like Ledgend of Zelda) when my guy hits the wall his head and eyes keep going over but the rest of the body stays there until you relase the over button, if you hit over once against the wall he gets meesed up but if you hit over again or hit over twice against a wall he is normal... (Replace over with right) Use the right wall to test... Also if m guy kills an emeny with his sword the enemey will turn red but the problem is that when he is under or beside him, the enemy changes colout, is there a way to get it when the tip of his sword goes in him to make him change colour not when the sword is beside him or below him...

P.S. What do you think about me and my friends program...(Right now when you go down in the center divider he gets messed up, I have to fix it later...)

.BMP in next post...



bckgrnd.zip
 Description:
.BMP file for background...

Download
 Filename:  bckgrnd.zip
 Filesize:  8.48 KB
 Downloaded:  240 Time(s)


background.t
 Description:
My program...

Download
 Filename:  background.t
 Filesize:  5.18 KB
 Downloaded:  243 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
Cervantes




PostPosted: Sat Feb 21, 2004 9:33 am   Post subject: (No subject)

wow your code is very messy and almost all of it is unecessary Neutral

Instead of having variables for his head and sword and all that, you have to do the following:

draw a few pictures of him in paint (facing various angles, attacking or not)
then import those pictures like so
code:

var zelda : int := Pic.New ("Zelda")


use case for animations
jonos




PostPosted: Sat Feb 21, 2004 9:40 am   Post subject: (No subject)

edit: wow cervants is too damn quick

i didn't take a really long look at your code, but you should make the figure (link???) a picture and then use that to move, becaue when it is all in separate parts it can fall apart (and does). nice first level.

one more thing you should add:
in your if statements for the amount the character should move, you should lessen the amount (i put it to 5 and it worked fine), as well you should make that amount a constant (const). also, you could get rid of some of the if statements and just do all the j := j+15, k:= k+15 in one if statment, then you wouldn't need al lthose if statements.
you have it

if chars (KEY_UP_ARROW) then
k := k + 5
end if
if chars (KEY_UP_ARROW) then
b := b + 5
end if
if chars (KEY_UP_ARROW) then
i := i + 5
end if
if chars (KEY_UP_ARROW) then
m := m + 5
end if

you might want to change it to:
if chars (KEY_UP_ARROW) then
k := k+5
b := b+5
i := i+5
m := m+5
end if

im not sure if how you have it is needed for your game, maybe im missing something, but that is the way i would do.

anyways, nice program and nice start!!!
GUI.GetScrollBarWidth : i




PostPosted: Sat Feb 21, 2004 7:27 pm   Post subject: (No subject)

that cool i like legand of zelda
TheFerret




PostPosted: Sun Feb 22, 2004 9:29 pm   Post subject: (No subject)

When I use
Quote:
var zelda : int := Pic.New ("Zelda")
for a picture and try to run it is says there is an error and will not run it, whyor what do I have to put...
Paul




PostPosted: Sun Feb 22, 2004 9:33 pm   Post subject: (No subject)

include file extension, whatever it is. like zelda.bmp or zelda.jpg and the pic also has to be in the same folder where you're saving the .t file.
TheFerret




PostPosted: Sun Feb 22, 2004 9:49 pm   Post subject: (No subject)

It says argument is wrong type
code:
var test : int := Pic.New ("test.bmp")
Paul




PostPosted: Sun Feb 22, 2004 10:03 pm   Post subject: (No subject)

oh yea that too
code:

var cash := Pic.FileNew ("cash.bmp")

no int. if you type Pic.FileNew and press F9 it tells you.[/code]
Sponsor
Sponsor
Sponsor
sponsor
TheFerret




PostPosted: Sun Feb 22, 2004 10:18 pm   Post subject: (No subject)

when I put
code:
var test := Pic.FileNew ("test.bmp")
put test
all it outputs is 7001 an dit does not put my picture...
Paul




PostPosted: Sun Feb 22, 2004 10:28 pm   Post subject: (No subject)

Yea, you have to draw the pic too, its in the help file.
code:

var test := Pic.FileNew ("test.bmp")
Pic.Draw (test, 75, 10, picMerge)
TheFerret




PostPosted: Sun Feb 22, 2004 10:57 pm   Post subject: (No subject)

Ok, I shortened up the code a lot to 111 lines and I am wondering how to get a circle to be drawn over the enemy when the guys sword goes in him... I have tried
code:
      % if l >= 285 and l <= 315 then
        %     ene := 1
        % elsif m >= maxy - 90 and m <= maxy - 60 then
        %     ene := 1
        % end if
        % if ene = 1 then
        %     drawfilloval (300, maxy - 75, 15, 15, 12)
        % end if 
(don't worry about comments) but that does not work, all it does is if my guy is anywhere between 285 and 315 on the screen the enemy will turn red... All I want to happen is only when his sword goes in...
jonos




PostPosted: Mon Feb 23, 2004 7:22 am   Post subject: (No subject)

post the new code with your attempt at the enemy circle thing, but this should help:
i don't know the sword action but id say something like this might help:

if the user presses the sword button then
if the user is within a certain area away from the enemy then
kill/injure enemy
end if
end if
TheFerret




PostPosted: Mon Feb 23, 2004 4:04 pm   Post subject: (No subject)

Here is the code... The test BMP is the guy... NB: You have to declare the var for the damage, I do not have it in because I do not need it now...

code:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% The Ledgend of Janet: Tom's Story...
%%% Made by Nathan Boucher & Travis Baker...
%%% Feb. 17, 2004
%%% Version 0.3
%%% Use the arrow keys to move Tom around the screen and space to swing sword...
%%% Grade 10 Computer Sciences & Technologies...
%%% (c)2004 B&B Inc.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
setscreen ("graphics:500;500")
var x, y, key, ene, change : int
var chars : array char of boolean
x := 180
y := 370
ene := 0
%How many keys he has.
key := 0
change := 5
loop
    View.Set ("offscreenonly")
    View.Update
    Input.KeyDown (chars)

    if chars (KEY_UP_ARROW) then
        y := y + change

    end if
    if chars (KEY_RIGHT_ARROW) then
        x := x + change

    end if
    if chars (KEY_LEFT_ARROW) then
        x := x - change

    end if
    if chars (KEY_DOWN_ARROW) then
        y := y - change

    end if
    % if chars (' ') then
    %     l := l + change
    % elsif chars (' ') then
    %     m := m - 50
    % elsif chars ('w') then
    %     l -= 15
    % elsif chars ('w') then
    %     m += 50
    %end if
    %Right Wall Detection
    if x >= 407 then
        x -= change

    end if
    %Bototm wall detection
    if y <= 80 then
        y += change
    end if
    if x <= 40 then
        x += change
    elsif y <= 40 then
        y += change

    end if
    if y >= maxy - 95 then
        y -= change

    end if
    if y <= 275 then
        y += change
    end if

    %drawbox (49, 59, 451, 461, 0) %Wall boundry
    %drawbox (49, 280, 451, 461, 0) %Top part of level boundry
    var test := Pic.FileNew ("test.bmp")
    Pic.ScreenLoad ("Zelda1.bmp", 0, 0, picCopy)
    Pic.Draw (test, x, y, picMerge)
    %enemy
    drawfilloval (300, maxy - 75, 15, 15, 124)
    drawfilloval (285, maxy - 65, 5, 5, 4)
    drawfilloval (315, maxy - 65, 5, 5, 4)
    drawfilloval (300, maxy - 75, 5, 5, 17)
    drawbox (49, 280, 451, 461, 0)
%%%%%%%%BELOW HERE IS ENEMY DAMAGE FOR COMPSCI.CA%%%%%%%%%%
     if l >= 285 and l <= 315 then
         ene := 1
     elsif m >= maxy - 90 and m <= maxy - 60 then
         ene := 1
     end if
     if ene = 1 then
         drawfilloval (300, maxy - 75, 15, 15, 12)
     end if
end loop



test.zip
 Description:
Guy...

Download
 Filename:  test.zip
 Filesize:  532 Bytes
 Downloaded:  219 Time(s)

Paul




PostPosted: Mon Feb 23, 2004 4:22 pm   Post subject: (No subject)

first, l and m are not declared, so I figured that thats the position of the sword, I just made their values basically somewhere around the point of the sword.
Maybe this is what you want
oh yea, also clear the previous pic when you move it.
also, notice I moved the var test:=Pic.Filenew... part out of the loop or else it maxes out and stops in like 1 min, cause it created 1000 pics
code:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% The Ledgend of Janet: Tom's Story...
%%% Made by Nathan Boucher & Travis Baker...
%%% Feb. 17, 2004
%%% Version 0.3
%%% Use the arrow keys to move Tom around the screen and space to swing sword...
%%% Grade 10 Computer Sciences & Technologies...
%%% (c)2004 B&B Inc.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
setscreen ("graphics:500;500")
    var test := Pic.FileNew ("test.bmp")
var l,m,x, y, key, ene, change : int
var chars : array char of boolean
x := 180
y := 370
ene := 0
%How many keys he has.
key := 0
change := 5
loop
    View.Set ("offscreenonly")
    View.Update
    Input.KeyDown (chars)

    if chars (KEY_UP_ARROW) then
        y := y + change

    end if
    if chars (KEY_RIGHT_ARROW) then
        x := x + change

    end if
    if chars (KEY_LEFT_ARROW) then
        x := x - change

    end if
    if chars (KEY_DOWN_ARROW) then
        y := y - change

    end if
    % if chars (' ') then
    %     l := l + change
    % elsif chars (' ') then
    %     m := m - 50
    % elsif chars ('w') then
    %     l -= 15
    % elsif chars ('w') then
    %     m += 50
    %end if
    %Right Wall Detection
    if x >= 407 then
        x -= change

    end if
    %Bototm wall detection
    if y <= 80 then
        y += change
    end if
    if x <= 40 then
        x += change
    elsif y <= 40 then
        y += change

    end if
    if y >= maxy - 95 then
        y -= change

    end if
    if y <= 275 then
        y += change
    end if

    %drawbox (49, 59, 451, 461, 0) %Wall boundry
    %drawbox (49, 280, 451, 461, 0) %Top part of level boundry

    Pic.ScreenLoad ("Zelda1.bmp", 0, 0, picCopy)
    Pic.Draw (test, x, y, picMerge)
    %enemy
    drawfilloval (300, maxy - 75, 15, 15, 124)
    drawfilloval (285, maxy - 65, 5, 5, 4)
    drawfilloval (315, maxy - 65, 5, 5, 4)
    drawfilloval (300, maxy - 75, 5, 5, 17)
    drawbox (49, 280, 451, 461, 0)
%%%%%%%%BELOW HERE IS ENEMY DAMAGE FOR COMPSCI.CA%%%%%%%%%%
l:=x+45
m:=y+45
     if l >= 285 and l <= 315  and m >= maxy - 90 and m <= maxy - 60then
         ene := 1
     
     end if
     if ene = 1 then
         drawfilloval (300, maxy - 75, 15, 15, 12)
     end if
end loop
TheFerret




PostPosted: Mon Feb 23, 2004 4:27 pm   Post subject: (No subject)

I can get the guy to erase by using
code:
ene := 1
if x<=275 and x>=245 or y<=maxy-50 and y>=maxy-80 then
ene:=0
end if
if ene=1 then
    drawfilloval (300, maxy - 75, 15, 15, 124)
    drawfilloval (285, maxy - 65, 5, 5, 4)
    drawfilloval (315, maxy - 65, 5, 5, 4)
    drawfilloval (300, maxy - 75, 5, 5, 17)
   else end if
but if you go anywhere where x<=275 and greater than 245 but if I put if x<=275 and x>=245 and(instead of or) y<=maxy-50 and y>=maxy-80 then the enemey will not delete...
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 20 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: