Making a cricle follow the x and y of another
| Author |
Message |
mobin12
|
Posted: Tue Jan 03, 2012 8:12 pm Post subject: RE:Making a cricle follow the x and y of another |
|
|
so for the enemy how do i make it disappear forever? 'cause i got it to disappear but its still there u just cant see it
also does the background have to be in a zip along with the code? |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
Dreadnought
|
Posted: Tue Jan 03, 2012 9:13 pm Post subject: Re: Making a cricle follow the x and y of another |
|
|
What exactly do you mean when you say "disappear forever"? Because disappearing and not seeing it are basically the same thing in my mind.
For your second question, any picture or sound files used by the program must be kept in the same folder (or at least on the same filepath) relative to the program in order to run the program. Making a zipped folder containing everything is a good way to keep everything as a package. |
|
|
|
|
 |
Raknarg

|
Posted: Wed Jan 04, 2012 12:27 pm Post subject: RE:Making a cricle follow the x and y of another |
|
|
There is no way to destroy the enemy; What you can do is make it so the program, aftger the enemy is hit, no longer intereacts witht eh enemy.
When I say this, it means that you have something keeping track of it. If the enemy is alive, then move him/shoot bullets/drawing/etc. If enemy is dead, then don't do any of those things. Something like this
| Turing: |
if enemyLive then
do_stuff ()
end if
|
Thats the basic idea |
|
|
|
|
 |
mobin12
|
Posted: Fri Jan 06, 2012 7:27 pm Post subject: RE:Making a cricle follow the x and y of another |
|
|
| alright so how would i make an intro and then the player would hit 'enter' and then the game would start |
|
|
|
|
 |
