Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
125 user(s) are online (117 user(s) are browsing Forums)

Members: 0
Guests: 125

more...

Support us!

Headlines

 
  Register To Post  

« 1 ... 3 4 5 (6) 7 8 9 »
Re: Doesn't Seem to be Any Programing Languages for AOS4 for the Average Person
Quite a regular
Quite a regular


See User information
Hi ChrisH,

If the upper part works (ref. post #91), and it IS relatively readable, I don't understand why the lower half exists or what it is doing.

You see, I cannot get to grips with this
closeWindow()

Why are those brackets there? Why isn't a variable inbetween them?


As for making the variables global, that's because I almost always need access to all of them at any given time. Being in any procedure, I may instantly need what weapon the character is holding, or what hitpoints he has, or the variable that describes the room he's in or monster he's facing.

The program wasn't finished. It needs probably 7 times more code.

Support Amiga Fantasy cases!!!
How to program: 1. Start with lots and lots of 0's. 10. Add 1's, liberally.
"Details for OS 5 will be made public in the fourth quarter of 2007, ..." - Bill McEwen
Whoah!!! He spoke, a bit late.
Go to top
Re: Doesn't Seem to be Any Programing Languages for AOS4 for the Average Person
Not too shy to talk
Not too shy to talk


See User information
@Atheist

Quote:
You see, I cannot get to grips with this
closeWindow()

Why are those brackets there? Why isn't a variable inbetween them?

This is the sort of thing that the tutorial I linked to before explains.

Go to top
Re: Doesn't Seem to be Any Programing Languages for AOS4 for the Average Person
Quite a regular
Quite a regular


See User information
Hi ChrisH,

That is a lot to expect from a person that wants to change the colour of one pixel!!!

In 1985 I took a computer course and in the Pascal unit I asked the teacher how to change the colour of a pixel on the screen, and he said that I should figure it out from the manual.

Support Amiga Fantasy cases!!!
How to program: 1. Start with lots and lots of 0's. 10. Add 1's, liberally.
"Details for OS 5 will be made public in the fourth quarter of 2007, ..." - Bill McEwen
Whoah!!! He spoke, a bit late.
Go to top
Re: Doesn't Seem to be Any Programing Languages for AOS4 for the Average Person
Home away from home
Home away from home


See User information
@Atheist


Quote:

To me
char *str1;
means multiply "char" with "str1".


Thats because this some thing that does not exist in basic,
this is an array whit out any defined size and storage space,
it called a char pointer, and it's major difference between basic and C.

I think you know what this is:

char str1[100];

it's array of 100 chars, some programs language define this as strings.

I can give you an example of how pointers work:

Typical basic program:

Quote:

ptr=$1000
Rem read one byte form address ptr+0
Print "Get value of peek ="; Peek(ptr+0)


the same program in C

Quote:

char *ptr;
ptr=0x1000;
/* Read one byte from address n+0 */
printf("Get value of peek = %d\n",ptr[0]);


This two do the same, the C program does not use a command to read from address 0x1000+0, but uses a special table variable (char pointer).

the above examples will give you a DSI error, change the code to;

Quote:

#include <stdlib.h>

int main()
{
char *ptr;
// reserves 100 bytes at any address
ptr = malloc(100);
printf("Get value of peek = %d\n",ptr[0]);
// frees 100 bytes after use.
free(ptr);
}


A better way to read and write chars, are to use sscanf(), sprintf().

(NutsAboutAmiga)

Basilisk II for AmigaOS4
AmigaInputAnywhere
Excalibur
and other tools and apps.
Go to top
Re: Doesn't Seem to be Any Programing Languages for AOS4 for the Average Person
Quite a regular
Quite a regular


See User information
Just to be accurate this:
Quote:

MODULE '*athiest'

PROC main()
openWindow(320, 200)

Plot(159, 99, 2)

waitForUserToCloseWindow()
closeWindow()
ENDPROC




OPT MODULE, EXPORT
MODULE 'intuition/intuition'
DEF window

PROC openWindow(width, height, x=0, y=0, title=0)
window := OpenW(x, y, width, height, IDCMP_CLOSEWINDOW, WFLG_CLOSEGADGET OR WFLG_ACTIVATE, IF title THEN title ELSE 'window', NIL, 1, NIL)
IF window = NIL
PrintF('ERROR -- Could not open window!\n')
Raise("WIN")
ENDIF
ENDPROC

PROC closeWindow() IS CloseW(window)

PROC waitForUserToCloseWindow()
WHILE WaitIMessage(window) <> IDCMP_CLOSEWINDOW
ENDWHILE
ENDPROC



is better than this:
Plot 159,99,7


to change the colour of one pixel on the screen.

I just wanted some perspective.

Support Amiga Fantasy cases!!!
How to program: 1. Start with lots and lots of 0's. 10. Add 1's, liberally.
"Details for OS 5 will be made public in the fourth quarter of 2007, ..." - Bill McEwen
Whoah!!! He spoke, a bit late.
Go to top
Re: Doesn't Seem to be Any Programing Languages for AOS4 for the Average Person
Quite a regular
Quite a regular


See User information
Hi LiveForIt,

You lost me.

ptr=0x1000

"x" isn't a number?!? The more I see, the less "normal" it all becomes.

Support Amiga Fantasy cases!!!
How to program: 1. Start with lots and lots of 0's. 10. Add 1's, liberally.
"Details for OS 5 will be made public in the fourth quarter of 2007, ..." - Bill McEwen
Whoah!!! He spoke, a bit late.
Go to top
Re: Doesn't Seem to be Any Programing Languages for AOS4 for the Average Person
Just popping in
Just popping in


See User information
@Atheist

--- PLOT IN HOLLYWOOD ---
Plot(x, y, color)


@LiveForIt
Quote:

I don?t know what you?re trying to do whit the last line; I think a structure might be better.
A structure is a way to group variables.

Struct
{
char *str1;
char *str2;
int value1;
int value2;
char *str3;
} my_value_type;


That's the way Hollywood (and LUA) handle data, somithing similar to standard structures:

mytable = { 2, 3, "four" }

is the same as
mytable[0] = 2
mytable[1] = 3
mytable[2] = "four"


you can have non-numeric indexes to simulate structures:
mytable = { name = "Johnny", surname = "Mnemonic" }

so you can access them with:
mytable.name
mytable.surname


but this is not a LUA thread

Go to top
Re: Doesn't Seem to be Any Programing Languages for AOS4 for the Average Person
Home away from home
Home away from home


See User information
@Atheist

Quote:
I have made a 4 dimensional array in AMOS, as well as many many other arrays and have no problem whatsoever manipulating them.


this how you make a 4 dimensional array in C.

int values[50][50][50][50];

structures are not the same, the basic idea behind structures is to name content group properties.
if you have used virtual basic you know that virtual basic objects have properties for fonts, text, caption, x, y, width, height, index.

// count from 0 to 9
for (n=0;n<10;n++)
{
printf("Car x pos = %d\n",car[n].x);
printf("Car y pos = %d\n",car[n].y);
printf("Car name = %s\n", name[n].name);
}

the same code in basic using a 2 dimensional array

for n = 0 to 9 step 1
print "Car x pos = " ; car[n,0]
print "Car y pos = " ; car[n,1]
print "car name = " ; car[n,2]
next n

the 2en example is harder to read, you need to know that 0 is x, and 1 is y and 2 is name.

it's not problem remembering this the day you write it, but if find you find your old source code 5 years later then its hard to remember what 0 is and 1 is and 2 is.


Edited by LiveForIt on 2009/1/13 23:24:59
(NutsAboutAmiga)

Basilisk II for AmigaOS4
AmigaInputAnywhere
Excalibur
and other tools and apps.
Go to top
Re: Doesn't Seem to be Any Programing Languages for AOS4 for the Average Person
Just popping in
Just popping in


See User information
@Atheist

The only reason Amos looks so plain to you is that it does a lot of work that is totally hidden to you. It opens a screen by default so you don't have to, for example. Even sdlBasic doesn't do that for you. It allows input on that screen without opening a window on that screen. Even AmigaOS doesn't allow that.

Atheist, you have no idea how much more work it is to write a hardware-banging monstrosity like Amos than to write a system-friendly programming language like PortablE.

Incidently sdlBasic is forever doomed to be an interpreted language because of the way that it handles the typing of its variables. You can use a variable as a string in one context and an integer in another context just by reassigning the variable a different value. That's fine for Python and sdlBasic but if you want to compile them for greater efficiency, you're better off with another language.

I have used C for a long time and I don't think it is all that simple. It tries to use single characters where keywords should have been used. C++ is easier to write classes but can still be done cryptically in C.

If you want to count AmosPro as being a useful language you'd better not rule out Assembly because that is the language that all of the extensions are written in. You can't write extensions for AmosPro in AmosPro, you can only include reuseable procedures with the Include command.

You've been waiting for Sidewinder and i to finish Mattathias for a long time. You know what? It's going to still be a long time because of the amount of work it is to write it.

With PortablE, you can write extensions to the language in PortablE. That is the value of an object-oriented language. The downside is that you're expected to write extensions to get the job done.

If you want to converse on the subject off-list, send me a PM.

Go to top
Re: Doesn't Seem to be Any Programing Languages for AOS4 for the Average Person
Home away from home
Home away from home


See User information
@Atheist


Quote:

Hi LiveForIt,

You lost me.

ptr=0x1000

"x" isn't a number?!? The more I see, the less "normal" it all becomes.


yes it is a number it's a hex number $1000

'0x' = '$'

(NutsAboutAmiga)

Basilisk II for AmigaOS4
AmigaInputAnywhere
Excalibur
and other tools and apps.
Go to top
Re: Doesn't Seem to be Any Programing Languages for AOS4 for the Average Person
Quite a regular
Quite a regular


See User information
I agree with ChrisH - distractions removed :D


Edited by Slayer on 2009/1/14 0:05:09
Edited by Slayer on 2009/1/14 10:29:06
~Yes I am a Kiwi, No, I did not appear as an extra in 'Lord of the Rings'~
1x AmigaOne X5000 2.0GHz 2gM RadeonR9280X AOS4.x
3x AmigaOne X1000 1.8GHz 2gM RadeonHD7970 AOS4.x
Go to top
Re: Doesn't Seem to be Any Programing Languages for AOS4 for the Average Person
Not too shy to talk
Not too shy to talk


See User information
The problem with this thread is that we're all trying to teach Atheist how to program, and we're not teaching the subjects in the right order, jumping back and forth between different areas. The tutorial I linked to teaches the basics, then builds on it for each lesson.

Go to top
Re: Doesn't Seem to be Any Programing Languages for AOS4 for the Average Person
Home away from home
Home away from home


See User information
@Atheist Quote:
You see, I cannot get to grips with this
closeWindow()

Why are those brackets there? Why isn't a variable inbetween them?

It's the same reason the sky is blue - IT'S JUST THE WAY THINGS ARE, so you have to accept it. I can see why jahc got fed up - and I shall probably follow his lead...

edit: However, if I was being slightly more helpful, I would also say that the brackets are there to tell E that you are calling a procedure. There is nothing between the brackets, because closeWindow does not need or expect any extra information.

Quote:
That is a lot to expect from a person that wants to change the colour of one pixel!!!

Please tell me, how is this a lot to expect?:
Plot(159, 99, 2)

The other stuff is to open & close a window - something you didn't need to do in AMOS, because it opened a screen for you whether or not you wanted it!

PROC main()
openWindow(320, 200)

Plot(159, 99, 2)

waitForUserToCloseWindow()
closeWindow()
ENDPROC


Precisely why is this a lot to expect from someone? It has ONE LINE to open a window, ONE LINE to plot a pixel, ONE LINE to wait for the user to click on the close button, and ONE LINE to close the window.

I really don't get your problem. The WHOLE POINT of the "athiest.e" file I created was to HIDE the stuff that you never need to see again. This is how programming languages work - you look-up how to do the hard stuff, then hide it in a procedure (and a file) that you may never look at again.

Not to mention that "athiest.e" file was mostly a copy & past job from Jason Hulances example. It took me a minute at most, and I didn't even need to understand how most of it worked.

Author of the PortablE programming language.
Go to top
Re: Doesn't Seem to be Any Programing Languages for AOS4 for the Average Person
Home away from home
Home away from home


See User information
@athiest
It does seem that you have some sort of "mental block" regarding programming, where if it is different from AMOS then your brain goes "I can't deal with that" & doesn't even TRY to understand it.

Well, unfortunately that is your problem (not the rest of the world's), and I don't see how I can help any further. Except to re-iterate my suggestion of Hollywood. Or perhaps switch to (Dark) Basic programming on a Windows PC.

(Of course, if you actually made any progress due to my previous post, then I would be happy to try to continue helping you. But currently I see *zero* progress on your part. Feel free to re-read my previous posts at your leisure, and PM me if you think you might have understood a little of what I have been trying to explain.)


Edited by ChrisH on 2009/1/14 10:12:02
Author of the PortablE programming language.
Go to top
Re: Doesn't Seem to be Any Programing Languages for AOS4 for the Average Person
Amigans Defender
Amigans Defender


See User information
@Atheist

You haven't commented on the C at the end of post #93 yet.


@Allanon

Quote:

That's the way Hollywood (and LUA) handle data, somithing similar to standard structures:

mytable = { 2, 3, "four" }

is the same as
mytable[0] = 2
mytable[1] = 3
mytable[2] = "four"

you can have non-numeric indexes to simulate structures:
mytable = { name = "Johnny", surname = "Mnemonic" }

so you can access them with:
mytable.name
mytable.surname


Perl does something similar.

You'll have to excuse me if this is wrong as it is somewhat confusing and I don't dabble in Perl often enough to remember it properly, but your example looks like this in Perl:

@mytable = {2,3,'four'};
Hmm, maybe that should be:
@mytable = (2,3,'four');

$mytable[0] = 2;
$mytable[1] = 3;
$mytable[2] = 'four';

$mytable['name'] = 'Johnny';
$mytable['surname'] = 'Mnemonic';

The above two you can probably do in one line, but I'd have to look it up. It might be
@mytable = {'name','Johnny','surname','Mnemonic'};

This is particularly useful when you assign strings to variables and then pull out the related data from an array like so:
$idx = 'name';
print $mytable[$idx];

would print Johnny.

I emulate this a bit in C sometimes by using two identical-sized arrays, finding the index of a string in the first array then tells me where to find the data in the second. It's surprisingly even less readable than the original Perl.

Whoever invented Perl needs a kick. What sort of brackets am I suppsoed to be using? Is my variable @ or $ or % in this context? wtf does /\//\./g mean? Arrgh!

Chris

(sorry, edited in some changes and ranting)

Go to top
Re: Doesn't Seem to be Any Programing Languages for AOS4 for the Average Person
Quite a regular
Quite a regular


See User information
I agree with ChrisH - distractions removed :D


Edited by Slayer on 2009/1/14 10:29:49
~Yes I am a Kiwi, No, I did not appear as an extra in 'Lord of the Rings'~
1x AmigaOne X5000 2.0GHz 2gM RadeonR9280X AOS4.x
3x AmigaOne X1000 1.8GHz 2gM RadeonHD7970 AOS4.x
Go to top
Re: Doesn't Seem to be Any Programing Languages for AOS4 for the Average Person
Quite a regular
Quite a regular


See User information
Quote:
Chris wrote:

Of course, that's not a complete example, which would be more like this:
// Compile with gcc -o pixelplot pixelplot.c -lauto

#include <proto/intuition.h>
#include <proto/graphics.h>

int main(void)
{
struct Window *window;

window = IIntuition->OpenWindow(NULL);
IGraphics->WritePixel(window->RastPort,0,0);
}

Which is obviously completely ridiculous, as the pixel plotted will end up over the window border (if it has a border, which we can't know for sure), we don't know what colour it will be, and the whole caboodle is left on screen after the program exits.



Hi Chris

As you point out in the last paragraph, that's the tip of the iceberg to simply placing one pixel in a given point on the screen. Also, is there case sensitivity? I see capitals, sometimes not. What's the call on that?


"gcc -o pixelplot pixelplot.c -lauto"

It becomes easy to learn to parse out the statment above?
Okay, I can see the name of the source and the compiled file to be made, actually. But there are a bazillion options, right? Like I said, I've seen 30 post threads on "what option should I use".


When I started this thread, I merely wanted to point out that there isn't much available to use for a bit of easy programming.

P.S. What about "Return 0;". Isn't there always a "return 0;" (why, I don't know, more useless junk) at the end?

Support Amiga Fantasy cases!!!
How to program: 1. Start with lots and lots of 0's. 10. Add 1's, liberally.
"Details for OS 5 will be made public in the fourth quarter of 2007, ..." - Bill McEwen
Whoah!!! He spoke, a bit late.
Go to top
Re: Doesn't Seem to be Any Programing Languages for AOS4 for the Average Person
Home away from home
Home away from home


See User information
@Atheist

Quote:

Atheist wrote:
Quote:
Hans wrote:

Semi-colons denote the end of an actual line of code, which can be multiple lines long.


Hi Hans,

Reading the above, therefore:
Quote:
Hans wrote:
this is C:

if( x == 10)
{
drawCar();
}
else
{
drawPig();
}

to me becomes (and can only make sense) by your own rule:


if( x == 10){drawCar();
} else { drawPig();
}


You could even put it all on one line if you wish.

Quote:
And that last bracket seems to be missing the semi-colon. This is why I can not understand C. I can not understand why there isn't a semicolon to the right of the final bracket??


Because a bracket is not a line of code. The brackets enclose a one or more lines of code that belong together because they're part of a loop, an if/else statement, a function, or any other block of grouped lines.

Now on to why closeWindow() has "()" after it with no variables. In C, a function has its inputs enclosed in "()". Some functions take no inputs, so the area between "(" and ")" is empty. However, it is still a function. What this means is that it is immediately obvious that closeWindow() is a function call, not something else.

Hans

Join Kea Campus' Amiga Corner and support Amiga content creation
https://keasigmadelta.com/ - see more of my work
Go to top
Re: Doesn't Seem to be Any Programing Languages for AOS4 for the Average Person
Home away from home
Home away from home


See User information
@Atheist Quote:
As for making the variables global, that's because I almost always need access to all of them at any given time.

Actually you don't need access to everything at once. It is only because you have not split-up your program in to procedures the right way (or at all). And that is at least partly because you are using a limited programming language like AMOS. Of course you don't realise it is limiting, because you have never experienced anything different.

If your game (?) was written using a better programming language, you could avoid having ANY global variables. Loads of global variables simply mean that anything can affect anything else, and that means it will quickly get difficult to change how anything works - not to mention meaning you tend to need to know how everything works at the same time.

Author of the PortablE programming language.
Go to top
Re: Doesn't Seem to be Any Programing Languages for AOS4 for the Average Person
Not too shy to talk
Not too shy to talk


See User information
@Atheist

Quote:
P.S. What about "Return 0;". Isn't there always a "return 0;" (why, I don't know, more useless junk) at the end?

This is covered in the functions tutorial on the link I gave you. But it would probably be best to do the lessons in the right order from the beginning, because they build upon each other, and if you jump straight to the lesson on functions, then it might not make sense due to relying on other areas of C to demonstrate it.

Also, it's not useless junk, its useful. In the game engine I'm making, I made a function that queries whether my character has collided with any of the enemys. I can make it return TRUE if he has, and then decrease his life etc, or if it returns FALSE then I can choose to do nothing on him. I have a loop that runs this function on all of my enemys that are alive.
Edit: thats only one very simple example of a use for return. I wont elaborate more because it wont make sense unless you start learning the language.

Edit2: Actually, that explanation may be a little too dumbed down. :) I actually have a function that takes any two pieces of graphics, and using it I can test to see if they overlapped/collided.
For example:
1. a platform tile on my level and the player 1 character
2. an enemy and a player 1 bullet
3. an enemy bullet and my player 1 character
etc.
So by only having the one collision detection function, I'm reusing code. So when I ask "did player 1 collide with an enemy bullet?" and it returns TRUE, then we can act and make his life decrease.


Edited by jahc on 2009/1/14 3:04:30
Go to top

  Register To Post
« 1 ... 3 4 5 (6) 7 8 9 »

 




Currently Active Users Viewing This Thread: 3 ( 0 members and 3 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project