Recent

Author Topic: Is there any problem with my programme?plz help!  (Read 4676 times)

7vinbaby

  • Jr. Member
  • **
  • Posts: 59
  • Hi ! Bless you have a good day.
Is there any problem with my programme?plz help!
« on: September 13, 2016, 03:54:52 pm »
the problem has solved. thx
« Last Edit: September 13, 2016, 04:07:30 pm by 7vinbaby »
7vinbaby

rvk

  • Hero Member
  • *****
  • Posts: 6162
Re: Is there any problem with my programme?plz help!
« Reply #1 on: September 13, 2016, 04:08:37 pm »
the problem has solved. thx
And please put your code between [code][/code]-tags (or press the #-button above the editor) in the future (like I already asked in your other topic).

DiCri

  • Full Member
  • ***
  • Posts: 151
  • My goal : Build a game
    • http://manueldicriscito.altervista.org/DinoLand.zip
Re: Is there any problem with my programme?plz help!
« Reply #2 on: September 13, 2016, 04:10:57 pm »
I am studying the code. Let's assume this:
Code: Pascal  [Select][+][-]
  1. procedure find_runway(var runway,count:integer);
  2. begin
  3.         with runway[count] do
  4.         begin
  5.         if  (count<3)
  6.         then  begin
  7.                 find_runway(runway,count);
  8.                 if runway_condition='y'
  9.                 then runway=count;
  10.                 count:=count+1;
  11.               end;
  12.         end;
  13.  
  14. end;
  15.  
The variable "runway" is not an array so it says error when writing runway[count]. And i don't know why there is a procedure into his same procedure.
I see there's the line "find_runway( runway, count ) into his same procedure.
And maybe you should see the meaning of "with..do" .. "with" uses only record type variables so here is it an example:
Code: Pascal  [Select][+][-]
  1. uses crt;
  2. var
  3. runway : record
  4.   count : integer;
  5.   end;
  6. begin
  7.   runway.count := 1;
  8.   with runway do if count = 1 then writeln('hi');
  9.   readln;
  10. end;
  11.  
i hope you understand.. my english is not very good! Hope all's okay! ;)

I'm a game developer.. Now studying..
Go download my game:
http://manueldicriscito.altervista.org/DinoLand.zip

DiCri

  • Full Member
  • ***
  • Posts: 151
  • My goal : Build a game
    • http://manueldicriscito.altervista.org/DinoLand.zip
Re: Is there any problem with my programme?plz help!
« Reply #3 on: September 13, 2016, 04:11:56 pm »
the problem has solved. thx
ehm.. too late.. it was my first reply for helping someone.. :-[
I'm a game developer.. Now studying..
Go download my game:
http://manueldicriscito.altervista.org/DinoLand.zip

Handoko

  • Hero Member
  • *****
  • Posts: 5149
  • My goal: build my own game engine using Lazarus
Re: Is there any problem with my programme?plz help!
« Reply #4 on: September 13, 2016, 04:36:32 pm »
@7vinbaby:

Glad to hear you have solved the problem. And please help use to help you by adding code tag next time. I saw this post a while ago but reluctant to help because the code was hard to read without code tag.

@Manu12x

Nice try Manu. You're right "with" statement is used for record type variables. But if you have learned OOP (object oriented programming), you will know "with" can be used with class and object too.

http://www.freepascal.org/docs-html/ref/refsu63.html

You can always find useful information about certain Pascal programming statement or topic using google search by using query:

"free pascal " + [the_keyword]

For example, to learn more about "with", you use google to search for:
"free pascal with"

Quote
ehm.. too late.. it was my first reply for helping someone.. :-[

Newbies always pop up, you have lots of chances to help them.
« Last Edit: September 13, 2016, 04:38:47 pm by Handoko »

DiCri

  • Full Member
  • ***
  • Posts: 151
  • My goal : Build a game
    • http://manueldicriscito.altervista.org/DinoLand.zip
Re: Is there any problem with my programme?plz help!
« Reply #5 on: September 13, 2016, 04:40:10 pm »
@7vinbaby:

Glad to hear you have solved the problem. And please help use to help you by adding code tag next time. I saw this post a while ago but reluctant to help because the code was hard to read without code tag.

@Manu12x

Nice try Manu. You're right "with" statement is used for record type variables. But if you have learned OOP (object oriented programming), you will know "with" can be used with class and object too.

http://www.freepascal.org/docs-html/ref/refsu63.html

You can always find useful information about certain Pascal programming statement or topic using google by using query:

"free pascal " + [the_keyword]

For example, to learn more about "with", you use google to search for:
"free pascal with"

Quote
ehm.. too late.. it was my first reply for helping someone.. :-[

Newbies always pop up, you have lots of chances to help them.
i am going too fast and i don't like to.. i heard objects with c++ but not in free pascal but i will learn! not now! but what do you mean with code tag? you mean (code=pascal)..?
I'm a game developer.. Now studying..
Go download my game:
http://manueldicriscito.altervista.org/DinoLand.zip

rvk

  • Hero Member
  • *****
  • Posts: 6162
Re: Is there any problem with my programme?plz help!
« Reply #6 on: September 13, 2016, 04:43:23 pm »
i am going too fast and i don't like to.. i heard objects with c++ but not in free pascal but i will learn! not now! but what do you mean with code tag? you mean (code=pascal)..?
Yep. It used to be just [code]your code[/code] but functionality was added for code-highlighting for pascal (hence the =pascal after code).
The #-button above the editor will automatically add [code=pascal]your code[/code].
(you can select your code and press that button, but you already knew that :) )
« Last Edit: September 13, 2016, 04:46:17 pm by rvk »

Handoko

  • Hero Member
  • *****
  • Posts: 5149
  • My goal: build my own game engine using Lazarus
Re: Is there any problem with my programme?plz help!
« Reply #7 on: September 13, 2016, 04:58:11 pm »
@Manu12x

OOP is very powerful, without using OOP it will be hard to write complex codes.

Example case of usage:
You can imagine, you dino game how has became a complete game. It has 5 dino types, it also can has pets. There are 3 kinds of enemies: land monster, flying monster, outer space aliens falling from sky. Objects you need to avoid: tree, big rock, wall. There are 3 kind of trees: small, big, huge. Two kinds of walls: tall and wide.

How should you write the code? Using record? Yes you can, but it will be very complicated to handle the different types of objects.

That's why OOP is born. You define the main object type, and the sub object types that each one has its own behavior and size and animation. Each sub object types can has their own sub object types too.

You can consider objects is a more powerful version of records.

The sample case above is very easy to code if you're an OOP expert.
I use OOP a lot and "with" statement too.

About the code tag, yes you're right.
« Last Edit: September 13, 2016, 05:04:33 pm by Handoko »

DiCri

  • Full Member
  • ***
  • Posts: 151
  • My goal : Build a game
    • http://manueldicriscito.altervista.org/DinoLand.zip
Re: Is there any problem with my programme?plz help!
« Reply #8 on: September 13, 2016, 05:01:31 pm »
@Manu12x

OOP is very powerful, without using OOP it will be hard to write complex codes.

Example case of usage:
You can imagine, you dino game how has became a complete game. It has 5 dino types, it also can has pets. There are 3 kinds of enemies: land monster, flying monster, outer space aliens falling from sky. Objects you need to avoid: tree, big rock, wall. There are 3 kind of trees: small, big, huge. Two kinds of walls: tall and wide.

How should you write the code? Using record? Yes you can, but it will be very complicated to handle the different types of objects.

That's why OOP is born. You define the main object type, and the sub object types that each one has its own behavior and size and animation. Each class and sub class can has their own sub class too.

The sample case above is very easy to code if you're an OOP expert.

About the code tag, yes you're right.
ok now i understand! Because, yes, i use record type for doing that! As i told before.. i don't want to go fast.. i may will be lost. so i will learn it
I'm a game developer.. Now studying..
Go download my game:
http://manueldicriscito.altervista.org/DinoLand.zip

Handoko

  • Hero Member
  • *****
  • Posts: 5149
  • My goal: build my own game engine using Lazarus
Re: Is there any problem with my programme?plz help!
« Reply #9 on: September 13, 2016, 05:16:43 pm »
You're a fast learner.

Unfortunately, your basic Pascal knowledge is weak. You learn thing not follow the basic steps. It's okay, but you will be better to strengthen your basic knowledge of Pascal programming.

If you have time, try to follow these tutorials step-by-step:
http://www.pascal-programming.info/index.php
http://www.taoyue.com/tutorials/pascal/index.html
http://www.marcocantu.com/epascal/English/default.htm

I know, most the the tutorials above are boring, but that's the basic things you have to pass with a perfect 10 score. Also you will see some of the topics you've already know, it is good to read and review the topics again to make sure you really have understand them.

 

TinyPortal © 2005-2018