Dreadnought
|
Posted: Fri Jan 06, 2012 8:55 pm Post subject: Re: Making a cricle follow the x and y of another |
|
|
| Well, you have to make an intro screen with graphics obviously (that's not your problem I think). Next you need to check if the user pressed enter. You may be using a loop if the intro screen is animated. In that case you should be able to check for key strokes in the same way you check for WASD and space in you game (using Input.KeyDown). You can also look at the other input functions in the documentation. |
|
|
|
|
 |
Raknarg

|
Posted: Fri Jan 06, 2012 11:07 pm Post subject: RE:Making a cricle follow the x and y of another |
|
|
Fairly simple idea:
| Turing: |
loop
intro()
exit when key (KEY_ENTER)
end loop
loop
game()
end loop
|
something like that |
|
|
|
|
 |
mobin12
|
Posted: Sun Jan 08, 2012 6:15 pm Post subject: RE:Making a cricle follow the x and y of another |
|
|
| ok so i did that know i tried putting the 'intructions loop' in between the 'intro loop' and the 'game loop' but it never showed the intructions pic that i made |
|
|
|
|
 |
Dreadnought
|
Posted: Sun Jan 08, 2012 6:51 pm Post subject: Re: Making a cricle follow the x and y of another |
|
|
| Was it erased immediately by the game? |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
mobin12
|
Posted: Mon Jan 09, 2012 10:36 am Post subject: RE:Making a cricle follow the x and y of another |
|
|
no once i clicked to go to the instrucions it would still show the 'intro pic' and then i would have to click a bit lower to start the game but only i know where to click
if other people play they would get confused |
|
|
|
|
 |
Dreadnought
|
Posted: Mon Jan 09, 2012 12:06 pm Post subject: Re: Making a cricle follow the x and y of another |
|
|
| Well, without knowing what your code looks like its hard to be very helpful. I suppose my second guess would be that maybe you forgot to put a View.Update line. |
|
|
|
|
 |
mobin12
|
Posted: Mon Jan 09, 2012 4:20 pm Post subject: Re: Making a cricle follow the x and y of another |
|
|
well actually i tried the 'View.Update' but it didn't work out so well. But anyways here is my code.
| code: |
setscreen ("graphics:900;550")
%Anti-flicker command
View.Set ("offscreenonly")
var chars : array char of boolean
var enemy, player : array 1 .. 3 of int
enemy (1) := 15
enemy (2) := 15
enemy (3) := 1
player (1) := 450
player (2) := 275
player (3) := 1
var mx, my, b : int
var shockwaveValue : array 1 .. 4 of int
shockwaveValue (3) := 1
shockwaveValue (4) := 0
var space : int := 0
var count : int := 3
var health : int := 215
var intro : int := Pic.FileNew ("Game-Intro.jpg")
var instructions : int := Pic.FileNew ("Game-Instructions.jpg")
var background : int := Pic.FileNew ("Game-Background.jpg")
var bullet : array 1..2 of int
bullet(1) := 50
bullet(2) := 0
%THE INTRO
loop
Pic.Draw (intro, 0, 0, picMerge)
mousewhere (mx, my, b)
exit when mx > 288 and mx < 634 and my > 185 and my < 234 and b = 1
end loop
%THE INSTRUCTIONS
loop
Pic.Draw (instructions, 0, 0, picMerge)
mousewhere (mx, my, b)
exit when mx > 242 and mx < 694 and my > 104 and my < 170 and b = 1
end loop
%THE GAME
loop
%Draw the background for the game
Pic.Draw (background, 0, 0, picMerge)
%Draw the player
if player (3) = 1 then
drawfilloval (player (1), player (2), 10, 10, 54)
drawfilloval (player (1), player (2), 8, 8, 55)
end if
if enemy (3) = 1 then
drawfilloval (enemy (1), enemy (2), 7, 7, 41)
elsif enemy (3) = 0 then
enemy (1) := 15
enemy (2) := 15
drawfilloval (enemy (1), enemy (2), 7, 7, 41)
enemy (3) := 1
end if
Input.KeyDown (chars)
%Player controls
if chars (KEY_LEFT_ARROW) and player (1) > 48 then
player (1) := player (1) - 2
end if
if chars (KEY_RIGHT_ARROW) and player (1) < 851 then
player (1) := player (1) + 2
end if
if chars (KEY_UP_ARROW) and player (2) < 472 then
player (2) := player (2) + 2
end if
if chars (KEY_DOWN_ARROW) and player (2) > 49 then
player (2) := player (2) - 2
end if
% Attempt on enemy follow
if player (1) > enemy (1) then
enemy (1) := enemy (1) + 1
end if
if player (1) < enemy (1) then
enemy (1) := enemy (1) - 1
end if
if player (2) > enemy (2) then
enemy (2) := enemy (2) + 1
end if
if player (2) < enemy (2) then
enemy (2) := enemy (2) - 1
end if
%Shockwave
if chars (KEY_SHIFT) and count > 0 and space = 0 then
shockwaveValue (1) := player (1)
shockwaveValue (2) := player (2)
shockwaveValue (3) := 1
shockwaveValue (4) := 1
count := count - 1
space := 1
end if
if not chars (KEY_SHIFT) then
space := 0
end if
%Display amount of shockwaves that are left
if count = 3 then
drawoval (198, 538, 7, 7, 39)
drawoval (198, 538, 8, 8, 39)
drawoval (222, 538, 7, 7, 39)
drawoval (222, 538, 8, 8, 39)
drawoval (245, 538, 7, 7, 39)
drawoval (245, 538, 8, 8, 39)
end if
if count = 2 then
drawoval (198, 538, 7, 7, 39)
drawoval (198, 538, 8, 8, 39)
drawoval (222, 538, 7, 7, 39)
drawoval (222, 538, 8, 8, 39)
end if
if count = 1 then
drawoval (198, 538, 7, 7, 39)
drawoval (198, 538, 8, 8, 39)
end if
if count = 0 then
end if
%Firing the bullets
mousewhere (mx, my, b)
if b = 1 and bullet(2) = 0 then
drawline (player (1), player (2), mx, my, 40)
end if
%Enemy collision with shockwave
if enemy (1) <= shockwaveValue (3) then
enemy (3) := 0
end if
if enemy (2) <= shockwaveValue (3) then
enemy (3) := 0
end if
%Enemy collision with bullet
if mx = (enemy (1) + 7) and b = 1 and bullet(2) = 0 then
enemy (3) := 0
end if
if my = (enemy (2) + 7) and b = 1 and bullet(2) = 0 then
enemy (3) := 0
end if
%Enemy collision with player and player health
drawfillbox (395, 528, 394 + health, 542, 46)
if enemy (3) = 1 and enemy (1) - 7 <= (player (1) + 12) and enemy (1) + 7 >= (player (1) - 12) and enemy (2) - 7 <= (player (2) + 12) and enemy (2) + 7 >= (player (2) - 12) and health >= 0
then
health := health - 1
end if
if health = 0 then
player (3) := 0
end if
%Draw the shockwaves
if shockwaveValue (4) = 1 then
drawoval (shockwaveValue (1), shockwaveValue (2), shockwaveValue (3), shockwaveValue (3), 41)
shockwaveValue (3) := shockwaveValue (3) + 7
drawoval (shockwaveValue (1), shockwaveValue (2), shockwaveValue (3), shockwaveValue (3), 40)
shockwaveValue (3) := shockwaveValue (3) + 7
drawoval (shockwaveValue (1), shockwaveValue (2), shockwaveValue (3), shockwaveValue (3), 39)
shockwaveValue (3) := shockwaveValue (3) + 7
if shockwaveValue (3) >= 1000 + 5 then
shockwaveValue (4) := 0
end if
end if
bullet(2) := bullet(2) + 1
if bullet(2) >= bullet(1) then
bullet(2) := 0
end if
%Anti-flicker command
View.Update
%Slow the program down
Time.Delay (8)
%Clear the screen for the next loop
cls
exit when player (3) = 0
end loop
|
|
|
|
|
|
 |
mobin12
|
Posted: Mon Jan 09, 2012 4:25 pm Post subject: Re: Making a cricle follow the x and y of another |
|
|
Here is the part i need help with. The switch from the intro to the instructions.
| code: |
%THE INTRO
loop
Pic.Draw (intro, 0, 0, picMerge)
mousewhere (mx, my, b)
exit when mx > 288 and mx < 634 and my > 185 and my < 234 and b = 1
end loop
%THE INSTRUCTIONS
loop
Pic.Draw (instructions, 0, 0, picMerge)
mousewhere (mx, my, b)
exit when mx > 242 and mx < 694 and my > 104 and my < 170 and b = 1
end loop
|
|
|
|
|
|
 |
Dreadnought
|
Posted: Mon Jan 09, 2012 6:21 pm Post subject: Re: Making a cricle follow the x and y of another |
|
|
You have to understand what your code is actually doing.
This stops the onscreen window (the one you see) from receiving output, instead, all output is only sent to an offscreen window (a sort of virtual window in the computer's memory). However, when you call View.Update, the offscreen window is copied to the onscreen window.
http://compsci.ca/holtsoft/doc/view_update.html wrote: This can be used to provide smooth, flicker-free animation. Animated objects flicker when the object being animated disappears from the onscreen window for a period of time. By using View.Set ("offscreenonly") / View.Update, the onscreen window is never blank. Instead, the offscreen window drawn over top off the on screen window, replacing it. This means that the on-screen window is never blanked out, eliminating the flickering found in the animation.
This means that if you want to see something, you must call View.Update. In your case, the intro picture is drawn to the onscreen window because it is the first thing ever drawn to the Turing window (this is a special case). The instruction picture is drawn to the offscreen window but not the onscreen one (thus it doesn't show up). Finally, when the game starts, the game loop draw's over the instruction picture in the offscreen window and calls View.update, meaning, the instruction picture is never drawn to the onscreen window.
Hope this has cleared up the problem. |
|
|
|
|
 |
mobin12
|
Posted: Mon Jan 09, 2012 6:39 pm Post subject: RE:Making a cricle follow the x and y of another |
|
|
| so where am i suppposed to put View.Update on the 'intro code' or the 'instructions code'? |
|
|
|
|
 |
Dreadnought
|
Posted: Mon Jan 09, 2012 7:20 pm Post subject: Re: Making a cricle follow the x and y of another |
|
|
mobin12 wrote:
it never showed the intructions pic that i made
Dreadnought wrote:
This stops the onscreen window (the one you see) from receiving outputt, instead, all output is only sent to an offscreen window
This means that if you want to see something, you must call View.Update.
Where do you draw stuff that you want to see?
If you want this stuff to be visible, should you update the screen before or after you draw said stuff? |
|
|
|
|
 |
|
|