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

Username:   Password: 
 RegisterRegister   
 Loading pictures in records
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
iker




PostPosted: Wed Jul 12, 2006 5:03 pm   Post subject: Loading pictures in records

I've just recently started to implement ai into the Dragon Slayer game, and I found that when loading the picturues for the characters, one set manages to get screwed up. At the bottom of the code, before the main loop, you'll see where the loading procedures are called upon. So far, the Ai is in its starting stage and has not been completed. Anyways, if anyone can help me find the problem, it would be a great help.

edit * sorry i need more upload space please
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Wed Jul 12, 2006 6:39 pm   Post subject: (No subject)

increased upload space - PM me next time
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
iker




PostPosted: Wed Jul 12, 2006 8:03 pm   Post subject: (No subject)

Thanks for the space tony Very Happy
heres the files



Dragon Slayer.rar
 Description:
arrows move
space jump
z attack
x jump/attack
c "hover" attack

Download
 Filename:  Dragon Slayer.rar
 Filesize:  796.12 KB
 Downloaded:  90 Time(s)

Delos




PostPosted: Wed Jul 12, 2006 8:31 pm   Post subject: (No subject)

I'm getting an error at line 377:

Error wrote:

Cannot allocate item. Out of id numbers (max 1000).


That means one thing - inefficent pic loading. You should almost never have to have *that* many pics present at any one stage in the game. If you're getting this error as well, then simply divide the pics you load into groups based on the level/map.
I'm not sure if this is the error you're referring to though.

A couple of general comments (choose to implement which ever you like):
- from the onset, I'll recommend rewriting (REWRITing, that is!) all of the code in the form of objectified Classes. It will make your life down the road a lot easier.
- learn to use parameters in your procedures. You'll never be able to make a functional RPG (or any programme for that matter) if you have static procs. You've got the basics in a few of them, but hardly enough.
- your handling of movement is quite awful, to be honest. The way you've set it up, you have several unique procedures, each having access to a global variable, each changing the values of other global variables...not a smart idea.
Instead, compress these all into a single, simple movement procedure (if at all) and call this from your main loop. You have the idea, but your execution leaves a lot to be desired.
For instance:
pseudo:

begin loop
   check keyboard status
   if left_arrow then
      delta_x := -1
   elsif up_arrow then
      delta_y := 1
   ...
   end if
   move (my_character, delta_x, delta_y)
   reset_deltas ()   % Resets d_x and d_y to (0, 0).
end loop


Notice the 'move' procedure. This takes a character for an argument, as well as directionality vectors. Were you to do this in a Classified system, you'd use syntax similar to:

code:

Character (my_character).move (delta_x, delta_y)

% or, for short:

my_character -> move (delta_x, delta_y)


Doesn't that feel more intuitive than passing a character object to a procedure? Movement is a property of a character, and hence should be intrinsic to its behaviour, as it is with a Class system.


Edit: BTW, nice sprite sets. Where'd you get them from?
iker




PostPosted: Thu Jul 13, 2006 6:34 pm   Post subject: (No subject)

Thanks Delos, the problem does seem to lie in loading over 1000 pictures. I've reduced the amount of pictures to only 4 frames for each direction in each action instead of 7-12 frames. Now, I can see why you insist changing to classes. The code is realy sloppy, and I realy don't know too much about using classes. It seems simple enough, and I'm currently reading over Cervantes' introduction and walkthrough of Classes. I'm planning on switching over to using classes, but in the meentime, I'm going to continue programming with procedures.

And as for the sprites, I downloaded them from http://reinerstileset.4players.de/englisch.htm. I would have mentioned this earlier, but I totally forgot.
Delos




PostPosted: Thu Jul 13, 2006 9:09 pm   Post subject: (No subject)

I thought they looked familiar!

As for the 1000+ problem, I seriously doubt whether having ~32 frames for a single sprite would result in an overflow there. You could attempt to have seperate sprite_pic and character arrays (read: Sprite_pic class and Character class, possibly both children of a Sprite class) in which a character would access the sprite_pics for its pics, thus save you having to redeclare them anew for each sprite of the same shape.
In other words, check your code - you might find some redundancies.
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 1  [ 6 Posts ]
Jump to:   


Style:  
Search: